diff options
| author | Kenichi Handa | 1999-12-15 00:13:13 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1999-12-15 00:13:13 +0000 |
| commit | 012fd715d2a20095a693df3f8cb3fadb5e0ece16 (patch) | |
| tree | 82e29b12f9f75300a87b8707427f039e8b341367 /src | |
| parent | 810abb8758c265759cbb194d9a34bd54dec63890 (diff) | |
| download | emacs-012fd715d2a20095a693df3f8cb3fadb5e0ece16.tar.gz emacs-012fd715d2a20095a693df3f8cb3fadb5e0ece16.zip | |
(check_composition): New function.
(MULTIBYTE_BYTES_WIDTH): Call STRING_CHAR_AND_LENGTH with
MAX_MULTIBYTE_LENGTH, not MAX_LENGTH_OF_MULTI_BYTE_FORM.
(current_column_1): Handle new way of composition.
(Fmove_to_column): Likewise.
(compute_motion): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 101 |
1 files changed, 84 insertions, 17 deletions
diff --git a/src/indent.c b/src/indent.c index af5b689b5b5..913b7633469 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -266,6 +266,31 @@ skip_invisible (pos, next_boundary_p, to, window) | |||
| 266 | return pos; | 266 | return pos; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | /* If a composition starts at POS/POS_BYTE and it doesn't stride over | ||
| 270 | POINT, set *LEN/*LEN_BYTE to the character and byte lengths, *WIDTH | ||
| 271 | to the width, and return 1. Otherwise, return 0. */ | ||
| 272 | |||
| 273 | static int | ||
| 274 | check_composition (pos, pos_byte, point, len, len_byte, width) | ||
| 275 | int pos, pos_byte, point; | ||
| 276 | int *len, *len_byte, *width; | ||
| 277 | { | ||
| 278 | Lisp_Object prop; | ||
| 279 | int start, end; | ||
| 280 | int id; | ||
| 281 | |||
| 282 | if (! find_composition (pos, -1, &start, &end, &prop, Qnil) | ||
| 283 | || pos != start || point < end) | ||
| 284 | return 0; | ||
| 285 | if ((id = get_composition_id (pos, pos_byte, end - pos, prop, Qnil)) < 0) | ||
| 286 | return 0; | ||
| 287 | |||
| 288 | *len = COMPOSITION_LENGTH (prop); | ||
| 289 | *len_byte = CHAR_TO_BYTE (end) - pos_byte; | ||
| 290 | *width = composition_table[id]->width; | ||
| 291 | return 1; | ||
| 292 | } | ||
| 293 | |||
| 269 | /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. | 294 | /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. |
| 270 | 295 | ||
| 271 | DP is a display table or NULL. | 296 | DP is a display table or NULL. |
| @@ -273,23 +298,23 @@ skip_invisible (pos, next_boundary_p, to, window) | |||
| 273 | This macro is used in current_column_1, Fmove_to_column, and | 298 | This macro is used in current_column_1, Fmove_to_column, and |
| 274 | compute_motion. */ | 299 | compute_motion. */ |
| 275 | 300 | ||
| 276 | #define MULTIBYTE_BYTES_WIDTH(p, dp) \ | 301 | #define MULTIBYTE_BYTES_WIDTH(p, dp) \ |
| 277 | do { \ | 302 | do { \ |
| 278 | int c; \ | 303 | int c; \ |
| 279 | \ | 304 | \ |
| 280 | wide_column = 0; \ | 305 | wide_column = 0; \ |
| 281 | c = STRING_CHAR_AND_LENGTH (p, MAX_LENGTH_OF_MULTI_BYTE_FORM, bytes); \ | 306 | c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, bytes); \ |
| 282 | if (BYTES_BY_CHAR_HEAD (*p) != bytes) \ | 307 | if (BYTES_BY_CHAR_HEAD (*p) != bytes) \ |
| 283 | width = bytes * 4; \ | 308 | width = bytes * 4; \ |
| 284 | else \ | 309 | else \ |
| 285 | { \ | 310 | { \ |
| 286 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) \ | 311 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) \ |
| 287 | width = XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; \ | 312 | width = XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; \ |
| 288 | else \ | 313 | else \ |
| 289 | width = WIDTH_BY_CHAR_HEAD (*p); \ | 314 | width = WIDTH_BY_CHAR_HEAD (*p); \ |
| 290 | if (width > 1) \ | 315 | if (width > 1) \ |
| 291 | wide_column = width; \ | 316 | wide_column = width; \ |
| 292 | } \ | 317 | } \ |
| 293 | } while (0) | 318 | } while (0) |
| 294 | 319 | ||
| 295 | DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, | 320 | DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, |
| @@ -464,6 +489,21 @@ current_column_1 () | |||
| 464 | next_boundary_byte = CHAR_TO_BYTE (next_boundary); | 489 | next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
| 465 | } | 490 | } |
| 466 | 491 | ||
| 492 | /* Check composition sequence. */ | ||
| 493 | { | ||
| 494 | int len, len_byte, width; | ||
| 495 | |||
| 496 | if (check_composition (scan, scan_byte, opoint, | ||
| 497 | &len, &len_byte, &width)) | ||
| 498 | { | ||
| 499 | scan += len; | ||
| 500 | scan_byte += len_byte; | ||
| 501 | if (scan <= opoint) | ||
| 502 | col += width; | ||
| 503 | continue; | ||
| 504 | } | ||
| 505 | } | ||
| 506 | |||
| 467 | c = FETCH_BYTE (scan_byte); | 507 | c = FETCH_BYTE (scan_byte); |
| 468 | if (dp != 0 | 508 | if (dp != 0 |
| 469 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 509 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| @@ -840,6 +880,19 @@ The return value is the current column.") | |||
| 840 | if (col >= goal) | 880 | if (col >= goal) |
| 841 | break; | 881 | break; |
| 842 | 882 | ||
| 883 | /* Check composition sequence. */ | ||
| 884 | { | ||
| 885 | int len, len_byte, width; | ||
| 886 | |||
| 887 | if (check_composition (pos, pos_byte, Z, &len, &len_byte, &width)) | ||
| 888 | { | ||
| 889 | pos += len; | ||
| 890 | pos_byte += len_byte; | ||
| 891 | col += width; | ||
| 892 | continue; | ||
| 893 | } | ||
| 894 | } | ||
| 895 | |||
| 843 | c = FETCH_BYTE (pos_byte); | 896 | c = FETCH_BYTE (pos_byte); |
| 844 | if (dp != 0 | 897 | if (dp != 0 |
| 845 | && ! (multibyte && BASE_LEADING_CODE_P (c)) | 898 | && ! (multibyte && BASE_LEADING_CODE_P (c)) |
| @@ -1321,6 +1374,20 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1321 | else | 1374 | else |
| 1322 | { | 1375 | { |
| 1323 | c = FETCH_BYTE (pos_byte); | 1376 | c = FETCH_BYTE (pos_byte); |
| 1377 | |||
| 1378 | /* Check composition sequence. */ | ||
| 1379 | { | ||
| 1380 | int len, len_byte, width; | ||
| 1381 | |||
| 1382 | if (check_composition (pos, pos_byte, to, &len, &len_byte, &width)) | ||
| 1383 | { | ||
| 1384 | pos += len; | ||
| 1385 | pos_byte += len_byte; | ||
| 1386 | hpos += width; | ||
| 1387 | continue; | ||
| 1388 | } | ||
| 1389 | } | ||
| 1390 | |||
| 1324 | pos++, pos_byte++; | 1391 | pos++, pos_byte++; |
| 1325 | 1392 | ||
| 1326 | /* Perhaps add some info to the width_run_cache. */ | 1393 | /* Perhaps add some info to the width_run_cache. */ |