changeset 35410:94d2751dcb5c

(store_frame_title): Pay attention to width of non-ASCII characters by calling c_string_width. (x_consider_frame_title): Get byte length of frame tile string correctly. (display_mode_element): Pay attention to width of non-ASCII characters by calling strwidth.
author Kenichi Handa <handa@m17n.org>
date Fri, 19 Jan 2001 05:23:16 +0000
parents 0ff464da2a0a
children be20c22dc16d
files src/xdisp.c
diffstat 1 files changed, 17 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Fri Jan 19 05:22:51 2001 +0000
+++ b/src/xdisp.c	Fri Jan 19 05:23:16 2001 +0000
@@ -6759,12 +6759,12 @@
 
 
 /* Store part of a frame title in frame_title_buf, beginning at
-   frame_title_ptr.  STR is the string to store.  Do not copy more
-   than PRECISION number of bytes from STR; PRECISION <= 0 means copy
-   the whole string.  Pad with spaces until FIELD_WIDTH number of
-   characters have been copied; FIELD_WIDTH <= 0 means don't pad.
-   Called from display_mode_element when it is used to build a frame
-   title.  */
+   frame_title_ptr.  STR is the string to store.  Do not copy
+   characters that yield more columns than PRECISION; PRECISION <= 0
+   means copy the whole string.  Pad with spaces until FIELD_WIDTH
+   number of characters have been copied; FIELD_WIDTH <= 0 means don't
+   pad.  Called from display_mode_element when it is used to build a
+   frame title.  */
 
 static int
 store_frame_title (str, field_width, precision)
@@ -6772,14 +6772,13 @@
      int field_width, precision;
 {
   int n = 0;
+  int dummy, nbytes, width;
 
   /* Copy at most PRECISION chars from STR.  */
-  while ((precision <= 0 || n < precision)
-	 && *str)
-    {
-      store_frame_title_char (*str++);
-      ++n;
-    }
+  nbytes = strlen (str);
+  n+= c_string_width (str, nbytes, precision, &dummy, &nbytes);
+  while (nbytes--)
+    store_frame_title_char (*str++);
 
   /* Fill up with spaces until FIELD_WIDTH reached.  */
   while (field_width > 0
@@ -6837,7 +6836,8 @@
       frame_title_ptr = frame_title_buf;
       init_iterator (&it, XWINDOW (f->selected_window), -1, -1,
 		     NULL, DEFAULT_FACE_ID);
-      len = display_mode_element (&it, 0, -1, -1, fmt);
+      display_mode_element (&it, 0, -1, -1, fmt);
+      len = frame_title_ptr - frame_title_buf;
       frame_title_ptr = NULL;
       set_buffer_internal (obuf);
 
@@ -12804,12 +12804,13 @@
 		/* Output to end of string or up to '%'.  Field width
 		   is length of string.  Don't output more than
 		   PRECISION allows us.  */
-		prec = --this - last;
+		--this;
+		prec = strwidth (last, this - last);
 		if (precision > 0 && prec > precision - n)
 		  prec = precision - n;
 		
 		if (frame_title_ptr)
-		  n += store_frame_title (last, prec, prec);
+		  n += store_frame_title (last, 0, prec);
 		else
 		  n += display_string (NULL, elt, Qnil, 0, last - lisp_string,
 				       it, 0, prec, 0, -1);
@@ -12891,9 +12892,7 @@
 	       don't check for % within it.  */
 	    if (STRINGP (tem))
 	      {
-		prec = XSTRING (tem)->size;
-		if (precision > 0 && prec > precision - n)
-		  prec = precision - n;
+		prec = precision - n;
 		if (frame_title_ptr)
 		  n += store_frame_title (XSTRING (tem)->data, -1, prec);
 		else