changeset 38984:a127df65e9a2

(display_mode_element): Use string_byte_to_char to determine character positions in strings, use chars_in_text instead of strwidth. (dump_glyph_row) [GLYPH_DEBUG]: Take a glyph row instead of a matrix as parameter; this is easier to use from GDB.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 28 Aug 2001 08:33:29 +0000
parents a437c3195fd7
children 74dadef90974
files src/xdisp.c
diffstat 1 files changed, 33 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Tue Aug 28 06:35:00 2001 +0000
+++ b/src/xdisp.c	Tue Aug 28 08:33:29 2001 +0000
@@ -11892,7 +11892,7 @@
 
 #if GLYPH_DEBUG
 
-void dump_glyph_row P_ ((struct glyph_matrix *, int, int));
+void dump_glyph_row P_ ((struct glyph_row *, int, int));
 void dump_glyph_matrix P_ ((struct glyph_matrix *, int));
 void dump_glyph P_ ((struct glyph_row *, struct glyph *, int));
 
@@ -11910,7 +11910,7 @@
 {
   int i;
   for (i = 0; i < matrix->nrows; ++i)
-    dump_glyph_row (matrix, i, glyphs);
+    dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs);
 }
 
 
@@ -11991,17 +11991,10 @@
    GLYPHS > 1 means show glyphs in long form.  */
 
 void
-dump_glyph_row (matrix, vpos, glyphs)
-     struct glyph_matrix *matrix;
+dump_glyph_row (row, vpos, glyphs)
+     struct glyph_row *row;
      int vpos, glyphs;
 {
-  struct glyph_row *row;
-  
-  if (vpos < 0 || vpos >= matrix->nrows)
-    return;
-
-  row = MATRIX_ROW (matrix, vpos);
-
   if (glyphs != 1)
     {
       fprintf (stderr, "Row Start   End Used oEI><O\\CTZFesm     X    Y    W    H    V    A    P\n");
@@ -12009,7 +12002,7 @@
   
       fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d%1.1d%1.1d\
 %1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d  %4d %4d %4d %4d %4d %4d %4d\n",
-	       row - matrix->rows,
+	       vpos,
 	       MATRIX_ROW_START_CHARPOS (row),
 	       MATRIX_ROW_END_CHARPOS (row),
 	       row->used[TEXT_AREA],
@@ -12122,10 +12115,16 @@
   (row, glyphs)
      Lisp_Object row, glyphs;
 {
+  struct glyph_matrix *matrix;
+  int vpos;
+  
   CHECK_NUMBER (row, 0);
-  dump_glyph_row (XWINDOW (selected_window)->current_matrix,
-		  XINT (row),
-		  INTEGERP (glyphs) ? XINT (glyphs) : 2);
+  matrix = XWINDOW (selected_window)->current_matrix;
+  vpos = XINT (row);
+  if (vpos >= 0 && vpos < matrix->nrows)
+    dump_glyph_row (MATRIX_ROW (matrix, vpos),
+		    vpos,
+		    INTEGERP (glyphs) ? XINT (glyphs) : 2);
   return Qnil;
 }
 
@@ -12139,8 +12138,14 @@
      Lisp_Object row, glyphs;
 {
   struct frame *sf = SELECTED_FRAME ();
-  struct glyph_matrix *m = (XWINDOW (sf->tool_bar_window)->current_matrix);
-  dump_glyph_row (m, XINT (row), INTEGERP (glyphs) ? XINT (glyphs) : 2);
+  struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
+  int vpos;
+  
+  CHECK_NUMBER (row, 0);
+  vpos = XINT (row);
+  if (vpos >= 0 && vpos < m->nrows)
+    dump_glyph_row (MATRIX_ROW (m, vpos), vpos,
+		    INTEGERP (glyphs) ? XINT (glyphs) : 2);
   return Qnil;
 }
 
@@ -13378,15 +13383,20 @@
 		   is length of string.  Don't output more than
 		   PRECISION allows us.  */
 		--this;
-		prec = strwidth (last, this - last);
+
+		prec = chars_in_text (last, this - last);
 		if (precision > 0 && prec > precision - n)
 		  prec = precision - n;
 		
 		if (frame_title_ptr)
 		  n += store_frame_title (last, 0, prec);
 		else
-		  n += display_string (NULL, elt, Qnil, 0, last - lisp_string,
-				       it, 0, prec, 0, -1);
+		  {
+		    int bytepos = last - lisp_string;
+		    int charpos = string_byte_to_char (elt, bytepos);
+		    n += display_string (NULL, elt, Qnil, 0, charpos,
+					 it, 0, prec, 0, -1);
+		  }
 	      }
 	    else /* c == '%' */
 	      {
@@ -13419,8 +13429,10 @@
 		      {
 			int nglyphs_before
 			  = it->glyph_row->used[TEXT_AREA];
+			int bytepos
+			  = percent_position - XSTRING (elt)->data;
 			int charpos
-			  = percent_position - XSTRING (elt)->data;
+			  = string_byte_to_char (elt, bytepos);
 			int nwritten
 			  = display_string (spec, Qnil, elt, charpos, 0, it,
 					    field, prec, 0, -1);