changeset 57583:a928074615ea

(display_mode_element): Fix display of wide chars. From Kenichi Handa <handa@m17n.org>.
author Kim F. Storm <storm@cua.dk>
date Mon, 18 Oct 2004 22:53:13 +0000
parents eca0af7f95d3
children 695a041acf6f
files src/xdisp.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Mon Oct 18 22:52:44 2004 +0000
+++ b/src/xdisp.c	Mon Oct 18 22:53:13 2004 +0000
@@ -7976,7 +7976,7 @@
 
   /* Copy at most PRECISION chars from STR.  */
   nbytes = strlen (str);
-  n+= c_string_width (str, nbytes, precision, &dummy, &nbytes);
+  n += c_string_width (str, nbytes, precision, &dummy, &nbytes);
   while (nbytes--)
     store_frame_title_char (*str++);
 
@@ -15457,14 +15457,15 @@
 
 	    if (this - 1 != last)
 	      {
+		int nchars, nbytes;
+
 		/* Output to end of string or up to '%'.  Field width
 		   is length of string.  Don't output more than
 		   PRECISION allows us.  */
 		--this;
 
-		prec = chars_in_text (last, this - last);
-		if (precision > 0 && prec > precision - n)
-		  prec = precision - n;
+		prec = c_string_width (last, this - last, precision - n,
+				       &nchars, &nbytes);
 
 		if (frame_title_ptr)
 		  n += store_frame_title (last, 0, prec);
@@ -15472,9 +15473,12 @@
 		  {
 		    int bytepos = last - lisp_string;
 		    int charpos = string_byte_to_char (elt, bytepos);
+		    int endpos = (precision <= 0 ? SCHARS (elt)
+				  : charpos + nchars);
+
 		    n += store_mode_line_string (NULL,
 						 Fsubstring (elt, make_number (charpos),
-							     make_number (charpos + prec)),
+							     make_number (endpos)),
 						 0, 0, 0, Qnil);
 		  }
 		else