Also remove bogus guard: we cannot use waddch for a multi-byte character
(EUC-JP comes to mind).
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
keypad(stdscr, TRUE);
curs_set(0);
ESCDELAY=50;
keypad(stdscr, TRUE);
curs_set(0);
ESCDELAY=50;
+ madtty_init_vt100_graphics();
madtty_init_colors();
getmaxyx(stdscr, screen_h, screen_w);
madtty_init_colors();
getmaxyx(stdscr, screen_h, screen_w);
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
-static int has_default = 0;
+static int has_default, is_utf8;
static void is_utf8_locale(void)
{
static void is_utf8_locale(void)
{
- const char *l = getenv("LANG");
- if (l)
- is_utf8 = (strstr(l, "UTF-8") != NULL);
+ const char *cset = nl_langinfo(CODESET) ?: "ANSI_X3.4-1968";
+ is_utf8 = !strcmp(cset, "UTF-8");
}
// vt100 special graphics and line drawing
}
// vt100 special graphics and line drawing
if (t->graphmode) {
if (wc >= 0x41 && wc <= 0x7e) {
if (t->graphmode) {
if (wc >= 0x41 && wc <= 0x7e) {
- if(is_utf8 && vt100_utf8[wc - 0x41])
- wc = vt100_utf8[wc - 0x41];
- else if(!is_utf8 && vt100[wc - 0x41])
- wc = vt100[wc - 0x41];
+ wchar_t gc = is_utf8 ? vt100_utf8[wc - 0x41] : vt100[wc - 0x41];
+ if (gc)
+ wc = gc;
for (int j = 0; j < t->cols; j++) {
if (!j || row->attr[j] != row->attr[j - 1])
wattrset(win, (attr_t)row->attr[j] << NCURSES_ATTR_SHIFT);
for (int j = 0; j < t->cols; j++) {
if (!j || row->attr[j] != row->attr[j - 1])
wattrset(win, (attr_t)row->attr[j] << NCURSES_ATTR_SHIFT);
- if (is_utf8 && row->text[j] >= 128) {
+ if (row->text[j] >= 128) {
char buf[MB_CUR_MAX + 1];
int len;
char buf[MB_CUR_MAX + 1];
int len;
fg == COLOR_WHITE ? -1 : fg,
bg == COLOR_BLACK ? -1 : bg);
} else {
fg == COLOR_WHITE ? -1 : fg,
bg == COLOR_BLACK ? -1 : bg);
} else {
- init_pair((7 - fg) * 8 + bg, fg, bg);
+ init_pair((7 - fg) * 8 + bg, fg, bg);
+ }
}
int madtty_color_pair(int fg, int bg)
}
int madtty_color_pair(int fg, int bg)
#include <unistd.h>
#include <wchar.h>
#include <unistd.h>
#include <wchar.h>
+typedef struct madtty_t madtty_t;
+
void madtty_init_colors(void);
void madtty_init_colors(void);
-int madtty_color_pair(int fg, int bg);
void madtty_init_vt100_graphics(void);
void madtty_init_vt100_graphics(void);
-typedef struct madtty_t madtty_t;
+int madtty_color_pair(int fg, int bg);
madtty_t *madtty_create(int rows, int cols);
void madtty_resize(madtty_t *, int rows, int cols);
madtty_t *madtty_create(int rows, int cols);
void madtty_resize(madtty_t *, int rows, int cols);