summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2010-10-23 16:41:50 +0200
committerEli Zaretskii <eliz@gnu.org>2010-10-23 16:41:50 +0200
commita4041a7121ee093ec81ef0cb4b8da62a54587596 (patch)
tree38b9df69b316addaf729e6fd290f8fcc89513e1e
parent03f46be29c6ff082003567c27ead50a4b210b1dd (diff)
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 @@
our early if no row in the window belongs to the highlighted
string. Always back up after exiting the second loop.
Fix off-by-one error when testing against ENDPOS.
+ Fix support for R2L lines.
2010-10-16 Eli Zaretskii <eliz@gnu.org>
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,
int found = 0;
/* Find the glyph row with at least one position in the range
- [STARTPOS..ENDPOS], and the leftmost glyph in that row whose
+ [STARTPOS..ENDPOS], and the first glyph in that row whose
position belongs to that range. */
for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
r->enabled_p && r->y < yb;
++r)
{
- g = r->glyphs[TEXT_AREA];
- e = g + r->used[TEXT_AREA];
- for (gx = r->x; g < e; gx += g->pixel_width, ++g)
- if (EQ (g->object, object)
- && startpos <= g->charpos && g->charpos <= endpos)
- {
- dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
- dpyinfo->mouse_face_beg_y = r->y;
- if (!r->reversed_p)
+ if (!r->reversed_p)
+ {
+ g = r->glyphs[TEXT_AREA];
+ e = g + r->used[TEXT_AREA];
+ for (gx = r->x; g < e; gx += g->pixel_width, ++g)
+ if (EQ (g->object, object)
+ && startpos <= g->charpos && g->charpos <= endpos)
{
+ dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ dpyinfo->mouse_face_beg_y = r->y;
dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
dpyinfo->mouse_face_beg_x = gx;
+ found = 1;
+ break;
}
- else
+ }
+ else
+ {
+ struct glyph *g1;
+
+ e = r->glyphs[TEXT_AREA];
+ g = e + r->used[TEXT_AREA];
+ for ( ; g > e; --g)
+ if (EQ ((g-1)->object, object)
+ && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
{
- /* R2L rows want BEG and END swapped, see
- show_mouse_face. */
- dpyinfo->mouse_face_end_col = g - r->glyphs[TEXT_AREA];
- dpyinfo->mouse_face_end_x = gx;
+ dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ dpyinfo->mouse_face_beg_y = r->y;
+ dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
+ for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
+ gx += g1->pixel_width;
+ dpyinfo->mouse_face_beg_x = gx;
+ found = 1;
+ break;
}
- found = 1;
- break;
- }
+ }
if (found)
break;
}
@@ -24486,25 +24499,36 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
dpyinfo->mouse_face_end_row = r - w->current_matrix->rows;
dpyinfo->mouse_face_end_y = r->y;
- /* Compute and set the end column. */
- g = r->glyphs[TEXT_AREA];
- e = g + r->used[TEXT_AREA];
- for ( ; e > g; --e)
- if (EQ ((e-1)->object, object)
- && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
- break;
+ /* Compute and set the end column and the end column's horizontal
+ pixel coordinate. */
if (!r->reversed_p)
- dpyinfo->mouse_face_end_col = e - g;
- else
- dpyinfo->mouse_face_beg_col = e - g;
+ {
+ g = r->glyphs[TEXT_AREA];
+ e = g + r->used[TEXT_AREA];
+ for ( ; e > g; --e)
+ if (EQ ((e-1)->object, object)
+ && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
+ break;
+ dpyinfo->mouse_face_end_col = e - g;
- /* Compute and set the end column's horizontal pixel coordinate. */
- for (gx = r->x; g < e; ++g)
- gx += g->pixel_width;
- if (!r->reversed_p)
- dpyinfo->mouse_face_end_x = gx;
+ for (gx = r->x; g < e; ++g)
+ gx += g->pixel_width;
+ dpyinfo->mouse_face_end_x = gx;
+ }
else
- dpyinfo->mouse_face_beg_x = gx;
+ {
+ e = r->glyphs[TEXT_AREA];
+ g = e + r->used[TEXT_AREA];
+ for (gx = r->x ; e < g; ++e)
+ {
+ if (EQ (e->object, object)
+ && startpos <= e->charpos && e->charpos <= endpos)
+ break;
+ gx += e->pixel_width;
+ }
+ dpyinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA];
+ dpyinfo->mouse_face_end_x = gx;
+ }
}
/* See if position X, Y is within a hot-spot of an image. */