aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-10-23 14:58:12 +0200
committerEli Zaretskii2010-10-23 14:58:12 +0200
commit03f46be29c6ff082003567c27ead50a4b210b1dd (patch)
treebe58be9dbb6cfb2a115ae35785455db9b6fc9cd8 /src
parent7b7e2c18a64fe2de45d80dfc6f48645f3e126440 (diff)
downloademacs-03f46be29c6ff082003567c27ead50a4b210b1dd.tar.gz
emacs-03f46be29c6ff082003567c27ead50a4b210b1dd.zip
The range [STARTPOS..ENDPOS] is inclusive in strings.
Tested with multiline display strings. xdisp.c (mouse_face_from_string_pos): Fix off-by-one error when testing against ENDPOS.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog1
-rw-r--r--src/xdisp.c15
2 files changed, 11 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0cd77348d12..d6e93b28299 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -4,6 +4,7 @@
4 flag to zero, and exit the outer loop when it's non-zero. Bail 4 flag to zero, and exit the outer loop when it's non-zero. Bail
5 our early if no row in the window belongs to the highlighted 5 our early if no row in the window belongs to the highlighted
6 string. Always back up after exiting the second loop. 6 string. Always back up after exiting the second loop.
7 Fix off-by-one error when testing against ENDPOS.
7 8
82010-10-16 Eli Zaretskii <eliz@gnu.org> 92010-10-16 Eli Zaretskii <eliz@gnu.org>
9 10
diff --git a/src/xdisp.c b/src/xdisp.c
index 5a7ba32b678..2db6ab8dbd1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -24409,7 +24409,7 @@ fast_find_string_pos (struct window *w, EMACS_INT pos, Lisp_Object object,
24409#endif /* not used */ 24409#endif /* not used */
24410 24410
24411/* Find the positions of the first and the last glyphs in window W's 24411/* Find the positions of the first and the last glyphs in window W's
24412 current matrix that occlude positions [STARTPOS..ENDPOS) in OBJECT 24412 current matrix that occlude positions [STARTPOS..ENDPOS] in OBJECT
24413 (assumed to be a string), and return in DPYINFO's mouse_face 24413 (assumed to be a string), and return in DPYINFO's mouse_face
24414 members the pixel and column/row coordinates of those glyphs. */ 24414 members the pixel and column/row coordinates of those glyphs. */
24415 24415
@@ -24425,7 +24425,7 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24425 int found = 0; 24425 int found = 0;
24426 24426
24427 /* Find the glyph row with at least one position in the range 24427 /* Find the glyph row with at least one position in the range
24428 [STARTPOS..ENDPOS), and the leftmost glyph in that row whose 24428 [STARTPOS..ENDPOS], and the leftmost glyph in that row whose
24429 position belongs to that range. */ 24429 position belongs to that range. */
24430 for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 24430 for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
24431 r->enabled_p && r->y < yb; 24431 r->enabled_p && r->y < yb;
@@ -24435,7 +24435,7 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24435 e = g + r->used[TEXT_AREA]; 24435 e = g + r->used[TEXT_AREA];
24436 for (gx = r->x; g < e; gx += g->pixel_width, ++g) 24436 for (gx = r->x; g < e; gx += g->pixel_width, ++g)
24437 if (EQ (g->object, object) 24437 if (EQ (g->object, object)
24438 && startpos <= g->charpos && g->charpos < endpos) 24438 && startpos <= g->charpos && g->charpos <= endpos)
24439 { 24439 {
24440 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows; 24440 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
24441 dpyinfo->mouse_face_beg_y = r->y; 24441 dpyinfo->mouse_face_beg_y = r->y;
@@ -24470,7 +24470,7 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24470 found = 0; 24470 found = 0;
24471 for ( ; g < e; ++g) 24471 for ( ; g < e; ++g)
24472 if (EQ (g->object, object) 24472 if (EQ (g->object, object)
24473 && startpos <= g->charpos && g->charpos < endpos) 24473 && startpos <= g->charpos && g->charpos <= endpos)
24474 { 24474 {
24475 found = 1; 24475 found = 1;
24476 break; 24476 break;
@@ -24478,22 +24478,27 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24478 if (!found) 24478 if (!found)
24479 break; 24479 break;
24480 } 24480 }
24481
24482 /* The highlighted region ends on the previous row. */
24481 r--; 24483 r--;
24482 24484
24485 /* Set the end row and its vertical pixel coordinate. */
24483 dpyinfo->mouse_face_end_row = r - w->current_matrix->rows; 24486 dpyinfo->mouse_face_end_row = r - w->current_matrix->rows;
24484 dpyinfo->mouse_face_end_y = r->y; 24487 dpyinfo->mouse_face_end_y = r->y;
24485 24488
24489 /* Compute and set the end column. */
24486 g = r->glyphs[TEXT_AREA]; 24490 g = r->glyphs[TEXT_AREA];
24487 e = g + r->used[TEXT_AREA]; 24491 e = g + r->used[TEXT_AREA];
24488 for ( ; e > g; --e) 24492 for ( ; e > g; --e)
24489 if (EQ ((e-1)->object, object) 24493 if (EQ ((e-1)->object, object)
24490 && startpos <= (e-1)->charpos && (e-1)->charpos < endpos) 24494 && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
24491 break; 24495 break;
24492 if (!r->reversed_p) 24496 if (!r->reversed_p)
24493 dpyinfo->mouse_face_end_col = e - g; 24497 dpyinfo->mouse_face_end_col = e - g;
24494 else 24498 else
24495 dpyinfo->mouse_face_beg_col = e - g; 24499 dpyinfo->mouse_face_beg_col = e - g;
24496 24500
24501 /* Compute and set the end column's horizontal pixel coordinate. */
24497 for (gx = r->x; g < e; ++g) 24502 for (gx = r->x; g < e; ++g)
24498 gx += g->pixel_width; 24503 gx += g->pixel_width;
24499 if (!r->reversed_p) 24504 if (!r->reversed_p)