changeset 40244:164df80e94ba

(try_window_reusing_current_matrix): Use row_containing_pos. (row_containing_pos): Take additional argument DY. Treat rows ending in middle of char differently. (display_line): Handle tabs on window systems differently.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 24 Oct 2001 09:11:54 +0000
parents 5a65c1e29273
children 9175d0c189f4
files src/xdisp.c
diffstat 1 files changed, 36 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Wed Oct 24 09:10:57 2001 +0000
+++ b/src/xdisp.c	Wed Oct 24 09:11:54 2001 +0000
@@ -10705,26 +10705,11 @@
 	      int dy = it.current_y - first_row_y;
 	      
 	      row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
-	      while (MATRIX_ROW_DISPLAYS_TEXT_P (row))
-		{
-		  if (PT >= MATRIX_ROW_START_CHARPOS (row)
-		      && PT < MATRIX_ROW_END_CHARPOS (row))
-		    {
-		      set_cursor_from_row (w, row, w->current_matrix, 0, 0,
-					   dy, nrows_scrolled);
-		      break;
-		    }
-		  
-		  if (MATRIX_ROW_BOTTOM_Y (row) + dy >= it.last_visible_y)
-		    break;
-		  
-		  ++row;
-		}
-	      
-	      /* Give up if point was not found.  This shouldn't
-		 happen often; not more often than with try_window
-		 itself.  */
-	      if (w->cursor.vpos < 0)
+	      row = row_containing_pos (w, PT, row, NULL, dy);
+	      if (row)
+		set_cursor_from_row (w, row, w->current_matrix, 0, 0,
+				     dy, nrows_scrolled);
+	      else
 		{
 		  clear_glyph_matrix (w->desired_matrix);
 		  return 0;
@@ -11200,10 +11185,11 @@
    containing CHARPOS or null.  */
 
 struct glyph_row *
-row_containing_pos (w, charpos, start, end)
+row_containing_pos (w, charpos, start, end, dy)
      struct window *w;
      int charpos;
      struct glyph_row *start, *end;
+     int dy;
 {
   struct glyph_row *row = start;
   int last_y;
@@ -11215,18 +11201,18 @@
   if ((end && row >= end) || !row->enabled_p)
     return NULL;
   
-  last_y = window_text_bottom_y (w);
+  last_y = window_text_bottom_y (w) - dy;
       
   while ((end == NULL || row < end)
+	 && MATRIX_ROW_BOTTOM_Y (row) < last_y
 	 && (MATRIX_ROW_END_CHARPOS (row) < charpos
-	     /* The end position of a row equals the start
-		position of the next row.  If CHARPOS is there, we
-		would rather display it in the next line, except
-		when this line ends in ZV.  */
 	     || (MATRIX_ROW_END_CHARPOS (row) == charpos
-		 && (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)
-		     || !row->ends_at_zv_p)))
-	 && MATRIX_ROW_BOTTOM_Y (row) < last_y)
+		 /* The end position of a row equals the start
+		    position of the next row.  If CHARPOS is there, we
+		    would rather display it in the next line, except
+		    when this line ends in ZV.  */
+		 && !row->ends_at_zv_p
+		 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))
     ++row;
       
   /* Give up if CHARPOS not found.  */
@@ -11435,7 +11421,7 @@
 	    }
       
 	  /* Set the cursor.  */
-	  row = row_containing_pos (w, PT, r0, NULL);
+	  row = row_containing_pos (w, PT, r0, NULL, 0);
 	  set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
 	  return 1;
 	}
@@ -11473,7 +11459,7 @@
 	    = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
 
 	  /* Set the cursor.  */
-	  row = row_containing_pos (w, PT, r0, NULL);
+	  row = row_containing_pos (w, PT, r0, NULL, 0);
 	  set_cursor_from_row (w, row, current_matrix, 0, 0, 0, 0);
 	  return 2;
 	}
@@ -11672,7 +11658,7 @@
 	{
 	  row = row_containing_pos (w, PT,
 				    MATRIX_FIRST_TEXT_ROW (w->current_matrix),
-				    last_unchanged_at_beg_row + 1);
+				    last_unchanged_at_beg_row + 1, 0);
 	  if (row)
 	    set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
 	}
@@ -11681,7 +11667,7 @@
       else if (first_unchanged_at_end_row)
 	{
 	  row = row_containing_pos (w, PT - delta,
-				    first_unchanged_at_end_row, NULL);
+				    first_unchanged_at_end_row, NULL, 0);
 	  if (row)
 	    set_cursor_from_row (w, row, w->current_matrix, delta,
 				 delta_bytes, dy, dvpos);
@@ -12945,11 +12931,24 @@
 		      it->max_phys_ascent = phys_ascent;
 		      it->max_phys_descent = phys_descent;
 		    }
+		  else if (it->c == '\t' && FRAME_WINDOW_P (it->f))
+		    {
+		      /* A TAB that extends past the right edge of the
+			 window.  This produces a single glyph on
+			 window system frames.  We leave the glyph in
+			 this row and let it fill the row, but don't
+			 consume the TAB.  */
+		      it->continuation_lines_width += it->last_visible_x;
+		      row->ends_in_middle_of_char_p = 1;
+		      row->continued_p = 1;
+		      glyph->pixel_width = it->last_visible_x - x;
+		      it->starts_in_middle_of_char_p = 1;
+		    }
 		  else
 		    {
-		      /* Display element draws past the right edge of
-			 the window.  Restore positions to values
-			 before the element.  */
+		      /* Something other than a TAB that draws past
+			 the right edge of the window.  Restore
+			 positions to values before the element.  */
 		      row->used[TEXT_AREA] = n_glyphs_before + i;
 		  
 		      /* Display continuation glyphs.  */
@@ -12957,14 +12956,7 @@
 			produce_special_glyphs (it, IT_CONTINUATION);
 		      row->continued_p = 1;
 
-		      /* A TAB takes us to the right edge of the window.  */
-		      if (it->c == '\t')
-			{
-			  it->continuation_lines_width += it->last_visible_x;
-			  row->ends_in_middle_of_char_p = 1;
-			}
-		      else
-			it->continuation_lines_width += x;
+		      it->continuation_lines_width += x;
 		      
 		      if (nglyphs > 1 && i > 0)
 			{