aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2010-10-23 16:41:50 +0200
committerEli Zaretskii2010-10-23 16:41:50 +0200
commita4041a7121ee093ec81ef0cb4b8da62a54587596 (patch)
tree38b9df69b316addaf729e6fd290f8fcc89513e1e
parent03f46be29c6ff082003567c27ead50a4b210b1dd (diff)
downloademacs-a4041a7121ee093ec81ef0cb4b8da62a54587596.tar.gz
emacs-a4041a7121ee093ec81ef0cb4b8da62a54587596.zip
Fix support for R2L lines. Tested with reordered text.
xdisp.c (mouse_face_from_string_pos): Fix support for R2L lines.
-rw-r--r--src/ChangeLog1
-rw-r--r--src/xdisp.c92
2 files changed, 59 insertions, 34 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d6e93b28299..a86b33fa3af 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -5,6 +5,7 @@
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 Fix off-by-one error when testing against ENDPOS.
8 Fix support for R2L lines.
8 9
92010-10-16 Eli Zaretskii <eliz@gnu.org> 102010-10-16 Eli Zaretskii <eliz@gnu.org>
10 11
diff --git a/src/xdisp.c b/src/xdisp.c
index 2db6ab8dbd1..fe3eeec982b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -24425,35 +24425,48 @@ 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 first 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;
24432 ++r) 24432 ++r)
24433 { 24433 {
24434 g = r->glyphs[TEXT_AREA]; 24434 if (!r->reversed_p)
24435 e = g + r->used[TEXT_AREA]; 24435 {
24436 for (gx = r->x; g < e; gx += g->pixel_width, ++g) 24436 g = r->glyphs[TEXT_AREA];
24437 if (EQ (g->object, object) 24437 e = g + r->used[TEXT_AREA];
24438 && startpos <= g->charpos && g->charpos <= endpos) 24438 for (gx = r->x; g < e; gx += g->pixel_width, ++g)
24439 { 24439 if (EQ (g->object, object)
24440 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows; 24440 && startpos <= g->charpos && g->charpos <= endpos)
24441 dpyinfo->mouse_face_beg_y = r->y;
24442 if (!r->reversed_p)
24443 { 24441 {
24442 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
24443 dpyinfo->mouse_face_beg_y = r->y;
24444 dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; 24444 dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
24445 dpyinfo->mouse_face_beg_x = gx; 24445 dpyinfo->mouse_face_beg_x = gx;
24446 found = 1;
24447 break;
24446 } 24448 }
24447 else 24449 }
24450 else
24451 {
24452 struct glyph *g1;
24453
24454 e = r->glyphs[TEXT_AREA];
24455 g = e + r->used[TEXT_AREA];
24456 for ( ; g > e; --g)
24457 if (EQ ((g-1)->object, object)
24458 && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
24448 { 24459 {
24449 /* R2L rows want BEG and END swapped, see 24460 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
24450 show_mouse_face. */ 24461 dpyinfo->mouse_face_beg_y = r->y;
24451 dpyinfo->mouse_face_end_col = g - r->glyphs[TEXT_AREA]; 24462 dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
24452 dpyinfo->mouse_face_end_x = gx; 24463 for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
24464 gx += g1->pixel_width;
24465 dpyinfo->mouse_face_beg_x = gx;
24466 found = 1;
24467 break;
24453 } 24468 }
24454 found = 1; 24469 }
24455 break;
24456 }
24457 if (found) 24470 if (found)
24458 break; 24471 break;
24459 } 24472 }
@@ -24486,25 +24499,36 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24486 dpyinfo->mouse_face_end_row = r - w->current_matrix->rows; 24499 dpyinfo->mouse_face_end_row = r - w->current_matrix->rows;
24487 dpyinfo->mouse_face_end_y = r->y; 24500 dpyinfo->mouse_face_end_y = r->y;
24488 24501
24489 /* Compute and set the end column. */ 24502 /* Compute and set the end column and the end column's horizontal
24490 g = r->glyphs[TEXT_AREA]; 24503 pixel coordinate. */
24491 e = g + r->used[TEXT_AREA];
24492 for ( ; e > g; --e)
24493 if (EQ ((e-1)->object, object)
24494 && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
24495 break;
24496 if (!r->reversed_p) 24504 if (!r->reversed_p)
24497 dpyinfo->mouse_face_end_col = e - g; 24505 {
24498 else 24506 g = r->glyphs[TEXT_AREA];
24499 dpyinfo->mouse_face_beg_col = e - g; 24507 e = g + r->used[TEXT_AREA];
24508 for ( ; e > g; --e)
24509 if (EQ ((e-1)->object, object)
24510 && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
24511 break;
24512 dpyinfo->mouse_face_end_col = e - g;
24500 24513
24501 /* Compute and set the end column's horizontal pixel coordinate. */ 24514 for (gx = r->x; g < e; ++g)
24502 for (gx = r->x; g < e; ++g) 24515 gx += g->pixel_width;
24503 gx += g->pixel_width; 24516 dpyinfo->mouse_face_end_x = gx;
24504 if (!r->reversed_p) 24517 }
24505 dpyinfo->mouse_face_end_x = gx;
24506 else 24518 else
24507 dpyinfo->mouse_face_beg_x = gx; 24519 {
24520 e = r->glyphs[TEXT_AREA];
24521 g = e + r->used[TEXT_AREA];
24522 for (gx = r->x ; e < g; ++e)
24523 {
24524 if (EQ (e->object, object)
24525 && startpos <= e->charpos && e->charpos <= endpos)
24526 break;
24527 gx += e->pixel_width;
24528 }
24529 dpyinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA];
24530 dpyinfo->mouse_face_end_x = gx;
24531 }
24508} 24532}
24509 24533
24510/* See if position X, Y is within a hot-spot of an image. */ 24534/* See if position X, Y is within a hot-spot of an image. */