aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-01-11 21:45:42 +0200
committerEli Zaretskii2012-01-11 21:45:42 +0200
commite71f5d99fe97bb132f16571764213601e3160eb6 (patch)
tree0af0da5d127420b37142e65176f8d196b3451503 /src
parentcc7f8e29eaf821712c6fd04a1675b225d7acb4e8 (diff)
downloademacs-e71f5d99fe97bb132f16571764213601e3160eb6.tar.gz
emacs-e71f5d99fe97bb132f16571764213601e3160eb6.zip
Fix the last part of bug #10464 with mouse highlight at end of line.
src/xdisp.c (rows_from_pos_range): Handle the case where the highlight ends on a newline. (mouse_face_from_buffer_pos): Fix off-by-one error in calculating he end column for display of highlight that ends on a newline before a R2L line.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/xdisp.c41
2 files changed, 46 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4c74a76e2aa..4fbfa52df3a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-01-11 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (rows_from_pos_range): Handle the case where the
4 highlight ends on a newline. (Bug#10464)
5 (mouse_face_from_buffer_pos): Fix off-by-one error in calculating
6 he end column for display of highlight that ends on a newline
7 before a R2L line.
8
12012-01-11 Glenn Morris <rgm@gnu.org> 92012-01-11 Glenn Morris <rgm@gnu.org>
2 10
3 * lread.c (init_lread): If no-site-lisp, remove site-lisp dirs 11 * lread.c (init_lread): If no-site-lisp, remove site-lisp dirs
diff --git a/src/xdisp.c b/src/xdisp.c
index c3bda5594b2..dc046886039 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25899,14 +25899,15 @@ rows_from_pos_range (struct window *w,
25899 for ( ; row->enabled_p && MATRIX_ROW_BOTTOM_Y (row) <= last_y; row++) 25899 for ( ; row->enabled_p && MATRIX_ROW_BOTTOM_Y (row) <= last_y; row++)
25900 { 25900 {
25901 struct glyph_row *next = row + 1; 25901 struct glyph_row *next = row + 1;
25902 EMACS_INT next_start = MATRIX_ROW_START_CHARPOS (next);
25902 25903
25903 if (!next->enabled_p 25904 if (!next->enabled_p
25904 || next >= MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w) 25905 || next >= MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)
25905 /* The first row >= START whose range of displayed characters 25906 /* The first row >= START whose range of displayed characters
25906 does NOT intersect the range [START_CHARPOS..END_CHARPOS] 25907 does NOT intersect the range [START_CHARPOS..END_CHARPOS]
25907 is the row END + 1. */ 25908 is the row END + 1. */
25908 || (start_charpos < MATRIX_ROW_START_CHARPOS (next) 25909 || (start_charpos < next_start
25909 && end_charpos < MATRIX_ROW_START_CHARPOS (next)) 25910 && end_charpos < next_start)
25910 || ((start_charpos > MATRIX_ROW_END_CHARPOS (next) 25911 || ((start_charpos > MATRIX_ROW_END_CHARPOS (next)
25911 || (start_charpos == MATRIX_ROW_END_CHARPOS (next) 25912 || (start_charpos == MATRIX_ROW_END_CHARPOS (next)
25912 && !next->ends_at_zv_p 25913 && !next->ends_at_zv_p
@@ -25925,12 +25926,26 @@ rows_from_pos_range (struct window *w,
25925 but none of the characters it displays are in the range, it is 25926 but none of the characters it displays are in the range, it is
25926 also END + 1. */ 25927 also END + 1. */
25927 struct glyph *g = next->glyphs[TEXT_AREA]; 25928 struct glyph *g = next->glyphs[TEXT_AREA];
25929 struct glyph *s = g;
25928 struct glyph *e = g + next->used[TEXT_AREA]; 25930 struct glyph *e = g + next->used[TEXT_AREA];
25929 25931
25930 while (g < e) 25932 while (g < e)
25931 { 25933 {
25932 if (((BUFFERP (g->object) || INTEGERP (g->object)) 25934 if (((BUFFERP (g->object) || INTEGERP (g->object))
25933 && start_charpos <= g->charpos && g->charpos < end_charpos) 25935 && (start_charpos <= g->charpos && g->charpos < end_charpos
25936 /* If the buffer position of the first glyph in
25937 the row is equal to END_CHARPOS, it means
25938 the last character to be highlighted is the
25939 newline of ROW, and we must consider NEXT as
25940 END, not END+1. */
25941 || ((!next->reversed_p && g == s
25942 || next->reversed_p && g == e - 1)
25943 && (g->charpos == end_charpos
25944 /* Special case for when NEXT is an
25945 empty line at ZV. */
25946 || (g->charpos == -1
25947 && !row->ends_at_zv_p
25948 && next_start == end_charpos)))))
25934 /* A glyph that comes from DISP_STRING is by 25949 /* A glyph that comes from DISP_STRING is by
25935 definition to be highlighted. */ 25950 definition to be highlighted. */
25936 || EQ (g->object, disp_string)) 25951 || EQ (g->object, disp_string))
@@ -25942,6 +25957,13 @@ rows_from_pos_range (struct window *w,
25942 *end = row; 25957 *end = row;
25943 break; 25958 break;
25944 } 25959 }
25960 /* The first row that ends at ZV must be the last to be
25961 highlighted. */
25962 else if (next->ends_at_zv_p)
25963 {
25964 *end = next;
25965 break;
25966 }
25945 } 25967 }
25946 } 25968 }
25947} 25969}
@@ -26255,6 +26277,19 @@ mouse_face_from_buffer_pos (Lisp_Object window,
26255 } 26277 }
26256 x += end->pixel_width; 26278 x += end->pixel_width;
26257 } 26279 }
26280 /* If we exited the above loop because we arrived at the last
26281 glyph of the row, and its buffer position is still not in
26282 range, it means the last character in range is the preceding
26283 newline. Bump the end column and x values to get past the
26284 last glyph. */
26285 if (end == glyph
26286 && BUFFERP (end->object)
26287 && (end->charpos < start_charpos
26288 || end->charpos >= end_charpos))
26289 {
26290 x += end->pixel_width;
26291 ++end;
26292 }
26258 hlinfo->mouse_face_end_x = x; 26293 hlinfo->mouse_face_end_x = x;
26259 hlinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA]; 26294 hlinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA];
26260 } 26295 }