giftcurs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[giFTcurs-commits] giFTcurs/src format.c


From: Christian Häggström
Subject: [giFTcurs-commits] giFTcurs/src format.c
Date: Sat, 22 Nov 2003 05:15:12 -0500

CVSROOT:        /cvsroot/giftcurs
Module name:    giFTcurs
Branch:         
Changes by:     Christian Häggström <address@hidden>    03/11/22 05:15:10

Modified files:
        src            : format.c 

Log message:
        Substitute a wide char with space if it don't fit

Patches:
Index: giFTcurs/src/format.c
diff -u giFTcurs/src/format.c:1.72 giFTcurs/src/format.c:1.73
--- giFTcurs/src/format.c:1.72  Sat Nov  8 10:12:36 2003
+++ giFTcurs/src/format.c       Sat Nov 22 05:15:07 2003
@@ -18,7 +18,7 @@
  * along with giFTcurs; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,  USA.
  *
- * $Id: format.c,v 1.72 2003/11/08 15:12:36 saturn Exp $
+ * $Id: format.c,v 1.73 2003/11/22 10:15:07 saturn Exp $
  */
 #include "giftcurs.h"
 
@@ -854,9 +854,18 @@
 
 static void string_append_len(GString *str, const char *string, int width)
 {
-       if (utf8)
-               width = str_occupy(string, width, 0);
-       g_string_append_len(str, string, width);
+       if (utf8) {
+               int bytes = str_occupy(string, width, 0);
+               int strend = str->len;
+
+               g_string_append_len(str, string, bytes);
+
+               /* If a wide char was on the boundary, pad with a space */
+               if (vstrlen(str->str + strend) < width)
+                       g_string_append_c(str, ' ');
+       } else {
+               g_string_append_len(str, string, width);
+       }
 }
 
 /* Fill str with the actual data. All rendering info is provided in k */
@@ -939,7 +948,6 @@
                                valwidth = vstrlen(string);
 
                        /* output the string s with the given width */
-                       /* TODO: handle wide characters on the cut boundary */
                        if (valwidth >= width) {
                                string_append_len(str, string, width);
                        } else if (n->u.attr.left_justify) {
@@ -996,7 +1004,6 @@
                                        break;
                                }
 
-                               /* TODO: handle wide characters on the 
boundaries */
                                if (utf8) {
                                        start = str_occupy(str->str + 
progress_mark_offset, start, 0);
                                        end = str_occupy(str->str + 
progress_mark_offset, end, 0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]