From: handa Date: Fri, 15 Apr 2005 08:17:13 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-1-3-0~332 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ed667bd489adef44e6e6ccda6536c1f22fab68e5;p=m17n%2Fm17n-lib.git *** empty log message *** --- diff --git a/example/ChangeLog b/example/ChangeLog index 4ed07c2..cb47b22 100644 --- a/example/ChangeLog +++ b/example/ChangeLog @@ -1,3 +1,13 @@ +2005-04-15 Kenichi Handa + + * mdump.c (main): Set control.line_break to + mdraw_default_line_break. + + * Makefile.am (m17n_edit_SOURCES): Don't include linebreak.c. + (m17n_dump_SOURCES): Likewise. + (m17n_edit_LDADD): Don't include @WORDCUT_LD_FLAGS@. + (m17n_dump_LDADD): Likewise. + 2005-03-09 Kenichi Handa * HELLO.utf8, HELLO.xml, HELLO.html: Fix Telugu line. diff --git a/example/linebreak.c b/example/linebreak.c deleted file mode 100644 index 390b39a..0000000 --- a/example/linebreak.c +++ /dev/null @@ -1,121 +0,0 @@ -#include - -#include - -#ifdef HAVE_WORDCUT - -#define THAI_BEG 0x0E00 -#define THAI_END 0x0E6F - -static int wordcut_initiazlied = 0; - -#include - -static Wordcut wordcut; - -static MSymbol Mwordcut_wordbeg, Miso_8859_11; - -static void -init_th_wordcut () -{ - Mwordcut_wordbeg = msymbol (" wordcut-wordseg"); - Miso_8859_11 = msymbol ("iso-8859-11"); -} - -int -thai_line_break (MText *mt, int pos, int from, int to) -{ - WordcutResult result; - MTextProperty *prop; - int pos1, pos2, c, i; - unsigned char *str; - - if (wordcut_initiazlied < 0) - return pos; - if (! wordcut_initiazlied) - { - if (wordcut_init (&wordcut, WORDCUT_TDICT) != 0) - { - wordcut_initiazlied = -1; - return pos; - } - init_th_wordcut (); - wordcut_initiazlied = 1; - } - prop = mtext_get_property (mt, pos, Mwordcut_wordbeg); - if (prop) - { - pos1 = mtext_property_start (prop); - if (pos1 == from) - pos1 = pos; - return pos1; - } - str = alloca (to - from); - pos1 = pos - 1; - while (pos1 >= from - && (c = mtext_ref_char (mt, pos1)) >= THAI_BEG && c <= THAI_END) - str[pos1-- - from] = mchar_encode (Miso_8859_11, c); - pos1++; - pos2 = pos; - while (pos2 < to - && (c = mtext_ref_char (mt, pos2)) >= 0x0E00 && c <= 0x0E6F) - str[pos2++ - from] = mchar_encode (Miso_8859_11, c); - str[pos2 - from] = 0; - wordcut_cut (&wordcut, (char *) (str + pos1 - from), &result); - for (i = 0; i < result.count; i++) - { - int start = pos1 + result.start[i]; - - prop = mtext_property (Mwordcut_wordbeg, Mt, - MTEXTPROP_VOLATILE_WEAK | MTEXTPROP_NO_MERGE); - mtext_attach_property (mt, start, start + result.offset[i], prop); - m17n_object_unref (prop); - } - prop = mtext_get_property (mt, pos, Mwordcut_wordbeg); - pos1 = mtext_property_start (prop); - if (pos1 == from) - pos1 = pos; - return pos1; -} - -#define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) \ - do { \ - if ((c) >= THAI_BEG && (c) <= THAI_END) \ - return thai_line_break ((mt), (pos), (from), (to)); \ - } while (0) - -#else /* not HAVE_WORDCUT */ - -#define CHECK_THAI_LINE_BREAK(c, mt, pos, from, to) (void) 0 - -#endif /* not HAVE_WORDCUT */ - -int -line_break (MText *mt, int pos, int from, int to, int line, int y) -{ - int c = mtext_ref_char (mt, pos); - int orig_pos = pos; - - if (c == ' ' || c == '\t' || c == '\n') - { - for (pos++; pos < to; pos++) - if ((c = mtext_ref_char (mt, pos)) != ' ' && c != '\t' && c != '\n') - break; - } - else - { - while (pos > from) - { - if (c == ' ' || c == '\t') - break; - CHECK_THAI_LINE_BREAK (c, mt, pos, from, to); - pos--; - c = mtext_ref_char (mt, pos); - } - if (pos == from) - pos = orig_pos; - else - pos++; - } - return pos; -} diff --git a/src/ChangeLog b/src/ChangeLog index d328cfc..37aadb6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,18 @@ 2005-04-15 Kenichi Handa + * draw.c: Include mtext.h. + (linebreak_table, M_break_at_space, M_break_at_word) + (M_break_at_any, M_kinsoku_bol, M_kinsoku_eol): New variables. + (compose_glyph_string): Check POS before getting Mface text + property. + (truncate_gstring): Give correct TO arg to line_break function. + (GET_LB_TYPE): New macro. + (find_break_backward, find_break_forward): New functions. + (mdraw__init): Initialize the above new variables. + (mdraw__fini): Free linebreak_table. + (mdraw_default_line_break): Use find_break_backward and + find_break_forward. + * word-thai.c: New file. * word-thai.h: New file.