diff options
| author | Kim F. Storm | 2004-09-02 22:34:07 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-09-02 22:34:07 +0000 |
| commit | cc2734ee7602101a6dc15e2a69edf1881ba4c6c6 (patch) | |
| tree | ea94cbbe4bdabf2ed7204cc076b60e609c0d541e /src | |
| parent | 9277ba618e5e10bd65b65e7ab1becca34b32321b (diff) | |
| download | emacs-cc2734ee7602101a6dc15e2a69edf1881ba4c6c6.tar.gz emacs-cc2734ee7602101a6dc15e2a69edf1881ba4c6c6.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 32cd0f745f0..ad521e340ee 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -306,6 +306,7 @@ 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 | ||
| @@ -10647,6 +10648,7 @@ set_cursor_from_row (w, row, matrix, 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. */ |
| @@ -10656,6 +10658,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 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. |
| @@ -10688,12 +10691,29 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 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 |
| 10695 | { | ||
| 10696 | if ((cursor == NULL || glyph > cursor) | ||
| 10697 | && !NILP (Fget_char_property (make_number ((glyph)->charpos), | ||
| 10698 | Qcursor, (glyph)->object))) | ||
| 10699 | { | ||
| 10700 | cursor = glyph; | ||
| 10701 | cursor_x = x; | ||
| 10702 | } | ||
| 10703 | x += glyph->pixel_width; | ||
| 10704 | ++glyph; | ||
| 10705 | } | ||
| 10706 | while (glyph < end && STRINGP (glyph->object)); | ||
| 10692 | } | 10707 | } |
| 10693 | } | 10708 | } |
| 10694 | 10709 | ||
| 10695 | if (string_start | 10710 | if (cursor != NULL) |
| 10696 | && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) | 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 |