mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-25 23:10:47 -08:00
(set_cursor_from_row): Pay attention to string display properties.
This commit is contained in:
parent
8a2d8020c1
commit
ae73dc1c66
1 changed files with 61 additions and 3 deletions
64
src/xdisp.c
64
src/xdisp.c
|
|
@ -9460,6 +9460,14 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
|
|||
{
|
||||
struct glyph *glyph = row->glyphs[TEXT_AREA];
|
||||
struct glyph *end = glyph + row->used[TEXT_AREA];
|
||||
/* The first glyph that starts a sequence of glyphs from string. */
|
||||
struct glyph *string_start;
|
||||
/* The X coordinate of string_start. */
|
||||
int string_start_x;
|
||||
/* The last known character position. */
|
||||
int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
|
||||
/* The last known character position before string_start. */
|
||||
int string_before_pos;
|
||||
int x = row->x;
|
||||
int pt_old = PT - delta;
|
||||
|
||||
|
|
@ -9475,13 +9483,63 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
|
|||
++glyph;
|
||||
}
|
||||
|
||||
string_start = NULL;
|
||||
while (glyph < end
|
||||
&& !INTEGERP (glyph->object)
|
||||
&& (!BUFFERP (glyph->object)
|
||||
|| glyph->charpos < pt_old))
|
||||
|| (last_pos = glyph->charpos) < pt_old))
|
||||
{
|
||||
x += glyph->pixel_width;
|
||||
++glyph;
|
||||
if (! STRINGP (glyph->object))
|
||||
{
|
||||
string_start = NULL;
|
||||
x += glyph->pixel_width;
|
||||
++glyph;
|
||||
}
|
||||
else
|
||||
{
|
||||
string_before_pos = last_pos;
|
||||
string_start = glyph;
|
||||
string_start_x = x;
|
||||
/* Skip all glyphs from string. */
|
||||
do
|
||||
{
|
||||
x += glyph->pixel_width;
|
||||
++glyph;
|
||||
}
|
||||
while (glyph < end && STRINGP (glyph->object));
|
||||
}
|
||||
}
|
||||
|
||||
if (string_start
|
||||
&& (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
|
||||
{
|
||||
/* We may have skipped over point because the previous glyphs
|
||||
are from string. As there's no easy way to know the
|
||||
character position of the current glyph, find the correct
|
||||
glyph on point by scanning from string_start again. */
|
||||
Lisp_Object pos, limit;
|
||||
|
||||
limit = make_number (MATRIX_ROW_END_CHARPOS (row) + delta);
|
||||
glyph = string_start;
|
||||
x = string_start_x;
|
||||
pos = make_number (string_buffer_position (w, glyph->object,
|
||||
string_before_pos));
|
||||
pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit);
|
||||
while (XINT (pos) <= pt_old)
|
||||
{
|
||||
/* Skip glyphs from the same string. */
|
||||
do
|
||||
{
|
||||
x += glyph->pixel_width;
|
||||
++glyph;
|
||||
}
|
||||
while (glyph < end
|
||||
&& EQ (glyph->object, string_start->object));
|
||||
if (glyph == end || !STRINGP (glyph->object))
|
||||
break;
|
||||
string_start = glyph;
|
||||
pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit);
|
||||
}
|
||||
}
|
||||
|
||||
w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue