diff options
| author | Eli Zaretskii | 2011-11-19 17:50:23 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2011-11-19 17:50:23 +0200 |
| commit | f8fe6f9674b53239529644f95b71f2d885d76a08 (patch) | |
| tree | d2c4701296874b82dc815ace4de368ca8ed58cec /src | |
| parent | c7635a977e0d1fdb4d91ff54b3d85dfa9f3d3fe8 (diff) | |
| download | emacs-f8fe6f9674b53239529644f95b71f2d885d76a08.tar.gz emacs-f8fe6f9674b53239529644f95b71f2d885d76a08.zip | |
Fix bug #10075 with cursor drawing in an hscrolled window.
src/xdisp.c (x_write_glyphs, draw_phys_cursor_glyph)
(erase_phys_cursor, update_window_cursor, show_mouse_face)
(cursor_in_mouse_face_p): If the cursor position is out of bounds,
behave as if the cursor position were at the window margin.
src/window.c (get_phys_cursor_glyph): If the window is hscrolled,
and the cursor position is out of bounds, behave as if the cursor
position were at the window margin.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/window.c | 29 | ||||
| -rw-r--r-- | src/xdisp.c | 82 |
3 files changed, 107 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1fff4517c0b..2973ecc4b57 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2011-11-19 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (x_write_glyphs, draw_phys_cursor_glyph) | ||
| 4 | (erase_phys_cursor, update_window_cursor, show_mouse_face) | ||
| 5 | (cursor_in_mouse_face_p): If the cursor position is out of bounds, | ||
| 6 | behave as if the cursor position were at the window margin. | ||
| 7 | |||
| 8 | * window.c (get_phys_cursor_glyph): If the window is hscrolled, | ||
| 9 | and the cursor position is out of bounds, behave as if the cursor | ||
| 10 | position were at the window margin. (Bug#10075) | ||
| 11 | |||
| 1 | 2011-11-18 Chong Yidong <cyd@gnu.org> | 12 | 2011-11-18 Chong Yidong <cyd@gnu.org> |
| 2 | 13 | ||
| 3 | * window.c (Fwindow_combination_limit): Make first argument | 14 | * window.c (Fwindow_combination_limit): Make first argument |
diff --git a/src/window.c b/src/window.c index ae0c7431f74..776f097b59e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5773,13 +5773,30 @@ get_phys_cursor_glyph (struct window *w) | |||
| 5773 | { | 5773 | { |
| 5774 | struct glyph_row *row; | 5774 | struct glyph_row *row; |
| 5775 | struct glyph *glyph; | 5775 | struct glyph *glyph; |
| 5776 | int hpos = w->phys_cursor.hpos; | ||
| 5776 | 5777 | ||
| 5777 | if (w->phys_cursor.vpos >= 0 | 5778 | if (!(w->phys_cursor.vpos >= 0 |
| 5778 | && w->phys_cursor.vpos < w->current_matrix->nrows | 5779 | && w->phys_cursor.vpos < w->current_matrix->nrows)) |
| 5779 | && (row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos), | 5780 | return NULL; |
| 5780 | row->enabled_p) | 5781 | |
| 5781 | && row->used[TEXT_AREA] > w->phys_cursor.hpos) | 5782 | row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos); |
| 5782 | glyph = row->glyphs[TEXT_AREA] + w->phys_cursor.hpos; | 5783 | if (!row->enabled_p) |
| 5784 | return NULL; | ||
| 5785 | |||
| 5786 | if (w->hscroll) | ||
| 5787 | { | ||
| 5788 | /* When the window is hscrolled, cursor hpos can legitimately be | ||
| 5789 | out of bounds, but we draw the cursor at the corresponding | ||
| 5790 | window margin in that case. */ | ||
| 5791 | if (!row->reversed_p && hpos < 0) | ||
| 5792 | hpos = 0; | ||
| 5793 | if (row->reversed_p && hpos >= row->used[TEXT_AREA]) | ||
| 5794 | hpos = row->used[TEXT_AREA] - 1; | ||
| 5795 | } | ||
| 5796 | |||
| 5797 | if (row->used[TEXT_AREA] > hpos | ||
| 5798 | && 0 <= hpos) | ||
| 5799 | glyph = row->glyphs[TEXT_AREA] + hpos; | ||
| 5783 | else | 5800 | else |
| 5784 | glyph = NULL; | 5801 | glyph = NULL; |
| 5785 | 5802 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 1c913ca9612..bc7a7a053db 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -24671,9 +24671,17 @@ x_produce_glyphs (struct it *it) | |||
| 24671 | void | 24671 | void |
| 24672 | x_write_glyphs (struct glyph *start, int len) | 24672 | x_write_glyphs (struct glyph *start, int len) |
| 24673 | { | 24673 | { |
| 24674 | int x, hpos; | 24674 | int x, hpos, chpos = updated_window->phys_cursor.hpos; |
| 24675 | 24675 | ||
| 24676 | xassert (updated_window && updated_row); | 24676 | xassert (updated_window && updated_row); |
| 24677 | /* When the window is hscrolled, cursor hpos can legitimately be out | ||
| 24678 | of bounds, but we draw the cursor at the corresponding window | ||
| 24679 | margin in that case. */ | ||
| 24680 | if (!updated_row->reversed_p && chpos < 0) | ||
| 24681 | chpos = 0; | ||
| 24682 | if (updated_row->reversed_p && chpos >= updated_row->used[TEXT_AREA]) | ||
| 24683 | chpos = updated_row->used[TEXT_AREA] - 1; | ||
| 24684 | |||
| 24677 | BLOCK_INPUT; | 24685 | BLOCK_INPUT; |
| 24678 | 24686 | ||
| 24679 | /* Write glyphs. */ | 24687 | /* Write glyphs. */ |
| @@ -24688,8 +24696,8 @@ x_write_glyphs (struct glyph *start, int len) | |||
| 24688 | if (updated_area == TEXT_AREA | 24696 | if (updated_area == TEXT_AREA |
| 24689 | && updated_window->phys_cursor_on_p | 24697 | && updated_window->phys_cursor_on_p |
| 24690 | && updated_window->phys_cursor.vpos == output_cursor.vpos | 24698 | && updated_window->phys_cursor.vpos == output_cursor.vpos |
| 24691 | && updated_window->phys_cursor.hpos >= hpos | 24699 | && chpos >= hpos |
| 24692 | && updated_window->phys_cursor.hpos < hpos + len) | 24700 | && chpos < hpos + len) |
| 24693 | updated_window->phys_cursor_on_p = 0; | 24701 | updated_window->phys_cursor_on_p = 0; |
| 24694 | 24702 | ||
| 24695 | UNBLOCK_INPUT; | 24703 | UNBLOCK_INPUT; |
| @@ -25199,8 +25207,17 @@ draw_phys_cursor_glyph (struct window *w, struct glyph_row *row, | |||
| 25199 | { | 25207 | { |
| 25200 | int on_p = w->phys_cursor_on_p; | 25208 | int on_p = w->phys_cursor_on_p; |
| 25201 | int x1; | 25209 | int x1; |
| 25202 | x1 = draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, | 25210 | int hpos = w->phys_cursor.hpos; |
| 25203 | w->phys_cursor.hpos, w->phys_cursor.hpos + 1, | 25211 | |
| 25212 | /* When the window is hscrolled, cursor hpos can legitimately be | ||
| 25213 | out of bounds, but we draw the cursor at the corresponding | ||
| 25214 | window margin in that case. */ | ||
| 25215 | if (!row->reversed_p && hpos < 0) | ||
| 25216 | hpos = 0; | ||
| 25217 | if (row->reversed_p && hpos >= row->used[TEXT_AREA]) | ||
| 25218 | hpos = row->used[TEXT_AREA] - 1; | ||
| 25219 | |||
| 25220 | x1 = draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, hpos, hpos + 1, | ||
| 25204 | hl, 0); | 25221 | hl, 0); |
| 25205 | w->phys_cursor_on_p = on_p; | 25222 | w->phys_cursor_on_p = on_p; |
| 25206 | 25223 | ||
| @@ -25288,6 +25305,14 @@ erase_phys_cursor (struct window *w) | |||
| 25288 | : (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA]))) | 25305 | : (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA]))) |
| 25289 | goto mark_cursor_off; | 25306 | goto mark_cursor_off; |
| 25290 | 25307 | ||
| 25308 | /* When the window is hscrolled, cursor hpos can legitimately be out | ||
| 25309 | of bounds, but we draw the cursor at the corresponding window | ||
| 25310 | margin in that case. */ | ||
| 25311 | if (!cursor_row->reversed_p && hpos < 0) | ||
| 25312 | hpos = 0; | ||
| 25313 | if (cursor_row->reversed_p && hpos >= cursor_row->used[TEXT_AREA]) | ||
| 25314 | hpos = cursor_row->used[TEXT_AREA] - 1; | ||
| 25315 | |||
| 25291 | /* If the cursor is in the mouse face area, redisplay that when | 25316 | /* If the cursor is in the mouse face area, redisplay that when |
| 25292 | we clear the cursor. */ | 25317 | we clear the cursor. */ |
| 25293 | if (! NILP (hlinfo->mouse_face_window) | 25318 | if (! NILP (hlinfo->mouse_face_window) |
| @@ -25431,8 +25456,26 @@ update_window_cursor (struct window *w, int on) | |||
| 25431 | of being deleted. */ | 25456 | of being deleted. */ |
| 25432 | if (w->current_matrix) | 25457 | if (w->current_matrix) |
| 25433 | { | 25458 | { |
| 25459 | int hpos = w->phys_cursor.hpos; | ||
| 25460 | int vpos = w->phys_cursor.vpos; | ||
| 25461 | struct glyph_row *row; | ||
| 25462 | |||
| 25463 | if (vpos >= w->current_matrix->nrows | ||
| 25464 | || hpos >= w->current_matrix->matrix_w) | ||
| 25465 | return; | ||
| 25466 | |||
| 25467 | row = MATRIX_ROW (w->current_matrix, vpos); | ||
| 25468 | |||
| 25469 | /* When the window is hscrolled, cursor hpos can legitimately be | ||
| 25470 | out of bounds, but we draw the cursor at the corresponding | ||
| 25471 | window margin in that case. */ | ||
| 25472 | if (!row->reversed_p && hpos < 0) | ||
| 25473 | hpos = 0; | ||
| 25474 | if (row->reversed_p && hpos >= row->used[TEXT_AREA]) | ||
| 25475 | hpos = row->used[TEXT_AREA] - 1; | ||
| 25476 | |||
| 25434 | BLOCK_INPUT; | 25477 | BLOCK_INPUT; |
| 25435 | display_and_set_cursor (w, on, w->phys_cursor.hpos, w->phys_cursor.vpos, | 25478 | display_and_set_cursor (w, on, hpos, vpos, |
| 25436 | w->phys_cursor.x, w->phys_cursor.y); | 25479 | w->phys_cursor.x, w->phys_cursor.y); |
| 25437 | UNBLOCK_INPUT; | 25480 | UNBLOCK_INPUT; |
| 25438 | } | 25481 | } |
| @@ -25602,9 +25645,18 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw) | |||
| 25602 | if (FRAME_WINDOW_P (f) | 25645 | if (FRAME_WINDOW_P (f) |
| 25603 | && phys_cursor_on_p && !w->phys_cursor_on_p) | 25646 | && phys_cursor_on_p && !w->phys_cursor_on_p) |
| 25604 | { | 25647 | { |
| 25648 | int hpos = w->phys_cursor.hpos; | ||
| 25649 | |||
| 25650 | /* When the window is hscrolled, cursor hpos can legitimately be | ||
| 25651 | out of bounds, but we draw the cursor at the corresponding | ||
| 25652 | window margin in that case. */ | ||
| 25653 | if (!row->reversed_p && hpos < 0) | ||
| 25654 | hpos = 0; | ||
| 25655 | if (row->reversed_p && hpos >= row->used[TEXT_AREA]) | ||
| 25656 | hpos = row->used[TEXT_AREA] - 1; | ||
| 25657 | |||
| 25605 | BLOCK_INPUT; | 25658 | BLOCK_INPUT; |
| 25606 | display_and_set_cursor (w, 1, | 25659 | display_and_set_cursor (w, 1, hpos, w->phys_cursor.vpos, |
| 25607 | w->phys_cursor.hpos, w->phys_cursor.vpos, | ||
| 25608 | w->phys_cursor.x, w->phys_cursor.y); | 25660 | w->phys_cursor.x, w->phys_cursor.y); |
| 25609 | UNBLOCK_INPUT; | 25661 | UNBLOCK_INPUT; |
| 25610 | } | 25662 | } |
| @@ -25703,7 +25755,19 @@ coords_in_mouse_face_p (struct window *w, int hpos, int vpos) | |||
| 25703 | int | 25755 | int |
| 25704 | cursor_in_mouse_face_p (struct window *w) | 25756 | cursor_in_mouse_face_p (struct window *w) |
| 25705 | { | 25757 | { |
| 25706 | return coords_in_mouse_face_p (w, w->phys_cursor.hpos, w->phys_cursor.vpos); | 25758 | int hpos = w->phys_cursor.hpos; |
| 25759 | int vpos = w->phys_cursor.vpos; | ||
| 25760 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos); | ||
| 25761 | |||
| 25762 | /* When the window is hscrolled, cursor hpos can legitimately be out | ||
| 25763 | of bounds, but we draw the cursor at the corresponding window | ||
| 25764 | margin in that case. */ | ||
| 25765 | if (!row->reversed_p && hpos < 0) | ||
| 25766 | hpos = 0; | ||
| 25767 | if (row->reversed_p && hpos >= row->used[TEXT_AREA]) | ||
| 25768 | hpos = row->used[TEXT_AREA] - 1; | ||
| 25769 | |||
| 25770 | return coords_in_mouse_face_p (w, hpos, vpos); | ||
| 25707 | } | 25771 | } |
| 25708 | 25772 | ||
| 25709 | 25773 | ||