[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[giFTcurs-commits] giFTcurs/src ui_draw.c
From: |
Göran Weinholt |
Subject: |
[giFTcurs-commits] giFTcurs/src ui_draw.c |
Date: |
Tue, 04 Nov 2003 18:29:45 -0500 |
CVSROOT: /cvsroot/giftcurs
Module name: giFTcurs
Branch:
Changes by: Göran Weinholt <address@hidden> 03/11/04 18:29:45
Modified files:
src : ui_draw.c
Log message:
Draw wide characters with add_wch(), and calculate the width of what
we've drawn with mk_wcwidth().
Patches:
Index: giFTcurs/src/ui_draw.c
diff -u giFTcurs/src/ui_draw.c:1.113 giFTcurs/src/ui_draw.c:1.114
--- giFTcurs/src/ui_draw.c:1.113 Fri Oct 31 19:11:33 2003
+++ giFTcurs/src/ui_draw.c Tue Nov 4 18:29:45 2003
@@ -18,10 +18,11 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_draw.c,v 1.113 2003/11/01 00:11:33 saturn Exp $
+ * $Id: ui_draw.c,v 1.114 2003/11/04 23:29:45 weinholt Exp $
*/
#include "giftcurs.h"
+#include <wchar.h>
#include <string.h>
#include "parse.h"
@@ -30,6 +31,7 @@
#include "ui_draw.h"
#include "ui.h"
#include "tree.h"
+#include "wcwidth.h"
void draw_box(int x, int y, int w, int h, const char *title, int attr)
{
@@ -164,26 +166,30 @@
}
/* No printing control-chars here */
- if ((unsigned char) *u < 32 || ((unsigned char) *u >= 0x7f &&
(unsigned char) *u < 0xa0))
+ if ((unsigned char) *u < 32 || ((unsigned char) *u >= 0x7f &&
(unsigned char) *u < 0xa0)) {
addch(' ');
- else {
+ printed++;
+ } else {
if (utf8) {
+#ifdef WIDE_NCURSES
/* Get a unicode character from the next few
bytes. */
- gunichar c = g_utf8_get_char_validated(u, -1);
- gchar *nextc;
+ wchar_t wch[2];
+ cchar_t cc;
- if (c < 0)
- break; /* invalid utf-8
sequence */
- if (g_unichar_iswide(c))
- printed++; /* two chars wide */
- nextc = g_utf8_next_char(u);
- addnstr(u, nextc - u);
- u = nextc - 1;
+ wch[0] = g_utf8_get_char_validated(u, -1);
+ wch[1] = L'\0';
+ if (wch[0] < 0)
+ continue; /* invalid
utf-8 sequence */
+ setcchar(&cc, wch, A_NORMAL, 0, NULL);
+ add_wch(&cc);
+ printed += mk_wcwidth(wch[0]);
+ u = g_utf8_next_char(u) - 1;
+#endif
} else {
addnstr(u, 1);
+ printed++;
}
}
- printed++;
}
hline(' ', w - printed);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [giFTcurs-commits] giFTcurs/src ui_draw.c,
Göran Weinholt <=