Mercurial > emacs
comparison src/composite.c @ 109976:26e31bcc4b06
Allow composition striding over PT.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 25 Aug 2010 13:39:30 +0900 |
parents | 7a86ccf3260e |
children | dd01a03cf509 |
comparison
equal
deleted
inserted
replaced
109974:19fca2eb1b9f | 109976:26e31bcc4b06 |
---|---|
967 } | 967 } |
968 | 968 |
969 static Lisp_Object _work_val; | 969 static Lisp_Object _work_val; |
970 static int _work_char; | 970 static int _work_char; |
971 | 971 |
972 /* 1 iff the character C is composable. */ | 972 /* 1 iff the character C is composable. Characters of general |
973 category Z? or C? are not composable except for ZWNJ and ZWJ. */ | |
974 | |
973 #define CHAR_COMPOSABLE_P(C) \ | 975 #define CHAR_COMPOSABLE_P(C) \ |
974 ((C) == 0x200C || (C) == 0x200D \ | 976 ((C) == 0x200C || (C) == 0x200D \ |
975 || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ | 977 || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ |
976 (SYMBOLP (_work_val) \ | 978 (SYMBOLP (_work_val) \ |
977 && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \ | 979 && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \ |
1025 && find_composition (charpos, endpos, &start, &end, &prop, string) | 1027 && find_composition (charpos, endpos, &start, &end, &prop, string) |
1026 && COMPOSITION_VALID_P (start, end, prop)) | 1028 && COMPOSITION_VALID_P (start, end, prop)) |
1027 { | 1029 { |
1028 cmp_it->stop_pos = endpos = start; | 1030 cmp_it->stop_pos = endpos = start; |
1029 cmp_it->ch = -1; | 1031 cmp_it->ch = -1; |
1030 } | |
1031 if (NILP (string)) | |
1032 { | |
1033 /* A composition never strides over PT. */ | |
1034 if (PT > charpos) | |
1035 { | |
1036 if (PT < endpos) | |
1037 cmp_it->stop_pos = endpos = PT; | |
1038 } | |
1039 else if (PT < charpos && PT > endpos) | |
1040 { | |
1041 cmp_it->stop_pos = endpos = PT - 1; | |
1042 } | |
1043 } | 1032 } |
1044 if (NILP (current_buffer->enable_multibyte_characters) | 1033 if (NILP (current_buffer->enable_multibyte_characters) |
1045 || NILP (Vauto_composition_mode)) | 1034 || NILP (Vauto_composition_mode)) |
1046 return; | 1035 return; |
1047 if (bytepos < 0) | 1036 if (bytepos < 0) |
1231 CMP_IT->stop_pos, and return 0. */ | 1220 CMP_IT->stop_pos, and return 0. */ |
1232 | 1221 |
1233 int | 1222 int |
1234 composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, struct window *w, struct face *face, Lisp_Object string) | 1223 composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, struct window *w, struct face *face, Lisp_Object string) |
1235 { | 1224 { |
1236 if (endpos <= charpos) | 1225 if (endpos < 0) |
1237 { | 1226 endpos = NILP (string) ? BEGV : 0; |
1238 if (NILP (string)) | |
1239 { | |
1240 if (endpos < 0) | |
1241 endpos = BEGV; | |
1242 if (endpos < PT && PT < charpos) | |
1243 endpos = PT; | |
1244 } | |
1245 else if (endpos < 0) | |
1246 endpos = 0; | |
1247 } | |
1248 else | |
1249 { | |
1250 if (NILP (string) && charpos < PT && PT < endpos) | |
1251 endpos = PT; | |
1252 } | |
1253 | 1227 |
1254 if (cmp_it->ch == -2) | 1228 if (cmp_it->ch == -2) |
1255 { | 1229 { |
1256 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); | 1230 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); |
1257 if (cmp_it->ch == -2 || cmp_it->stop_pos != charpos) | 1231 if (cmp_it->ch == -2 || cmp_it->stop_pos != charpos) |
1309 while (1) | 1283 while (1) |
1310 { | 1284 { |
1311 elt = XCAR (val); | 1285 elt = XCAR (val); |
1312 if (cmp_it->lookback > 0) | 1286 if (cmp_it->lookback > 0) |
1313 { | 1287 { |
1314 cpos -= cmp_it->lookback; | 1288 cpos = charpos - cmp_it->lookback; |
1315 if (STRINGP (string)) | 1289 if (STRINGP (string)) |
1316 bpos = string_char_to_byte (string, cpos); | 1290 bpos = string_char_to_byte (string, cpos); |
1317 else | 1291 else |
1318 bpos = CHAR_TO_BYTE (cpos); | 1292 bpos = CHAR_TO_BYTE (cpos); |
1319 } | 1293 } |
1771 Lisp_Object gstring, header; | 1745 Lisp_Object gstring, header; |
1772 EMACS_INT frompos, topos; | 1746 EMACS_INT frompos, topos; |
1773 | 1747 |
1774 CHECK_NATNUM (from); | 1748 CHECK_NATNUM (from); |
1775 CHECK_NATNUM (to); | 1749 CHECK_NATNUM (to); |
1776 if (XINT (to) > XINT (from) + MAX_COMPOSITION_COMPONENTS) | |
1777 to = make_number (XINT (from) + MAX_COMPOSITION_COMPONENTS); | |
1778 if (! FONT_OBJECT_P (font_object)) | 1750 if (! FONT_OBJECT_P (font_object)) |
1779 { | 1751 { |
1780 struct coding_system *coding; | 1752 struct coding_system *coding; |
1781 struct terminal *terminal = get_terminal (font_object, 1); | 1753 struct terminal *terminal = get_terminal (font_object, 1); |
1782 | 1754 |