changeset 111103:6af5749f5c94

Support L2R continued lines. xdisp.c (mouse_face_from_buffer_pos): Fix the case of continued L2R lines.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 28 Aug 2010 15:36:19 +0300
parents 9fbc584102c2
children 42b3175dc16e
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 46 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Aug 28 14:09:02 2010 +0300
+++ b/src/ChangeLog	Sat Aug 28 15:36:19 2010 +0300
@@ -1,7 +1,8 @@
 2010-08-28  Eli Zaretskii  <eliz@gnu.org>
 
 	* xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as
-	test case.  Implement  highlight for R2L rows.
+	test case.  Implement  highlight for R2L rows.  Fix the case of
+	continued L2R lines.
 
 2010-08-21  Eli Zaretskii  <eliz@gnu.org>
 
--- a/src/xdisp.c	Sat Aug 28 14:09:02 2010 +0300
+++ b/src/xdisp.c	Sat Aug 28 15:36:19 2010 +0300
@@ -23837,7 +23837,7 @@
 {
   struct window *w = XWINDOW (window);
   struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
-  struct glyph_row *row;
+  struct glyph_row *row, *r;
   struct glyph *glyph, *end;
   EMACS_INT ignore, pos;
   int x;
@@ -24016,10 +24016,10 @@
     }
 
   /* Find the last highlighted glyph.  */
-  row = row_containing_pos (w, end_charpos, first, NULL, 0);
-  if (row == NULL)
-    {
-      row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
+  r = row_containing_pos (w, end_charpos, first, NULL, 0);
+  if (r == NULL)
+    {
+      r = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
       dpyinfo->mouse_face_past_end = 1;
     }
   else if (!NILP (after_string))
@@ -24029,12 +24029,37 @@
       struct glyph_row *last
 	= MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
 
-      for (next = row + 1;
+      for (next = r + 1;
 	   next <= last
 	     && next->used[TEXT_AREA] > 0
 	     && EQ (next->glyphs[TEXT_AREA]->object, after_string);
 	   ++next)
-	row = next;
+	r = next;
+    }
+
+  /* If the highlight ends in a different row, compute GLYPH and END
+     for the end row.  */
+  if (r != row)
+    {
+      /* If the beginning row was an R2L row, we actually computed
+	 above the beginning of the highlighted area, not its end.  */
+      if (row->reversed_p)
+	{
+	  dpyinfo->mouse_face_beg_x = dpyinfo->mouse_face_end_x;
+	  dpyinfo->mouse_face_beg_col = dpyinfo->mouse_face_end_col;
+	}
+      if (!r->reversed_p)
+	{
+	  glyph = r->glyphs[TEXT_AREA];
+	  end = glyph + r->used[TEXT_AREA];
+	  x = r->x;
+	}
+      else
+	{
+	  end = r->glyphs[TEXT_AREA] - 1;
+	  glyph = end + r->used[TEXT_AREA];
+	}
+      row = r;
     }
 
   dpyinfo->mouse_face_end_y = row->y;
@@ -24130,9 +24155,18 @@
 	  x += end->pixel_width;
 	}
       /* In the left-to-right screen geometry, END is actually the
-	 _beginning_ of the highlighted area for R2L paragraphs.  */
-      dpyinfo->mouse_face_beg_x = x;
-      dpyinfo->mouse_face_beg_col = end - row->glyphs[TEXT_AREA];
+	 _beginning_ of the highlighted area for R2L paragraphs, if
+	 the highlight begins and ends in the same row.  */
+      if (dpyinfo->mouse_face_end_row == dpyinfo->mouse_face_beg_row)
+	{
+	  dpyinfo->mouse_face_beg_x = x;
+	  dpyinfo->mouse_face_beg_col = end - row->glyphs[TEXT_AREA];
+	}
+      else
+	{
+	  dpyinfo->mouse_face_end_x = x;
+	  dpyinfo->mouse_face_end_col = end - row->glyphs[TEXT_AREA];
+	}
     }
 
   dpyinfo->mouse_face_window = window;