slang-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Bug in slang 2.0.5


On Wednesday 30 November 2005 18:31, Vladimir Nadvornik wrote:
> There is a bug in slang 2.0.5 which causes that in utf8 mode a
> non-ascii character can't be printed to bottom right corner.
> The problem is in function write_string_with_care, which counts
> bytes and not characters.
>

Here is a patch.



Regards, 

-- 
Vladimir Nadvornik
developer
---------------------------------------------------------------------  
SuSE CR, s.r.o.                             e-mail: nadvornik@xxxxxxx
Drahobejlova 27                             tel:+420 2 9654 2373 
190 00 Praha 9                              fax:+420 2 9654 2374   
Ceska republika                             http://www.suse.cz    
--- src/sldisply.c
+++ src/sldisply.c
@@ -1493,16 +1493,35 @@
    len = strlen (str);
    if (Automatic_Margins && (Cursor_r + 1 == SLtt_Screen_Rows))
      {
-	if (len + (unsigned int) Cursor_c >= (unsigned int) SLtt_Screen_Cols)
-	  {
-	     /* For now, just do not write there.  Later, something more
-	      * sophisticated will be implemented.
-	      */
-	     if (SLtt_Screen_Cols > Cursor_c)
-	       len = SLtt_Screen_Cols - Cursor_c - 1;
-	     else 
-	       len = 0;
-	  }
+       if (_pSLtt_UTF8_Mode == 0) 
+	 {
+	   if (len + (unsigned int) Cursor_c >= (unsigned int) SLtt_Screen_Cols)
+	     {
+	        /* For now, just do not write there.  Later, something more
+	        * sophisticated will be implemented.
+	        */
+	        if (SLtt_Screen_Cols > Cursor_c)
+	          len = SLtt_Screen_Cols - Cursor_c - 1;
+	        else 
+	          len = 0;
+	     }
+	 }
+       else
+	 {
+	   unsigned int nchars = SLutf8_strlen((SLuchar_Type *)str, 1);
+	   if (nchars + (unsigned int) Cursor_c >= (unsigned int) SLtt_Screen_Cols)
+	     {
+	       if (SLtt_Screen_Cols > Cursor_c)
+	         {
+                  char *p;
+	           nchars = SLtt_Screen_Cols - Cursor_c - 1;
+		   p = (char *)SLutf8_skip_chars((SLuchar_Type *) str, (SLuchar_Type *)(str + len), nchars, NULL, 1);
+		   len = p - str;
+		 }
+	       else
+	         len = 0; 
+	     }
+	 }
      }
    tt_write (str, len);
 }
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html

[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]