Commit f845b8b2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent 937054f3
...@@ -68,6 +68,7 @@ buffer_display_table () ...@@ -68,6 +68,7 @@ buffer_display_table ()
/* Width run cache considerations. */ /* Width run cache considerations. */
/* Return the width of character C under display table DP. */ /* Return the width of character C under display table DP. */
static int static int
character_width (c, dp) character_width (c, dp)
int c; int c;
...@@ -78,18 +79,16 @@ character_width (c, dp) ...@@ -78,18 +79,16 @@ character_width (c, dp)
/* These width computations were determined by examining the cases /* These width computations were determined by examining the cases
in display_text_line. */ in display_text_line. */
/* Some characters are never handled by the display table. */ /* Everything can be handled by the display table, if it's
if (c == '\n' || c == '\t' || c == '\015')
return 0;
/* Everything else might be handled by the display table, if it's
present and the element is right. */ present and the element is right. */
else if (dp && (elt = DISP_CHAR_VECTOR (dp, c), if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt)))
VECTORP (elt)))
return XVECTOR (elt)->size; return XVECTOR (elt)->size;
/* In the absence of display table perversities, printing characters /* Some characters are special. */
have width 1. */ if (c == '\n' || c == '\t' || c == '\015')
return 0;
/* Printing characters have width 1. */
else if (c >= 040 && c < 0177) else if (c >= 040 && c < 0177)
return 1; return 1;
...@@ -241,11 +240,10 @@ current_column () ...@@ -241,11 +240,10 @@ current_column ()
} }
c = *--ptr; c = *--ptr;
if (c >= 040 && c < 0177 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
&& (dp == 0 || !VECTORP (DISP_CHAR_VECTOR (dp, c)))) col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
{ else if (c >= 040 && c < 0177)
col++; col++;
}
else if (c == '\n') else if (c == '\n')
break; break;
else if (c == '\r' && EQ (current_buffer->selective_display, Qt)) else if (c == '\r' && EQ (current_buffer->selective_display, Qt))
...@@ -259,8 +257,6 @@ current_column () ...@@ -259,8 +257,6 @@ current_column ()
col = 0; col = 0;
tab_seen = 1; tab_seen = 1;
} }
else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
else else
col += (ctl_arrow && c < 0200) ? 2 : 4; col += (ctl_arrow && c < 0200) ? 2 : 4;
} }
...@@ -436,6 +432,12 @@ and if COLUMN is in the middle of a tab character, change it to spaces.") ...@@ -436,6 +432,12 @@ and if COLUMN is in the middle of a tab character, change it to spaces.")
while (col < goal && pos < end) while (col < goal && pos < end)
{ {
c = FETCH_CHAR (pos); c = FETCH_CHAR (pos);
if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
{
col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
pos++;
break;
}
if (c == '\n') if (c == '\n')
break; break;
if (c == '\r' && EQ (current_buffer->selective_display, Qt)) 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,8 +449,6 @@ and if COLUMN is in the middle of a tab character, change it to spaces.")
col += tab_width; col += tab_width;
col = col / tab_width * tab_width; col = col / tab_width * tab_width;
} }
else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
else if (ctl_arrow && (c < 040 || c == 0177)) else if (ctl_arrow && (c < 040 || c == 0177))
col += 2; col += 2;
else if (c < 040 || c >= 0177) else if (c < 040 || c >= 0177)
...@@ -631,23 +631,30 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -631,23 +631,30 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
{ {
Lisp_Object end, limit, proplimit; Lisp_Object end, limit, proplimit;
/* Get a quit lower bound for how soon property might change. */ /* We must not advance farther than the next overlay change.
The overlay change might change the invisible property;
we have no way of telling. */
limit = Fnext_overlay_change (position); limit = Fnext_overlay_change (position);
/* As for text properties, this gives a lower bound
for where the invisible text property could change. */
proplimit = Fnext_property_change (position, buffer, Qt); proplimit = Fnext_property_change (position, buffer, Qt);
if (XFASTINT (proplimit) < XFASTINT (limit)) if (XFASTINT (limit) < XFASTINT (proplimit))
limit = proplimit; proplimit = limit;
/* LIMIT is now a lower bound for the next change /* PROPLIMIT is now a lower bound for the next change
in invisible status. If that is plenty far away, in invisible status. If that is plenty far away,
use that lower bound. */ use that lower bound. */
if (XFASTINT (limit) > pos + 100 || XFASTINT (limit) >= to) if (XFASTINT (proplimit) > pos + 100 || XFASTINT (proplimit) >= to)
next_invisible = XINT (limit); next_invisible = XINT (proplimit);
/* Otherwise, scan for the next `invisible' property change. */ /* Otherwise, scan for the next `invisible' property change. */
else else
{ {
/* Don't scan terribly far. */ /* Don't scan terribly far. */
XSETFASTINT (limit, min (pos + 100, to)); XSETFASTINT (proplimit, min (pos + 100, to));
/* No matter what. don't go past next overlay change. */
if (XFASTINT (limit) < XFASTINT (proplimit))
proplimit = limit;
end = Fnext_single_property_change (position, Qinvisible, end = Fnext_single_property_change (position, Qinvisible,
buffer, limit); buffer, proplimit);
if (INTEGERP (end) && XINT (end) < to) if (INTEGERP (end) && XINT (end) < to)
next_invisible = XINT (end); next_invisible = XINT (end);
else else
...@@ -743,8 +750,9 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -743,8 +750,9 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
} }
} }
if (c >= 040 && c < 0177 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
&& (dp == 0 || ! VECTORP (DISP_CHAR_VECTOR (dp, c)))) hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
else if (c >= 040 && c < 0177)
hpos++; hpos++;
else if (c == '\t') else if (c == '\t')
{ {
...@@ -802,8 +810,6 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -802,8 +810,6 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
hpos = width; hpos = width;
} }
} }
else if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
else else
hpos += (ctl_arrow && c < 0200) ? 2 : 4; hpos += (ctl_arrow && c < 0200) ? 2 : 4;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment