changeset 111104:42b3175dc16e

Fix mouse highlight in continued R2L lines. xdisp.c (show_mouse_face): Support drawing highlighted R2L lines.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 28 Aug 2010 17:12:36 +0300
parents 6af5749f5c94
children 64a4bf2e92ae
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 44 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Aug 28 15:36:19 2010 +0300
+++ b/src/ChangeLog	Sat Aug 28 17:12:36 2010 +0300
@@ -3,6 +3,7 @@
 	* xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as
 	test case.  Implement  highlight for R2L rows.  Fix the case of
 	continued L2R lines.
+	(show_mouse_face): Support drawing highlighted R2L lines.
 
 2010-08-21  Eli Zaretskii  <eliz@gnu.org>
 
--- a/src/xdisp.c	Sat Aug 28 15:36:19 2010 +0300
+++ b/src/xdisp.c	Sat Aug 28 17:12:36 2010 +0300
@@ -23711,8 +23711,30 @@
 	  /* For all but the first row, the highlight starts at column 0.  */
 	  if (row == first)
 	    {
-	      start_hpos = dpyinfo->mouse_face_beg_col;
-	      start_x = dpyinfo->mouse_face_beg_x;
+	      /* R2L rows have BEG and END in reversed order, but the
+		 screen drawing geometry is always left to right.  So
+		 we need to mirror the beginning and end of the
+		 highlighted area in R2L rows.  */
+	      if (!row->reversed_p)
+		{
+		  start_hpos = dpyinfo->mouse_face_beg_col;
+		  start_x = dpyinfo->mouse_face_beg_x;
+		}
+	      else if (row == last)
+		{
+		  start_hpos = dpyinfo->mouse_face_end_col;
+		  start_x = dpyinfo->mouse_face_end_x;
+		}
+	      else
+		{
+		  start_hpos = 0;
+		  start_x = 0;
+		}
+	    }
+	  else if (row->reversed_p && row == last)
+	    {
+	      start_hpos = dpyinfo->mouse_face_end_col;
+	      start_x = dpyinfo->mouse_face_end_x;
 	    }
 	  else
 	    {
@@ -23721,7 +23743,20 @@
 	    }
 
 	  if (row == last)
-	    end_hpos = dpyinfo->mouse_face_end_col;
+	    {
+	      if (!row->reversed_p)
+		end_hpos = dpyinfo->mouse_face_end_col;
+	      else if (row == first)
+		end_hpos = dpyinfo->mouse_face_beg_col;
+	      else
+		{
+		  end_hpos = row->used[TEXT_AREA];
+		  if (draw == DRAW_NORMAL_TEXT)
+		    row->fill_line_p = 1; /* Clear to end of line */
+		}
+	    }
+	  else if (row->reversed_p && row == first)
+	    end_hpos = dpyinfo->mouse_face_beg_col;
 	  else
 	    {
 	      end_hpos = row->used[TEXT_AREA];
@@ -24002,16 +24037,11 @@
 		}
 	    }
 
-	  /* Mouse highlight uses the screen geometry, which is left
-	     to right even in R2L paragraphs.  Therefore, for R2L
-	     paragraphs, the "first" highlighted glyph actually
-	     determines the _end_ column and x of the highlighted
-	     area.  */
-	  glyph++;	/* first glyph beyond the highlighted area */
+	  glyph++; /* first glyph to the right of the highlighted area */
 	  for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++)
 	    x += g->pixel_width;
-	  dpyinfo->mouse_face_end_x = x;
-	  dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA];
+	  dpyinfo->mouse_face_beg_x = x;
+	  dpyinfo->mouse_face_beg_col = glyph - row->glyphs[TEXT_AREA];
 	}
     }
 
@@ -24041,13 +24071,6 @@
      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];
@@ -24154,19 +24177,8 @@
 	    }
 	  x += end->pixel_width;
 	}
-      /* In the left-to-right screen geometry, END is actually the
-	 _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_end_x = x;
+      dpyinfo->mouse_face_end_col = end - row->glyphs[TEXT_AREA];
     }
 
   dpyinfo->mouse_face_window = window;