7 #define THAI_BEG 0x0E00
8 #define THAI_END 0x0E6F
10 static int wordcut_initiazlied = 0;
12 #include <wordcut/wordcut.h>
13 #include <wordcut/xmalloc.h>
14 #include <wordcut/path.h>
16 static Wordcut wordcut;
18 static MSymbol Mwordcut_wordbeg, Miso_8859_11;
23 Mwordcut_wordbeg = msymbol (" wordcut-wordseg");
24 Miso_8859_11 = msymbol ("iso-8859-11");
28 thai_line_break (MText *mt, int pos, int from, int to)
35 if (wordcut_initiazlied < 0)
37 if (! wordcut_initiazlied)
39 if (wordcut_init (&wordcut, WORDCUT_TDICT) != 0)
41 wordcut_initiazlied = -1;
45 wordcut_initiazlied = 1;
47 prop = mtext_get_property (mt, pos, Mwordcut_wordbeg);
50 pos1 = mtext_property_start (prop);
55 str = alloca (to - from);
58 && (c = mtext_ref_char (mt, pos1)) >= THAI_BEG && c <= THAI_END)
59 str[pos1-- - from] = mchar_encode (Miso_8859_11, c);
63 && (c = mtext_ref_char (mt, pos2)) >= 0x0E00 && c <= 0x0E6F)
64 str[pos2++ - from] = mchar_encode (Miso_8859_11, c);
66 wordcut_cut (&wordcut, (char *) (str + pos1 - from), &result);
67 for (i = 0; i < result.count; i++)
69 int start = pos1 + result.start[i];
71 prop = mtext_property (Mwordcut_wordbeg, Mt,
72 MTEXTPROP_VOLATILE_WEAK | MTEXTPROP_NO_MERGE);
73 mtext_attach_property (mt, start, start + result.offset[i], prop);
74 m17n_object_unref (prop);
76 prop = mtext_get_property (mt, pos, Mwordcut_wordbeg);
77 pos1 = mtext_property_start (prop);
83 #define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) \
85 if ((c) >= THAI_BEG && (c) <= THAI_END) \
86 return thai_line_break ((mt), (pos), (from), (to)); \
89 #else /* not HAVE_WORDCUT */
91 #define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) (void) 0
93 #endif /* not HAVE_WORDCUT */
96 line_break (MText *mt, int pos, int from, int to, int line, int y)
98 int c = mtext_ref_char (mt, pos);
101 if (c == ' ' || c == '\t' || c == '\n')
103 for (pos++; pos < to; pos++)
104 if ((c = mtext_ref_char (mt, pos)) != ' ' && c != '\t' && c != '\n')
111 if (c == ' ' || c == '\t')
113 CHECK_THAI_LINE_BREAK (c, mt, pos, from, to);
115 c = mtext_ref_char (mt, pos);