changeset 21499:a063399999d8

(strout): Convert old echo area to multibyte, like printchar. (printchar, strout): If echo area text converted to multibyte does not all fit, truncate it at char boundary.
author Karl Heuer <kwzh@gnu.org>
date Mon, 13 Apr 1998 18:58:10 +0000
parents e69604162c2b
children 4c72cf4eeedb
files src/print.c
diffstat 1 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/print.c	Mon Apr 13 18:57:28 1998 +0000
+++ b/src/print.c	Mon Apr 13 18:58:10 1998 +0000
@@ -398,11 +398,15 @@
 		     0, 1);
 	  printbufidx = size;
 	  if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame))
-	    printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame);
+	    {
+	      printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame);
+	      /* Rewind incomplete multi-byte form.  */
+	      while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0)
+		printbufidx--;
+	    }
 	  bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx);
+	  message_enable_multibyte = 1;
 	}
-      message_enable_multibyte
-	= ! NILP (current_buffer->enable_multibyte_characters);
 
       if (printbufidx < FRAME_MESSAGE_BUF_SIZE (mini_frame) - len)
 	bcopy (str, &FRAME_MESSAGE_BUF (mini_frame)[printbufidx], len),
@@ -489,16 +493,44 @@
 	}
 
       message_dolog (ptr, size_byte, 0, multibyte);
+
+      /* Convert message to multibyte if we are now adding multibyte text.  */
+      if (multibyte
+	  && ! message_enable_multibyte
+	  && printbufidx > 0)
+	{
+	  int size = count_size_as_multibyte (FRAME_MESSAGE_BUF (mini_frame),
+					      printbufidx);
+	  unsigned char *tembuf = (unsigned char *) alloca (size + 1);
+	  copy_text (FRAME_MESSAGE_BUF (mini_frame), tembuf, printbufidx,
+		     0, 1);
+	  printbufidx = size;
+	  if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame))
+	    {
+	      printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame);
+	      /* Rewind incomplete multi-byte form.  */
+	      while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0)
+		printbufidx--;
+	    }
+
+	  bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx);
+	  message_enable_multibyte = 1;
+	}
+
+      /* Compute how much of the new text will fit there.  */
       if (size_byte > FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1)
 	{
 	  size_byte = FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1;
 	  /* Rewind incomplete multi-byte form.  */
-	  while (size_byte && (unsigned char) ptr[size] >= 0xA0) size--;
+	  while (size_byte && (unsigned char) ptr[size_byte] >= 0xA0)
+	    size_byte--;
 	}
+
+      /* Put that part of the new text in.  */
       bcopy (ptr, &FRAME_MESSAGE_BUF (mini_frame) [printbufidx], size_byte);
       printbufidx += size_byte;
+      FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0;
       echo_area_glyphs_length = printbufidx;
-      FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0;
 
       return;
     }