diff options
| author | Richard M. Stallman | 1995-03-16 18:51:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-03-16 18:51:49 +0000 |
| commit | f845b8b224e08e8e0e414a2a88547dcaaa731b72 (patch) | |
| tree | f5e4b30a447054a8c9ac90d0027adbb8a64b17fd /src | |
| parent | 937054f3bd6dd1af3fb14a5552c92d99d5d6949e (diff) | |
| download | emacs-f845b8b224e08e8e0e414a2a88547dcaaa731b72.tar.gz emacs-f845b8b224e08e8e0e414a2a88547dcaaa731b72.zip | |
(compute_motion, Fmove_to_column, current_column)
(character_width): Let display table handle \n, \r, \t.
(compute_motion): Fix logic in previous change regarding skipping invisible.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/src/indent.c b/src/indent.c index 520825c375e..ef30c10aaad 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -68,6 +68,7 @@ buffer_display_table () | |||
| 68 | /* Width run cache considerations. */ | 68 | /* Width run cache considerations. */ |
| 69 | 69 | ||
| 70 | /* Return the width of character C under display table DP. */ | 70 | /* Return the width of character C under display table DP. */ |
| 71 | |||
| 71 | static int | 72 | static int |
| 72 | character_width (c, dp) | 73 | character_width (c, dp) |
| 73 | int c; | 74 | int c; |
| @@ -78,18 +79,16 @@ character_width (c, dp) | |||
| 78 | /* These width computations were determined by examining the cases | 79 | /* These width computations were determined by examining the cases |
| 79 | in display_text_line. */ | 80 | in display_text_line. */ |
| 80 | 81 | ||
| 81 | /* Some characters are never handled by the display table. */ | 82 | /* Everything can be handled by the display table, if it's |
| 82 | if (c == '\n' || c == '\t' || c == '\015') | ||
| 83 | return 0; | ||
| 84 | |||
| 85 | /* Everything else might be handled by the display table, if it's | ||
| 86 | present and the element is right. */ | 83 | present and the element is right. */ |
| 87 | else if (dp && (elt = DISP_CHAR_VECTOR (dp, c), | 84 | if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt))) |
| 88 | VECTORP (elt))) | ||
| 89 | return XVECTOR (elt)->size; | 85 | return XVECTOR (elt)->size; |
| 90 | 86 | ||
| 91 | /* In the absence of display table perversities, printing characters | 87 | /* Some characters are special. */ |
| 92 | have width 1. */ | 88 | if (c == '\n' || c == '\t' || c == '\015') |
| 89 | return 0; | ||
| 90 | |||
| 91 | /* Printing characters have width 1. */ | ||
| 93 | else if (c >= 040 && c < 0177) | 92 | else if (c >= 040 && c < 0177) |
| 94 | return 1; | 93 | return 1; |
| 95 | 94 | ||
| @@ -241,11 +240,10 @@ current_column () | |||
| 241 | } | 240 | } |
| 242 | 241 | ||
| 243 | c = *--ptr; | 242 | c = *--ptr; |
| 244 | if (c >= 040 && c < 0177 | 243 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 245 | && (dp == 0 || !VECTORP (DISP_CHAR_VECTOR (dp, c)))) | 244 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
| 246 | { | 245 | else if (c >= 040 && c < 0177) |
| 247 | col++; | 246 | col++; |
| 248 | } | ||
| 249 | else if (c == '\n') | 247 | else if (c == '\n') |
| 250 | break; | 248 | break; |
| 251 | else if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | 249 | else if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
| @@ -259,8 +257,6 @@ current_column () | |||
| 259 | col = 0; | 257 | col = 0; |
| 260 | tab_seen = 1; | 258 | tab_seen = 1; |
| 261 | } | 259 | } |
| 262 | else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | ||
| 263 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | ||
| 264 | else | 260 | else |
| 265 | col += (ctl_arrow && c < 0200) ? 2 : 4; | 261 | col += (ctl_arrow && c < 0200) ? 2 : 4; |
| 266 | } | 262 | } |
| @@ -436,6 +432,12 @@ and if COLUMN is in the middle of a tab character, change it to spaces.") | |||
| 436 | while (col < goal && pos < end) | 432 | while (col < goal && pos < end) |
| 437 | { | 433 | { |
| 438 | c = FETCH_CHAR (pos); | 434 | c = FETCH_CHAR (pos); |
| 435 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | ||
| 436 | { | ||
| 437 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | ||
| 438 | pos++; | ||
| 439 | break; | ||
| 440 | } | ||
| 439 | if (c == '\n') | 441 | if (c == '\n') |
| 440 | break; | 442 | break; |
| 441 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | 443 | if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
| @@ -447,8 +449,6 @@ and if COLUMN is in the middle of a tab character, change it to spaces.") | |||
| 447 | col += tab_width; | 449 | col += tab_width; |
| 448 | col = col / tab_width * tab_width; | 450 | col = col / tab_width * tab_width; |
| 449 | } | 451 | } |
| 450 | else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | ||
| 451 | col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | ||
| 452 | else if (ctl_arrow && (c < 040 || c == 0177)) | 452 | else if (ctl_arrow && (c < 040 || c == 0177)) |
| 453 | col += 2; | 453 | col += 2; |
| 454 | else if (c < 040 || c >= 0177) | 454 | else if (c < 040 || c >= 0177) |
| @@ -631,23 +631,30 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta | |||
| 631 | { | 631 | { |
| 632 | Lisp_Object end, limit, proplimit; | 632 | Lisp_Object end, limit, proplimit; |
| 633 | 633 | ||
| 634 | /* Get a quit lower bound for how soon property might change. */ | 634 | /* We must not advance farther than the next overlay change. |
| 635 | The overlay change might change the invisible property; | ||
| 636 | we have no way of telling. */ | ||
| 635 | limit = Fnext_overlay_change (position); | 637 | limit = Fnext_overlay_change (position); |
| 638 | /* As for text properties, this gives a lower bound | ||
| 639 | for where the invisible text property could change. */ | ||
| 636 | proplimit = Fnext_property_change (position, buffer, Qt); | 640 | proplimit = Fnext_property_change (position, buffer, Qt); |
| 637 | if (XFASTINT (proplimit) < XFASTINT (limit)) | 641 | if (XFASTINT (limit) < XFASTINT (proplimit)) |
| 638 | limit = proplimit; | 642 | proplimit = limit; |
| 639 | /* LIMIT is now a lower bound for the next change | 643 | /* PROPLIMIT is now a lower bound for the next change |
| 640 | in invisible status. If that is plenty far away, | 644 | in invisible status. If that is plenty far away, |
| 641 | use that lower bound. */ | 645 | use that lower bound. */ |
| 642 | if (XFASTINT (limit) > pos + 100 || XFASTINT (limit) >= to) | 646 | if (XFASTINT (proplimit) > pos + 100 || XFASTINT (proplimit) >= to) |
| 643 | next_invisible = XINT (limit); | 647 | next_invisible = XINT (proplimit); |
| 644 | /* Otherwise, scan for the next `invisible' property change. */ | 648 | /* Otherwise, scan for the next `invisible' property change. */ |
| 645 | else | 649 | else |
| 646 | { | 650 | { |
| 647 | /* Don't scan terribly far. */ | 651 | /* Don't scan terribly far. */ |
| 648 | XSETFASTINT (limit, min (pos + 100, to)); | 652 | XSETFASTINT (proplimit, min (pos + 100, to)); |
| 653 | /* No matter what. don't go past next overlay change. */ | ||
| 654 | if (XFASTINT (limit) < XFASTINT (proplimit)) | ||
| 655 | proplimit = limit; | ||
| 649 | end = Fnext_single_property_change (position, Qinvisible, | 656 | end = Fnext_single_property_change (position, Qinvisible, |
| 650 | buffer, limit); | 657 | buffer, proplimit); |
| 651 | if (INTEGERP (end) && XINT (end) < to) | 658 | if (INTEGERP (end) && XINT (end) < to) |
| 652 | next_invisible = XINT (end); | 659 | next_invisible = XINT (end); |
| 653 | else | 660 | else |
| @@ -743,8 +750,9 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta | |||
| 743 | } | 750 | } |
| 744 | } | 751 | } |
| 745 | 752 | ||
| 746 | if (c >= 040 && c < 0177 | 753 | if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 747 | && (dp == 0 || ! VECTORP (DISP_CHAR_VECTOR (dp, c)))) | 754 | hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
| 755 | else if (c >= 040 && c < 0177) | ||
| 748 | hpos++; | 756 | hpos++; |
| 749 | else if (c == '\t') | 757 | else if (c == '\t') |
| 750 | { | 758 | { |
| @@ -802,8 +810,6 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta | |||
| 802 | hpos = width; | 810 | hpos = width; |
| 803 | } | 811 | } |
| 804 | } | 812 | } |
| 805 | else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) | ||
| 806 | hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; | ||
| 807 | else | 813 | else |
| 808 | hpos += (ctl_arrow && c < 0200) ? 2 : 4; | 814 | hpos += (ctl_arrow && c < 0200) ? 2 : 4; |
| 809 | } | 815 | } |