From: handa Date: Thu, 1 Sep 2005 01:26:17 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-1-3-0~218 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29d7a4adc198a0aceee84fe0340797d36aba7a09;p=m17n%2Fm17n-lib.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 4115af1..067b8bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2005-08-22 Kenichi Handa +2005-09-01 Kenichi Handa * configure.ac (CONFIG_FLAGS): Setup this variable and AC_SUBST it. diff --git a/README b/README index 86aa58a..b8cebf0 100644 --- a/README +++ b/README @@ -8,6 +8,7 @@ See the end for copying conditions. The m17n library is a multilingual text processing library for the C language. + (1) INSTALLATION (1-1) From CVS working directory. @@ -35,16 +36,17 @@ will find out the existence of them automatically. xft -- http://freedesktop.org/Software/Xft gd -- http://www.boutell.com/gd/http/gd-1.8.4.tar.gz +In addition, for finding a word boundary in Thai text, "configure" +checks the existence of these libraries (libthai is preferred): + + libthai -- http:// + wordcut -- http://thaiwordseg.sourceforge.net/ + The sample program m17n-edit utilizes this Japanese inputting system. It is also recommended to install it. anthy -- http://anthy.sourceforge.jp/ -The sample program m17n-edit and mdump utilize this Thai word-boundary -finder. It is also recommended to install it. - - wordcut -- http://thaiwordseg.sourceforge.net/ - Then, type the followings on the command line. % ./configure @@ -104,6 +106,7 @@ Actually, the documentation was generated by Doxygen using comments in the source files. There are English and Japanese comments in parallel. + (4) USAGE The library provides three levels of APIs, CORE, SHELL, and GUI. For @@ -121,6 +124,7 @@ This compiles PROX.c that uses GUI API and builds executable PROX. % gcc -o PROX `m17n-config GUI --cflags` `m17n-config GUI --libs` PROX.c + ---------------------------------------------------------------------- Copyright information diff --git a/src/ChangeLog b/src/ChangeLog index 89697aa..8464c13 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,25 @@ +2005-09-01 Kenichi Handa + + * textprop.h (mtext__adjust_plist_for_change): Prototype adjusted. + + * m17n-core.h (mtext_insert, mtext_replace): Extern them. + + * textprop.c (prepare_to_modify): New arg deleting. Callers changed. + (mtext__adjust_plist_for_change): Argument changed. Callers changed. + + * internal.h (enum MTextCoverage): New enum. + (MText): New member coverage. + + * mtext.c (FORMAT_COVERAGE): New macro. + (insert): Copy mt2->coverage. + (mtext__from_data): Initialize mt->coverage. + (mtext__adjust_format): Update mt->coverage. + (mtext): Initialize mt->coverage. + (mtext_set_char): Adjust args to mtext__adjust_plist_for_change. + Update mt->coverage if necessary. + (mtext_duplicate): Copy mt->coverage. + (mtext_insert, mtext_replace): New functions. + 2005-08-25 Kenichi Handa * font.h (MFont): New member for_full_width. diff --git a/src/textprop.c b/src/textprop.c index 30ca56a..3d84043 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -512,7 +512,7 @@ adjust_intervals (MInterval *head, MInterval *tail, int diff) if (diff < 0) { - /* Adjust end poistions of properties starting before HEAD. */ + /* Adjust end positions of properties starting before HEAD. */ for (i = 0; i < head->nprops; i++) { prop = head->stack[i]; @@ -1021,20 +1021,19 @@ pop_all_properties (MTextPlist *plist, int from, int to) } -/* Delete volatile text properties between FROM and TO. If KEY is - Mnil, we are going to delete text, thus both strongly and weakly - volatile properties must be deleted. Otherwise we are going to - modify a text property KEY, thus only strongly volatile properties - whose key is not KEY must be deleted. */ +/* Delete volatile text properties between FROM and TO. If DELETING + is nonzero, we are going to delete text, thus both strongly and + weakly volatile properties must be deleted. Otherwise we are going + to modify a text property KEY, thus only strongly volatile + properties whose key is not KEY must be deleted. */ static void -prepare_to_modify (MText *mt, int from, int to, MSymbol key) +prepare_to_modify (MText *mt, int from, int to, MSymbol key, int deleting) { MTextPlist *plist = mt->plist, *prev = NULL; int mask_bits = MTEXTPROP_VOLATILE_STRONG; - int deleting = (key == Mnil) && (from < to); - if (key == Mnil) + if (deleting) mask_bits |= MTEXTPROP_VOLATILE_WEAK; while (plist) { @@ -1259,7 +1258,7 @@ mtext__adjust_plist_for_delete (MText *mt, int pos, int len) } to = pos + len; - prepare_to_modify (mt, pos, to, Mnil); + prepare_to_modify (mt, pos, to, Mnil, 1); for (plist = mt->plist; plist; plist = plist->next) { MInterval *interval = pop_all_properties (plist, pos, to); @@ -1299,7 +1298,7 @@ mtext__adjust_plist_for_insert (MText *mt, int pos, int nchars, return; } if (pos > 0 && pos < mtext_nchars (mt)) - prepare_to_modify (mt, pos, pos, Mnil); + prepare_to_modify (mt, pos, pos, Mnil, 0); for (pl_last = NULL, pl = mt->plist; pl; pl_last = pl, pl = pl->next) { @@ -1428,16 +1427,49 @@ mtext__adjust_plist_for_insert (MText *mt, int pos, int nchars, } } +/* len1 > 0 && len2 > 0 */ + void -mtext__adjust_plist_for_change (MText *mt, int from, int to) +mtext__adjust_plist_for_change (MText *mt, int pos, int len1, int len2) { - MTextPlist *plist; + int pos2 = pos + len1; - prepare_to_modify (mt, from, to, Mnil); - for (plist = mt->plist; plist; plist = plist->next) + prepare_to_modify (mt, pos, pos2, Mnil, 0); + + if (len1 < len2) { - pop_all_properties (plist, from, to); - xassert (check_plist (plist, 0) == 0); + int diff = len2 - len1; + MTextPlist *plist; + + for (plist = mt->plist; plist; plist = plist->next) + { + MInterval *head = find_interval (plist, pos2); + MInterval *tail = mt->plist->tail; + MTextProperty *prop; + int i; + + if (head->start == pos2) + head = head->prev; + while (tail != head) + { + for (i = 0; i < tail->nprops; i++) + { + prop = tail->stack[i]; + if (prop->start == tail->start) + prop->start += diff, prop->end += diff; + } + tail->start += diff; + tail->end += diff; + tail = tail->prev; + } + for (i = 0; i < tail->nprops; i++) + tail->stack[i]->end += diff; + tail->end += diff; + } + } + else if (len1 > len2) + { + mtext__adjust_plist_for_delete (mt, pos + len2, len1 - len2); } } @@ -1746,7 +1778,7 @@ mtext_put_prop (MText *mt, int from, int to, MSymbol key, void *val) M_CHECK_RANGE (mt, from, to, -1, 0); - prepare_to_modify (mt, from, to, key); + prepare_to_modify (mt, from, to, key, 0); plist = get_plist_create (mt, key, 1); interval = pop_all_properties (plist, from, to); prop = new_text_property (mt, from, to, key, val, 0); @@ -1807,7 +1839,7 @@ mtext_put_prop_values (MText *mt, int from, int to, M_CHECK_RANGE (mt, from, to, -1, 0); - prepare_to_modify (mt, from, to, key); + prepare_to_modify (mt, from, to, key, 0); plist = get_plist_create (mt, key, 1); interval = pop_all_properties (plist, from, to); if (num > 0) @@ -1905,7 +1937,7 @@ mtext_push_prop (MText *mt, int from, int to, M_CHECK_RANGE (mt, from, to, -1, 0); - prepare_to_modify (mt, from, to, key); + prepare_to_modify (mt, from, to, key, 0); plist = get_plist_create (mt, key, 1); /* Find an interval that covers the position FROM. */ @@ -2070,7 +2102,7 @@ mtext_pop_prop (MText *mt, int from, int to, MSymbol key) /* No property to pop. */ return 0; - prepare_to_modify (mt, from, to, key); + prepare_to_modify (mt, from, to, key, 0); /* If the found interval starts before FROM and has value(s), divide it at FROM. */ @@ -2514,7 +2546,7 @@ mtext_attach_property (MText *mt, int from, int to, MTextProperty *prop) M17N_OBJECT_REF (prop); if (prop->mt) mtext_detach_property (prop); - prepare_to_modify (mt, from, to, prop->key); + prepare_to_modify (mt, from, to, prop->key, 0); plist = get_plist_create (mt, prop->key, 1); xassert (check_plist (plist, 0) == 0); interval = pop_all_properties (plist, from, to); @@ -2558,7 +2590,7 @@ mtext_detach_property (MTextProperty *prop) if (! prop->mt) return 0; - prepare_to_modify (prop->mt, start, end, prop->key); + prepare_to_modify (prop->mt, start, end, prop->key, 0); plist = get_plist_create (prop->mt, prop->key, 0); xassert (plist); detach_property (plist, prop, NULL); @@ -2601,7 +2633,7 @@ mtext_push_property (MText *mt, int from, int to, MTextProperty *prop) M17N_OBJECT_REF (prop); if (prop->mt) mtext_detach_property (prop); - prepare_to_modify (mt, from, to, prop->key); + prepare_to_modify (mt, from, to, prop->key, 0); plist = get_plist_create (mt, prop->key, 1); prop->mt = mt; prop->start = from;