}
}
+bool is_utf8 = true;
+
+static void is_utf8_locale(void)
+{
+ const char *l = getenv("LANG");
+ if (l)
+ is_utf8 = (strstr(l, "UTF-8") != NULL);
+}
+
// vt100 special graphics and line drawing
// 5f-7e standard vt100
// 40-5e rxvt extension for extra curses acs chars
-static uint16_t const vt100_0[62] = { // 41 .. 7e
+static uint16_t const vt100_utf8[62] = { // 41 .. 7e
0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603, // 41-47 hi mr. snowman!
0, 0, 0, 0, 0, 0, 0, 0, // 48-4f
0, 0, 0, 0, 0, 0, 0, 0, // 50-57
0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, // 78-7e
};
+static uint32_t vt100[62];
+
+void madtty_init_vt100_graphics(void)
+{
+ vt100['l' - 0x41] = ACS_ULCORNER;
+ vt100['m' - 0x41] = ACS_LLCORNER;
+ vt100['k' - 0x41] = ACS_URCORNER;
+ vt100['j' - 0x41] = ACS_LRCORNER;
+ vt100['u' - 0x41] = ACS_RTEE;
+ vt100['t' - 0x41] = ACS_LTEE;
+ vt100['v' - 0x41] = ACS_TTEE;
+ vt100['w' - 0x41] = ACS_BTEE;
+ vt100['q' - 0x41] = ACS_HLINE;
+ vt100['x' - 0x41] = ACS_VLINE;
+ vt100['n' - 0x41] = ACS_PLUS;
+ vt100['o' - 0x41] = ACS_S1;
+ vt100['s' - 0x41] = ACS_S9;
+ vt100['`' - 0x41] = ACS_DIAMOND;
+ vt100['a' - 0x41] = ACS_CKBOARD;
+ vt100['f' - 0x41] = ACS_DEGREE;
+ vt100['g' - 0x41] = ACS_PLMINUS;
+ vt100['~' - 0x41] = ACS_BULLET;
+ vt100[',' - 0x41] = ACS_LARROW;
+ vt100['+' - 0x41] = ACS_RARROW;
+ vt100['.' - 0x41] = ACS_DARROW;
+ vt100['-' - 0x41] = ACS_UARROW;
+ vt100['h' - 0x41] = ACS_BOARD;
+ vt100['i' - 0x41] = ACS_LANTERN;
+ vt100['0' - 0x41] = ACS_BLOCK;
+ /* these defaults were invented for ncurses */
+ vt100['p' - 0x41] = ACS_S3;
+ vt100['r' - 0x41] = ACS_S7;
+ vt100['y' - 0x41] = ACS_LEQUAL;
+ vt100['z' - 0x41] = ACS_GEQUAL;
+ vt100['{' - 0x41] = ACS_PI;
+ vt100['|' - 0x41] = ACS_NEQUAL;
+ vt100['}' - 0x41] = ACS_STERLING;
+ is_utf8_locale();
+}
+
static void madtty_putc(madtty_t *t, wchar_t wc)
{
int width = 0;
t_row_t *tmp;
if (t->graphmode) {
- if (wc >= 0x41 && wc <= 0x7e && vt100_0[wc - 0x41]) {
- wc = vt100_0[wc - 0x41];
+ 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];
}
width = 1;
} else {
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 (row->text[j] >= 128) {
+ if (is_utf8 && row->text[j] >= 128) {
char buf[MB_CUR_MAX + 1];
int len;