giftcurs-commits
[Top][All Lists]
Advanced

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

[giFTcurs-commits] giFTcurs/src parse.c wcwidth.c


From: Christian Häggström
Subject: [giFTcurs-commits] giFTcurs/src parse.c wcwidth.c
Date: Tue, 04 Nov 2003 01:58:13 -0500

CVSROOT:        /cvsroot/giftcurs
Module name:    giFTcurs
Branch:         
Changes by:     Christian Häggström <address@hidden>    03/11/04 01:58:13

Modified files:
        src            : parse.c 
Added files:
        src            : wcwidth.c 

Log message:
        Use Markus Kuhn's wcwidth implementation to determine how UTF-8 look on 
screen

Patches:
Index: giFTcurs/src/parse.c
diff -u giFTcurs/src/parse.c:1.150 giFTcurs/src/parse.c:1.151
--- giFTcurs/src/parse.c:1.150  Fri Oct 31 19:11:33 2003
+++ giFTcurs/src/parse.c        Tue Nov  4 01:58:12 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: parse.c,v 1.150 2003/11/01 00:11:33 saturn Exp $
+ * $Id: parse.c,v 1.151 2003/11/04 06:58:12 saturn Exp $
  */
 #include "giftcurs.h"
 
@@ -34,10 +34,6 @@
 # include <locale.h>
 #endif
 
-#if 1 //def WIDE_NCURSES
-# include <wchar.h>
-#endif
-
 #include "parse.h"
 
 gboolean utf8;
@@ -346,6 +342,9 @@
        return str;
 }
 
+#ifdef WIDE_NCURSES
+# include "wcwidth.c"
+
 /* Visual strlen(). */
 glong vstrlen(const char *str)
 {
@@ -353,10 +352,20 @@
                const char *p;
                int len;
 
+               /* g_unichar_iswide does not detect combining characters */
+               /* FIXME: We couldn't get mbrtowc/wcwidth to work. If anybody
+                *        know how to do with them, contact us.
+                */
                for (p = str, len = 0; *p; p = g_utf8_next_char(p))
-                       len += g_unichar_iswide(g_utf8_get_char(p)) ? 2 : 1;
+                       len += mk_wcwidth(g_utf8_get_char(p));
                return len;
        } else {
                return strlen(str);
        }
 }
+#else
+glong vstrlen(const char *str)
+{
+       return strlen(str);
+}
+#endif




reply via email to

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