Mercurial > emacs
comparison src/xdisp.c @ 56894:8beec197715e
(set_cursor_from_row): Look for non-nil `cursor' property
in overlay or text-property strings; set cursor on corresponding
glyph rather than at end of the string.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Thu, 02 Sep 2004 22:34:07 +0000 |
parents | 10705eddc995 |
children | 8f5fa45d791e |
comparison
equal
deleted
inserted
replaced
56893:b3e23208cc2a | 56894:8beec197715e |
---|---|
304 Lisp_Object Qmargin, Qpointer; | 304 Lisp_Object Qmargin, Qpointer; |
305 Lisp_Object Qline_height, Qtotal; | 305 Lisp_Object Qline_height, Qtotal; |
306 extern Lisp_Object Qheight; | 306 extern Lisp_Object Qheight; |
307 extern Lisp_Object QCwidth, QCheight, QCascent; | 307 extern Lisp_Object QCwidth, QCheight, QCascent; |
308 extern Lisp_Object Qscroll_bar; | 308 extern Lisp_Object Qscroll_bar; |
309 extern Lisp_Object Qcursor; | |
309 | 310 |
310 /* Non-nil means highlight trailing whitespace. */ | 311 /* Non-nil means highlight trailing whitespace. */ |
311 | 312 |
312 Lisp_Object Vshow_trailing_whitespace; | 313 Lisp_Object Vshow_trailing_whitespace; |
313 | 314 |
10645 struct glyph_matrix *matrix; | 10646 struct glyph_matrix *matrix; |
10646 int delta, delta_bytes, dy, dvpos; | 10647 int delta, delta_bytes, dy, dvpos; |
10647 { | 10648 { |
10648 struct glyph *glyph = row->glyphs[TEXT_AREA]; | 10649 struct glyph *glyph = row->glyphs[TEXT_AREA]; |
10649 struct glyph *end = glyph + row->used[TEXT_AREA]; | 10650 struct glyph *end = glyph + row->used[TEXT_AREA]; |
10651 struct glyph *cursor = NULL; | |
10650 /* The first glyph that starts a sequence of glyphs from string. */ | 10652 /* The first glyph that starts a sequence of glyphs from string. */ |
10651 struct glyph *string_start; | 10653 struct glyph *string_start; |
10652 /* The X coordinate of string_start. */ | 10654 /* The X coordinate of string_start. */ |
10653 int string_start_x; | 10655 int string_start_x; |
10654 /* The last known character position. */ | 10656 /* The last known character position. */ |
10655 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; | 10657 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; |
10656 /* The last known character position before string_start. */ | 10658 /* The last known character position before string_start. */ |
10657 int string_before_pos; | 10659 int string_before_pos; |
10658 int x = row->x; | 10660 int x = row->x; |
10661 int cursor_x = x; | |
10659 int pt_old = PT - delta; | 10662 int pt_old = PT - delta; |
10660 | 10663 |
10661 /* Skip over glyphs not having an object at the start of the row. | 10664 /* Skip over glyphs not having an object at the start of the row. |
10662 These are special glyphs like truncation marks on terminal | 10665 These are special glyphs like truncation marks on terminal |
10663 frames. */ | 10666 frames. */ |
10686 { | 10689 { |
10687 string_before_pos = last_pos; | 10690 string_before_pos = last_pos; |
10688 string_start = glyph; | 10691 string_start = glyph; |
10689 string_start_x = x; | 10692 string_start_x = x; |
10690 /* Skip all glyphs from string. */ | 10693 /* Skip all glyphs from string. */ |
10691 SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object)); | 10694 do |
10692 } | 10695 { |
10693 } | 10696 if ((cursor == NULL || glyph > cursor) |
10694 | 10697 && !NILP (Fget_char_property (make_number ((glyph)->charpos), |
10695 if (string_start | 10698 Qcursor, (glyph)->object))) |
10696 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) | 10699 { |
10700 cursor = glyph; | |
10701 cursor_x = x; | |
10702 } | |
10703 x += glyph->pixel_width; | |
10704 ++glyph; | |
10705 } | |
10706 while (glyph < end && STRINGP (glyph->object)); | |
10707 } | |
10708 } | |
10709 | |
10710 if (cursor != NULL) | |
10711 { | |
10712 glyph = cursor; | |
10713 x = cursor_x; | |
10714 } | |
10715 else if (string_start | |
10716 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) | |
10697 { | 10717 { |
10698 /* We may have skipped over point because the previous glyphs | 10718 /* We may have skipped over point because the previous glyphs |
10699 are from string. As there's no easy way to know the | 10719 are from string. As there's no easy way to know the |
10700 character position of the current glyph, find the correct | 10720 character position of the current glyph, find the correct |
10701 glyph on point by scanning from string_start again. */ | 10721 glyph on point by scanning from string_start again. */ |