Commit cde9337b authored by Jim Blandy's avatar Jim Blandy
Browse files

*** empty log message ***

parent 23b0668c
...@@ -408,27 +408,9 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -408,27 +408,9 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
register int width; register int width;
int hscroll, tab_offset; int hscroll, tab_offset;
{ {
/* Note that `cpos' is CURRENT_VPOS << SHORTBITS + CURRENT_HPOS, register int hpos = fromhpos;
and that CURRENT_HPOS may be negative. Use these macros register int vpos = fromvpos;
to extract the hpos or the vpos from cpos or anything like it.
*/
#ifndef SHORT_CAST_BUG
#define HPOS(VAR) (short) (VAR)
#else
#define HPOS(VAR) (((VAR) & (1 << (SHORTBITS - 1)) \
? ~((1 << SHORTBITS) - 1) : 0) \
| (VAR) & ((1 << SHORTBITS) - 1))
/* #define HPOS(VAR) (((VAR) & 0x8000 ? 0xffff0000 : 0) | ((VAR) & 0xffff)) */
#endif /* SHORT_CAST_BUG */
#define VPOS(VAR) (((VAR) >> SHORTBITS) + (HPOS (VAR) < 0))
#ifndef TAHOE_REGISTER_BUG
register
#endif /* TAHOE_REGISTER_BUG */
int cpos = fromhpos + (fromvpos << SHORTBITS);
register int target = tohpos + (tovpos << SHORTBITS);
register int pos; register int pos;
register int c; register int c;
register int tab_width = XFASTINT (current_buffer->tab_width); register int tab_width = XFASTINT (current_buffer->tab_width);
...@@ -438,28 +420,34 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -438,28 +420,34 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
= XTYPE (current_buffer->selective_display) == Lisp_Int = XTYPE (current_buffer->selective_display) == Lisp_Int
? XINT (current_buffer->selective_display) ? XINT (current_buffer->selective_display)
: !NILP (current_buffer->selective_display) ? -1 : 0; : !NILP (current_buffer->selective_display) ? -1 : 0;
int prevpos; int prev_vpos, prev_hpos;
int selective_rlen int selective_rlen
= (selective && dp && XTYPE (DISP_INVIS_ROPE (dp)) == Lisp_String = (selective && dp && XTYPE (DISP_INVIS_ROPE (dp)) == Lisp_String
? XSTRING (DISP_INVIS_ROPE (dp))->size / sizeof (GLYPH) : 0); ? XSTRING (DISP_INVIS_ROPE (dp))->size / sizeof (GLYPH) : 0);
if (tab_width <= 0 || tab_width > 20) tab_width = 8; if (tab_width <= 0 || tab_width > 20) tab_width = 8;
for (pos = from; pos < to && cpos < target; pos++) for (pos = from; pos < to; pos++)
{ {
prevpos = cpos; /* Stop if past the target screen position. */
if (vpos > tovpos
|| (vpos == tovpos && hpos >= tohpos))
break;
prev_vpos = vpos;
prev_hpos = hpos;
c = FETCH_CHAR (pos); c = FETCH_CHAR (pos);
if (c >= 040 && c < 0177 if (c >= 040 && c < 0177
&& (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String)) && (dp == 0 || XTYPE (DISP_CHAR_ROPE (dp, c)) != Lisp_String))
cpos++; hpos++;
else if (c == '\t') else if (c == '\t')
{ {
cpos += tab_width hpos += tab_width - ((hpos + tab_offset + hscroll - (hscroll > 0)
- HPOS (cpos + tab_offset + hscroll - (hscroll > 0) /* Add tab_width here to make sure positive.
/* Add tab_width here to make sure positive. hpos can be negative after continuation
cpos can be negative after continuation but can't be less than -tab_width. */
but can't be less than -tab_width. */ + tab_width)
+ tab_width) % tab_width);
% tab_width;
} }
else if (c == '\n') else if (c == '\n')
{ {
...@@ -468,61 +456,71 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -468,61 +456,71 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
/* Skip any number of invisible lines all at once */ /* Skip any number of invisible lines all at once */
do do
{ {
while (++pos < to && FETCH_CHAR(pos) != '\n'); while (++pos < to && FETCH_CHAR (pos) != '\n');
} }
while (selective > 0 && position_indentation (pos + 1) >= selective); while (selective > 0 && position_indentation (pos + 1) >= selective);
pos--; pos--;
/* Allow for the " ..." that is displayed for them. */ /* Allow for the " ..." that is displayed for them. */
if (selective_rlen) if (selective_rlen)
{ {
cpos += selective_rlen; hpos += selective_rlen;
if (HPOS (cpos) >= width) if (hpos >= width)
cpos -= HPOS (cpos) - width; hpos = width;
} }
} }
else else
cpos += (1 << SHORTBITS) - HPOS (cpos); {
cpos -= hscroll; /* A visible line. */
if (hscroll > 0) cpos++; /* Count the ! on column 0 */ vpos++;
hpos = 0;
}
hpos -= hscroll;
if (hscroll > 0) hpos++; /* Count the ! on column 0 */
tab_offset = 0; tab_offset = 0;
} }
else if (c == CR && selective < 0) else if (c == CR && selective < 0)
{ {
/* In selective display mode, /* In selective display mode,
everything from a ^M to the end of the line is invisible */ everything from a ^M to the end of the line is invisible */
while (pos < to && FETCH_CHAR(pos) != '\n') pos++; while (pos < to && FETCH_CHAR (pos) != '\n') pos++;
/* Stop *before* the real newline. */
pos--; pos--;
/* Allow for the " ..." that is displayed for them. */ /* Allow for the " ..." that is displayed for them. */
if (selective_rlen) if (selective_rlen)
{ {
cpos += selective_rlen; hpos += selective_rlen;
if (HPOS (cpos) >= width) if (hpos >= width)
cpos -= HPOS (cpos) - width; hpos = width;
} }
} }
else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String) else if (dp != 0 && XTYPE (DISP_CHAR_ROPE (dp, c)) == Lisp_String)
cpos += XSTRING (DISP_CHAR_ROPE (dp, c))->size / sizeof (GLYPH); hpos += XSTRING (DISP_CHAR_ROPE (dp, c))->size / sizeof (GLYPH);
else else
cpos += (ctl_arrow && c < 0200) ? 2 : 4; hpos += (ctl_arrow && c < 0200) ? 2 : 4;
if (HPOS (cpos) >= width /* Handle right margin. */
&& (HPOS (cpos) > width if (hpos >= width
|| (pos < (ZV - 1) && (hpos > width
|| (pos < ZV - 1
&& FETCH_CHAR (pos + 1) != '\n'))) && FETCH_CHAR (pos + 1) != '\n')))
{ {
if (cpos >= target) if (vpos > tovpos
|| (vpos == tovpos && hpos >= tohpos))
break; break;
if (hscroll if (hscroll
|| (truncate_partial_width_windows || (truncate_partial_width_windows
&& width + 1 < SCREEN_WIDTH (selected_screen)) && width + 1 < SCREEN_WIDTH (selected_screen))
|| !NILP (current_buffer->truncate_lines)) || !NILP (current_buffer->truncate_lines))
{ {
while (pos < to && FETCH_CHAR(pos) != '\n') pos++; /* Truncating: skip to newline. */
while (pos < to && FETCH_CHAR (pos) != '\n') pos++;
pos--; pos--;
} }
else else
{ {
cpos += (1 << SHORTBITS) - width; /* Continuing. */
vpos++;
hpos -= width;
tab_offset += width; tab_offset += width;
} }
...@@ -530,20 +528,18 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta ...@@ -530,20 +528,18 @@ compute_motion (from, fromvpos, fromhpos, to, tovpos, tohpos, width, hscroll, ta
} }
val_compute_motion.bufpos = pos; val_compute_motion.bufpos = pos;
val_compute_motion.hpos = HPOS (cpos); val_compute_motion.hpos = hpos;
val_compute_motion.vpos = VPOS (cpos); val_compute_motion.vpos = vpos;
val_compute_motion.prevhpos = HPOS (prevpos); val_compute_motion.prevhpos = prev_hpos;
/* Nonzero if have just continued a line */ /* Nonzero if have just continued a line */
val_compute_motion.contin val_compute_motion.contin
= pos != from = (pos != from
&& (val_compute_motion.vpos != VPOS (prevpos)) && (val_compute_motion.vpos != prev_vpos)
&& c != '\n'; && c != '\n');
return &val_compute_motion; return &val_compute_motion;
} }
#undef HPOS
#undef VPOS
/* Return the column of position POS in window W's buffer, /* Return the column of position POS in window W's buffer,
...@@ -608,7 +604,7 @@ vmotion (from, vtarget, width, hscroll, window) ...@@ -608,7 +604,7 @@ vmotion (from, vtarget, width, hscroll, window)
prevline = find_next_newline (prevline - 1, -1); prevline = find_next_newline (prevline - 1, -1);
pos = *compute_motion (prevline, 0, pos = *compute_motion (prevline, 0,
lmargin + (prevline == 1 ? start_hpos : 0), lmargin + (prevline == 1 ? start_hpos : 0),
from, 10000, 10000, from, 1 << (INTBITS - 2), 0,
width, hscroll, 0); width, hscroll, 0);
} }
else else
...@@ -617,7 +613,7 @@ vmotion (from, vtarget, width, hscroll, window) ...@@ -617,7 +613,7 @@ vmotion (from, vtarget, width, hscroll, window)
pos.vpos = 0; pos.vpos = 0;
} }
return compute_motion (from, vpos, pos.hpos, return compute_motion (from, vpos, pos.hpos,
ZV, vtarget, - (1 << (SHORTBITS - 1)), ZV, vtarget, - (1 << (INTBITS - 2)),
width, hscroll, pos.vpos * width); width, hscroll, pos.vpos * width);
} }
...@@ -639,7 +635,7 @@ vmotion (from, vtarget, width, hscroll, window) ...@@ -639,7 +635,7 @@ vmotion (from, vtarget, width, hscroll, window)
} }
pos = *compute_motion (prevline, 0, pos = *compute_motion (prevline, 0,
lmargin + (prevline == 1 ? start_hpos : 0), lmargin + (prevline == 1 ? start_hpos : 0),
from, 10000, 10000, from, 1 << (INTBITS - 2), 0,
width, hscroll, 0); width, hscroll, 0);
vpos -= pos.vpos; vpos -= pos.vpos;
first = 0; first = 0;
......
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