comparison src/composite.c @ 110004:4cb81410d95d

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Wed, 25 Aug 2010 22:44:39 +0000
parents 26e31bcc4b06
children dd01a03cf509
comparison
equal deleted inserted replaced
110003:336e4a38a76d 110004:4cb81410d95d
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)
1088 cmp_it->stop_pos = charpos - 1 - cmp_it->lookback; 1077 cmp_it->stop_pos = charpos - 1 - cmp_it->lookback;
1089 cmp_it->ch = c; 1078 cmp_it->ch = c;
1090 return; 1079 return;
1091 } 1080 }
1092 } 1081 }
1082 }
1083 if (charpos == endpos)
1084 {
1085 /* We couldn't find a composition point before ENDPOS. But,
1086 some character after ENDPOS may be composed with
1087 characters before ENDPOS. So, we should stop at the safe
1088 point. */
1089 charpos = endpos - MAX_AUTO_COMPOSITION_LOOKBACK;
1090 if (charpos < start)
1091 charpos = start;
1093 } 1092 }
1094 } 1093 }
1095 else if (charpos > endpos) 1094 else if (charpos > endpos)
1096 { 1095 {
1097 /* Search backward for a pattern that may be composed and the 1096 /* Search backward for a pattern that may be composed and the
1221 CMP_IT->stop_pos, and return 0. */ 1220 CMP_IT->stop_pos, and return 0. */
1222 1221
1223 int 1222 int
1224 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)
1225 { 1224 {
1226 if (endpos <= charpos) 1225 if (endpos < 0)
1227 { 1226 endpos = NILP (string) ? BEGV : 0;
1228 if (NILP (string))
1229 {
1230 if (endpos < 0)
1231 endpos = BEGV;
1232 if (endpos < PT && PT < charpos)
1233 endpos = PT;
1234 }
1235 else if (endpos < 0)
1236 endpos = 0;
1237 }
1238 else
1239 {
1240 if (NILP (string) && charpos < PT && PT < endpos)
1241 endpos = PT;
1242 }
1243 1227
1244 if (cmp_it->ch == -2) 1228 if (cmp_it->ch == -2)
1245 { 1229 {
1246 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); 1230 composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string);
1247 if (cmp_it->ch == -2 || cmp_it->stop_pos != charpos) 1231 if (cmp_it->ch == -2 || cmp_it->stop_pos != charpos)
1299 while (1) 1283 while (1)
1300 { 1284 {
1301 elt = XCAR (val); 1285 elt = XCAR (val);
1302 if (cmp_it->lookback > 0) 1286 if (cmp_it->lookback > 0)
1303 { 1287 {
1304 cpos -= cmp_it->lookback; 1288 cpos = charpos - cmp_it->lookback;
1305 if (STRINGP (string)) 1289 if (STRINGP (string))
1306 bpos = string_char_to_byte (string, cpos); 1290 bpos = string_char_to_byte (string, cpos);
1307 else 1291 else
1308 bpos = CHAR_TO_BYTE (cpos); 1292 bpos = CHAR_TO_BYTE (cpos);
1309 } 1293 }
1761 Lisp_Object gstring, header; 1745 Lisp_Object gstring, header;
1762 EMACS_INT frompos, topos; 1746 EMACS_INT frompos, topos;
1763 1747
1764 CHECK_NATNUM (from); 1748 CHECK_NATNUM (from);
1765 CHECK_NATNUM (to); 1749 CHECK_NATNUM (to);
1766 if (XINT (to) > XINT (from) + MAX_COMPOSITION_COMPONENTS)
1767 to = make_number (XINT (from) + MAX_COMPOSITION_COMPONENTS);
1768 if (! FONT_OBJECT_P (font_object)) 1750 if (! FONT_OBJECT_P (font_object))
1769 { 1751 {
1770 struct coding_system *coding; 1752 struct coding_system *coding;
1771 struct terminal *terminal = get_terminal (font_object, 1); 1753 struct terminal *terminal = get_terminal (font_object, 1);
1772 1754