diff src/term.c @ 107598:4bad2c6338cc

Retrospective commit from 2009-10-17. Continue working on display of R2L glyph rows. Reverse glyphs in term.c:append_glyph rather than in extend_face_to_end_of_line. Fix bidi iteration near BEGV and ZV. dispextern.h (struct glyph): New members resolved_level and bidi_type. xdisp.c (append_glyph, append_composite_glyph) (produce_image_glyph, append_stretch_glyph): Set them. term.c (append_glyph): Ditto. xdisp.c (display_line, next_element_from_buffer): Set the glyph row's reversed_p flag if the paragraph base direction is odd. (extend_face_to_end_of_line): Don't reverse the glyphs here. term.c (append_glyph): Reverse glyphs here. bidi.c (bidi_get_next_char_visually): Don't exit early when at ZV. (bidi_paragraph_init): Don't step over a newline if at BEGV. (bidi_paragraph_init): Handle empty buffers.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 01 Jan 2010 06:39:56 -0500
parents af182a117edd
children 297c59e52ecf
line wrap: on
line diff
--- a/src/term.c	Fri Jan 01 06:35:03 2010 -0500
+++ b/src/term.c	Fri Jan 01 06:39:56 2010 -0500
@@ -1545,6 +1545,26 @@
 	   + it->glyph_row->used[it->area]);
   end = it->glyph_row->glyphs[1 + it->area];
 
+  /* If the glyph row is reversed, we need to prepend the glyph rather
+     than append it.  */
+  if (it->glyph_row->reversed_p && it->area == TEXT_AREA)
+    {
+      struct glyph *g;
+      int move_by = it->pixel_width;
+
+      /* Make room for the new glyphs.  */
+      if (move_by > end - glyph) /* don't overstep end of this area */
+	move_by = end - glyph;
+      for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--)
+	g[move_by] = *g;
+      glyph = it->glyph_row->glyphs[it->area];
+      end = glyph + move_by;
+    }
+
+  /* BIDI Note: we put the glyphs of a "multi-pixel" character left to
+     right, even in the REVERSED_P case, since (a) all of its u.ch are
+     identical, and (b) the PADDING_P flag needs to be set for the
+     leftmost one, because we write to the terminal left-to-right.  */
   for (i = 0;
        i < it->pixel_width && glyph < end;
        ++i)
@@ -1556,6 +1576,11 @@
       glyph->padding_p = i > 0;
       glyph->charpos = CHARPOS (it->position);
       glyph->object = it->object;
+      if (it->bidi_p)
+	{
+	  glyph->resolved_level = it->bidi_it.resolved_level;
+	  glyph->bidi_type = it->bidi_it.type;
+	}
 
       ++it->glyph_row->used[it->area];
       ++glyph;