changeset 107586:cbca7f94b057

Retrospective commit from 2009-08-29. Started working on cursor motion. xdisp.c (set_cursor_from_row): Don't assume glyph->charpos increments linearly. (try_window_reusing_current_matrix): Don't assume glyph->charpos increments linearly. bidi.c <bidi_overriding_paragraph_direction>: Default to L2R, for now.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 31 Dec 2009 15:56:07 -0500
parents 35abfc7649e1
children 0ff1b8888f6b
files src/ChangeLog.bidi src/bidi.c src/xdisp.c
diffstat 3 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog.bidi	Thu Dec 31 15:49:08 2009 -0500
+++ b/src/ChangeLog.bidi	Thu Dec 31 15:56:07 2009 -0500
@@ -1,3 +1,15 @@
+2009-08-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* xdisp.c (set_cursor_from_row): Don't assume glyph->charpos
+	increments linearly.
+	(try_window_reusing_current_matrix): Don't assume glyph->charpos
+	increments linearly.
+
+2009-08-28  Eli Zaretskii  <eliz@gnu.org>
+
+	* bidi.c <bidi_overriding_paragraph_direction>: Default to L2R,
+	for now.
+
 2009-08-22  Eli Zaretskii  <eliz@gnu.org>
 
 	* bidi.c (bidi_initialize): staticpro bidi_char_table.
--- a/src/bidi.c	Thu Dec 31 15:49:08 2009 -0500
+++ b/src/bidi.c	Thu Dec 31 15:56:07 2009 -0500
@@ -155,7 +155,8 @@
 
 int bidi_ignore_explicit_marks_for_paragraph_level = 1;
 
-bidi_dir_t bidi_overriding_paragraph_direction = NEUTRAL_DIR;
+/* FIXME: Should be user-definable.  */
+bidi_dir_t bidi_overriding_paragraph_direction = L2R;
 
 /* FIXME: Unused? */
 #define ASCII_BIDI_TYPE_SET(STR, TYPE)			\
--- a/src/xdisp.c	Thu Dec 31 15:49:08 2009 -0500
+++ b/src/xdisp.c	Thu Dec 31 15:56:07 2009 -0500
@@ -12377,7 +12377,7 @@
   while (glyph < end
 	 && !INTEGERP (glyph->object)
 	 && (!BUFFERP (glyph->object)
-	     || (last_pos = glyph->charpos) < pt_old
+	     || (last_pos = glyph->charpos) != pt_old
 	     || glyph->avoid_cursor_p))
     {
       if (! STRINGP (glyph->object))
@@ -14497,15 +14497,39 @@
 	    {
 	      struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
 	      struct glyph *end = glyph + row->used[TEXT_AREA];
+	      struct glyph *orig_glyph = glyph;
+	      struct cursor_pos orig_cursor = w->cursor;
 
 	      for (; glyph < end
 		     && (!BUFFERP (glyph->object)
-			 || glyph->charpos < PT);
+			 || glyph->charpos != PT);
 		   glyph++)
 		{
 		  w->cursor.hpos++;
 		  w->cursor.x += glyph->pixel_width;
 		}
+	      /* With bidi reordering, charpos changes non-linearly
+		 with hpos, so the right glyph could be to the
+		 left.  */
+	      if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)
+		  && (!BUFFERP (glyph->object) || glyph->charpos != PT))
+		{
+		  struct glyph *start_glyph = row->glyphs[TEXT_AREA];
+
+		  glyph = orig_glyph - 1;
+		  orig_cursor.hpos--;
+		  orig_cursor.x -= glyph->pixel_width;
+		  for (; glyph >= start_glyph
+			 && (!BUFFERP (glyph->object)
+			     || glyph->charpos != PT);
+		       glyph--)
+		    {
+		      w->cursor.hpos--;
+		      w->cursor.x -= glyph->pixel_width;
+		    }
+		  if (BUFFERP (glyph->object) && glyph->charpos == PT)
+		    w->cursor = orig_cursor;
+		}
 	    }
 	}