7 #define THAI_BEG 0x0E00
8 #define THAI_END 0x0E6F
10 static int wordcut_initiazlied = 0;
12 #include <wordcut/wordcut.h>
14 static Wordcut wordcut;
16 static MSymbol Mwordcut_wordbeg, Miso_8859_11;
21 Mwordcut_wordbeg = msymbol (" wordcut-wordseg");
22 Miso_8859_11 = msymbol ("iso-8859-11");
26 thai_line_break (MText *mt, int pos, int from, int to)
33 if (wordcut_initiazlied < 0)
35 if (! wordcut_initiazlied)
37 if (wordcut_init (&wordcut, WORDCUT_TDICT) != 0)
39 wordcut_initiazlied = -1;
43 wordcut_initiazlied = 1;
45 prop = mtext_get_property (mt, pos, Mwordcut_wordbeg);
48 pos1 = mtext_property_start (prop);
53 str = alloca (to - from);
56 && (c = mtext_ref_char (mt, pos1)) >= THAI_BEG && c <= THAI_END)
57 str[pos1-- - from] = mchar_encode (Miso_8859_11, c);
61 && (c = mtext_ref_char (mt, pos2)) >= 0x0E00 && c <= 0x0E6F)
62 str[pos2++ - from] = mchar_encode (Miso_8859_11, c);
64 wordcut_cut (&wordcut, (char *) (str + pos1 - from), &result);
65 for (i = 0; i < result.count; i++)
67 int start = pos1 + result.start[i];
69 prop = mtext_property (Mwordcut_wordbeg, Mt,
70 MTEXTPROP_VOLATILE_WEAK | MTEXTPROP_NO_MERGE);
71 mtext_attach_property (mt, start, start + result.offset[i], prop);
72 m17n_object_unref (prop);
74 prop = mtext_get_property (mt, pos, Mwordcut_wordbeg);
75 pos1 = mtext_property_start (prop);
81 #define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) \
83 if ((c) >= THAI_BEG && (c) <= THAI_END) \
84 return thai_line_break ((mt), (pos), (from), (to)); \
87 #else /* not HAVE_WORDCUT */
89 #define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) (void) 0
91 #endif /* not HAVE_WORDCUT */
94 line_break (MText *mt, int pos, int from, int to, int line, int y)
96 int c = mtext_ref_char (mt, pos);
99 if (c == ' ' || c == '\t' || c == '\n')
101 for (pos++; pos < to; pos++)
102 if ((c = mtext_ref_char (mt, pos)) != ' ' && c != '\t' && c != '\n')
109 if (c == ' ' || c == '\t')
111 CHECK_THAI_LINE_BREAK (c, mt, pos, from, to);
113 c = mtext_ref_char (mt, pos);