diff options
| author | Kenichi Handa | 2008-08-29 07:56:25 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-08-29 07:56:25 +0000 |
| commit | d6721dda7faaaa1bab0a48b271c27151cf8be4b7 (patch) | |
| tree | 99249d59137b1283aeb76874877f9341a8b55637 /src | |
| parent | 89a95b7cf73592fb79175cc0d29dcba54ef4c453 (diff) | |
| download | emacs-d6721dda7faaaa1bab0a48b271c27151cf8be4b7.tar.gz emacs-d6721dda7faaaa1bab0a48b271c27151cf8be4b7.zip | |
Include composite.h and dispextern.h.
(check_composition): Delete this function..
(scan_for_column): Handle composition by
composition_compute_stop_pos, composition_reseat_it, and
composition_update_it.
(compute_motion): Likewise.
(Fvertical_motion): Fix checking of composition.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 114 |
1 files changed, 59 insertions, 55 deletions
diff --git a/src/indent.c b/src/indent.c index d08d4b3c7ca..7bef4949908 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -25,6 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | #include "buffer.h" | 25 | #include "buffer.h" |
| 26 | #include "character.h" | 26 | #include "character.h" |
| 27 | #include "category.h" | 27 | #include "category.h" |
| 28 | #include "composite.h" | ||
| 28 | #include "indent.h" | 29 | #include "indent.h" |
| 29 | #include "keyboard.h" | 30 | #include "keyboard.h" |
| 30 | #include "frame.h" | 31 | #include "frame.h" |
| @@ -33,6 +34,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 33 | #include "termopts.h" | 34 | #include "termopts.h" |
| 34 | #include "disptab.h" | 35 | #include "disptab.h" |
| 35 | #include "intervals.h" | 36 | #include "intervals.h" |
| 37 | #include "dispextern.h" | ||
| 36 | #include "region-cache.h" | 38 | #include "region-cache.h" |
| 37 | 39 | ||
| 38 | /* Indentation can insert tabs if this is non-zero; | 40 | /* Indentation can insert tabs if this is non-zero; |
| @@ -280,32 +282,6 @@ skip_invisible (pos, next_boundary_p, to, window) | |||
| 280 | return pos; | 282 | return pos; |
| 281 | } | 283 | } |
| 282 | 284 | ||
| 283 | /* If a composition starts at POS/POS_BYTE and it doesn't stride over | ||
| 284 | POINT, set *LEN / *LEN_BYTE to the character and byte lengths, *WIDTH | ||
| 285 | to the width, and return 1. Otherwise, return 0. */ | ||
| 286 | |||
| 287 | static int | ||
| 288 | check_composition (pos, pos_byte, point, len, len_byte, width) | ||
| 289 | int pos, pos_byte, point; | ||
| 290 | int *len, *len_byte, *width; | ||
| 291 | { | ||
| 292 | Lisp_Object prop; | ||
| 293 | EMACS_INT start, end; | ||
| 294 | int id; | ||
| 295 | |||
| 296 | if (! find_composition (pos, -1, &start, &end, &prop, Qnil) | ||
| 297 | || pos != start || point < end | ||
| 298 | || !COMPOSITION_VALID_P (start, end, prop)) | ||
| 299 | return 0; | ||
| 300 | if ((id = get_composition_id (pos, pos_byte, end - pos, prop, Qnil)) < 0) | ||
| 301 | return 0; | ||
| 302 | |||
| 303 | *len = COMPOSITION_LENGTH (prop); | ||
| 304 | *len_byte = CHAR_TO_BYTE (end) - pos_byte; | ||
| 305 | *width = composition_table[id]->width; | ||
| 306 | return 1; | ||
| 307 | } | ||
| 308 | |||
| 309 | /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. | 285 | /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. |
| 310 | 286 | ||
| 311 | DP is a display table or NULL. | 287 | DP is a display table or NULL. |
| @@ -556,6 +532,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) | |||
| 556 | register int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 532 | register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
| 557 | register struct Lisp_Char_Table *dp = buffer_display_table (); | 533 | register struct Lisp_Char_Table *dp = buffer_display_table (); |
| 558 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 534 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 535 | struct composition_it cmp_it; | ||
| 559 | 536 | ||
| 560 | /* Start the scan at the beginning of this line with column number 0. */ | 537 | /* Start the scan at the beginning of this line with column number 0. */ |
| 561 | register EMACS_INT col = 0, prev_col = 0; | 538 | register EMACS_INT col = 0, prev_col = 0; |
| @@ -573,6 +550,9 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) | |||
| 573 | } | 550 | } |
| 574 | 551 | ||
| 575 | if (tab_width <= 0 || tab_width > 1000) tab_width = 8; | 552 | if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
| 553 | bzero (&cmp_it, sizeof cmp_it); | ||
| 554 | cmp_it.id = -1; | ||
| 555 | composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil); | ||
| 576 | 556 | ||
| 577 | /* Scan forward to the target position. */ | 557 | /* Scan forward to the target position. */ |
| 578 | while (scan < end) | 558 | while (scan < end) |
| @@ -599,20 +579,6 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) | |||
| 599 | break; | 579 | break; |
| 600 | prev_col = col; | 580 | prev_col = col; |
| 601 | 581 | ||
| 602 | { /* Check composition sequence. */ | ||
| 603 | int len, len_byte, width; | ||
| 604 | |||
| 605 | if (check_composition (scan, scan_byte, end, | ||
| 606 | &len, &len_byte, &width)) | ||
| 607 | { | ||
| 608 | scan += len; | ||
| 609 | scan_byte += len_byte; | ||
| 610 | if (scan <= end) | ||
| 611 | col += width; | ||
| 612 | continue; | ||
| 613 | } | ||
| 614 | } | ||
| 615 | |||
| 616 | { /* Check display property. */ | 582 | { /* Check display property. */ |
| 617 | EMACS_INT end; | 583 | EMACS_INT end; |
| 618 | int width = check_display_width (scan, col, &end); | 584 | int width = check_display_width (scan, col, &end); |
| @@ -627,6 +593,29 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) | |||
| 627 | } | 593 | } |
| 628 | } | 594 | } |
| 629 | 595 | ||
| 596 | /* Check composition sequence. */ | ||
| 597 | if (cmp_it.id >= 0 | ||
| 598 | || (scan == cmp_it.stop_pos | ||
| 599 | && composition_reseat_it (&cmp_it, scan, scan_byte, end, | ||
| 600 | XWINDOW (selected_window), NULL, Qnil))) | ||
| 601 | composition_update_it (&cmp_it, scan, scan_byte, Qnil); | ||
| 602 | if (cmp_it.id >= 0) | ||
| 603 | { | ||
| 604 | scan += cmp_it.nchars; | ||
| 605 | scan_byte += cmp_it.nbytes; | ||
| 606 | if (scan <= end) | ||
| 607 | col += cmp_it.width; | ||
| 608 | if (cmp_it.to == cmp_it.nglyphs) | ||
| 609 | { | ||
| 610 | cmp_it.id = -1; | ||
| 611 | composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, | ||
| 612 | Qnil); | ||
| 613 | } | ||
| 614 | else | ||
| 615 | cmp_it.from = cmp_it.to; | ||
| 616 | continue; | ||
| 617 | } | ||
| 618 | |||
| 630 | c = FETCH_BYTE (scan_byte); | 619 | c = FETCH_BYTE (scan_byte); |
| 631 | 620 | ||
| 632 | /* See if there is a display table and it relates | 621 | /* See if there is a display table and it relates |
| @@ -1195,6 +1184,8 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1195 | EMACS_INT prev_tab_offset; /* Previous tab offset. */ | 1184 | EMACS_INT prev_tab_offset; /* Previous tab offset. */ |
| 1196 | EMACS_INT continuation_glyph_width; | 1185 | EMACS_INT continuation_glyph_width; |
| 1197 | 1186 | ||
| 1187 | struct composition_it cmp_it; | ||
| 1188 | |||
| 1198 | XSETBUFFER (buffer, current_buffer); | 1189 | XSETBUFFER (buffer, current_buffer); |
| 1199 | XSETWINDOW (window, win); | 1190 | XSETWINDOW (window, win); |
| 1200 | 1191 | ||
| @@ -1235,6 +1226,10 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1235 | pos_byte = prev_pos_byte = CHAR_TO_BYTE (from); | 1226 | pos_byte = prev_pos_byte = CHAR_TO_BYTE (from); |
| 1236 | contin_hpos = 0; | 1227 | contin_hpos = 0; |
| 1237 | prev_tab_offset = tab_offset; | 1228 | prev_tab_offset = tab_offset; |
| 1229 | bzero (&cmp_it, sizeof cmp_it); | ||
| 1230 | cmp_it.id = -1; | ||
| 1231 | composition_compute_stop_pos (&cmp_it, pos, pos_byte, to, Qnil); | ||
| 1232 | |||
| 1238 | while (1) | 1233 | while (1) |
| 1239 | { | 1234 | { |
| 1240 | while (pos == next_boundary) | 1235 | while (pos == next_boundary) |
| @@ -1522,21 +1517,29 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1522 | EMACS_INT i, n; | 1517 | EMACS_INT i, n; |
| 1523 | Lisp_Object charvec; | 1518 | Lisp_Object charvec; |
| 1524 | 1519 | ||
| 1525 | c = FETCH_BYTE (pos_byte); | ||
| 1526 | |||
| 1527 | /* Check composition sequence. */ | 1520 | /* Check composition sequence. */ |
| 1528 | { | 1521 | if (cmp_it.id >= 0 |
| 1529 | int len, len_byte, width; | 1522 | || (pos == cmp_it.stop_pos |
| 1530 | 1523 | && composition_reseat_it (&cmp_it, pos, pos_byte, to, win, | |
| 1531 | if (check_composition (pos, pos_byte, to, &len, &len_byte, &width)) | 1524 | NULL, Qnil))) |
| 1532 | { | 1525 | composition_update_it (&cmp_it, pos, pos_byte, Qnil); |
| 1533 | pos += len; | 1526 | if (cmp_it.id >= 0) |
| 1534 | pos_byte += len_byte; | 1527 | { |
| 1535 | hpos += width; | 1528 | pos += cmp_it.nchars; |
| 1536 | continue; | 1529 | pos_byte += cmp_it.nbytes; |
| 1537 | } | 1530 | hpos += cmp_it.width; |
| 1538 | } | 1531 | if (cmp_it.to == cmp_it.nglyphs) |
| 1532 | { | ||
| 1533 | cmp_it.id = -1; | ||
| 1534 | composition_compute_stop_pos (&cmp_it, pos, pos_byte, to, | ||
| 1535 | Qnil); | ||
| 1536 | } | ||
| 1537 | else | ||
| 1538 | cmp_it.from = cmp_it.to; | ||
| 1539 | continue; | ||
| 1540 | } | ||
| 1539 | 1541 | ||
| 1542 | c = FETCH_BYTE (pos_byte); | ||
| 1540 | pos++, pos_byte++; | 1543 | pos++, pos_byte++; |
| 1541 | 1544 | ||
| 1542 | /* Perhaps add some info to the width_run_cache. */ | 1545 | /* Perhaps add some info to the width_run_cache. */ |
| @@ -2065,6 +2068,8 @@ whether or not it is currently displayed in some window. */) | |||
| 2065 | /* See comments below for why we calculate this. */ | 2068 | /* See comments below for why we calculate this. */ |
| 2066 | if (XINT (lines) > 0) | 2069 | if (XINT (lines) > 0) |
| 2067 | { | 2070 | { |
| 2071 | if (it.cmp_it.id >= 0) | ||
| 2072 | it_overshoot_expected = 1; | ||
| 2068 | if (it.method == GET_FROM_STRING) | 2073 | if (it.method == GET_FROM_STRING) |
| 2069 | { | 2074 | { |
| 2070 | const char *s = SDATA (it.string); | 2075 | const char *s = SDATA (it.string); |
| @@ -2075,8 +2080,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2075 | } | 2080 | } |
| 2076 | else | 2081 | else |
| 2077 | it_overshoot_expected = (it.method == GET_FROM_IMAGE | 2082 | it_overshoot_expected = (it.method == GET_FROM_IMAGE |
| 2078 | || it.method == GET_FROM_STRETCH | 2083 | || it.method == GET_FROM_STRETCH); |
| 2079 | || it.method == GET_FROM_COMPOSITION); | ||
| 2080 | } | 2084 | } |
| 2081 | 2085 | ||
| 2082 | /* Scan from the start of the line containing PT. If we don't | 2086 | /* Scan from the start of the line containing PT. If we don't |