diff --git a/qe.c b/qe.c index 602c9f7..f22f7f0 100644 --- a/qe.c +++ b/qe.c @@ -2898,8 +2898,7 @@ int text_display(EditState *s, DisplayState *ds, int offset) } else if (c >= 0x10000) { /* currently, we cannot display these chars */ display_printf(ds, offset0, offset, "\\U%08x", c); - } else if ((c >= 128 && c < 128 + 32) || - (s->screen->charset != &charset_utf8 && c >= 256)) { + } else if (c >= 256 && s->screen->charset != &charset_utf8) { display_printf(ds, offset0, offset, "\\u%04x", c); } else { if (char_index < colored_nb_chars) diff --git a/shell.c b/shell.c index e7597a0..6f1039c 100644 --- a/shell.c +++ b/shell.c @@ -42,6 +42,7 @@ static ModeDef shell_mode; enum TTYState { TTY_STATE_NORM, TTY_STATE_ESC, + TTY_STATE_ESC2, TTY_STATE_CSI, }; @@ -54,6 +55,7 @@ typedef struct ShellState { int esc_params[MAX_ESC_PARAMS]; int nb_esc_params; int state; + int esc1; int shifted; EditBuffer *b; EditBuffer *b_color; /* color buffer, one byte per char */ @@ -302,11 +304,9 @@ static void tty_emulate(ShellState *s, int c) } break; case 14: - //eb_set_charset(s->b, &charset_8859_1); s->shifted = 1; break; case 15: - //eb_set_charset(s->b, &charset_cp1125); s->shifted = 0; break; case 27: @@ -315,6 +315,7 @@ static void tty_emulate(ShellState *s, int c) default: if (c >= 32 || c == 9) { int c1, cur_len, len; + /* CG: assuming ISO-8859-1 characters */ /* CG: horrible kludge for alternate charset support */ if (s->shifted && c >= 96 && c < 128) c += 32; @@ -346,9 +347,56 @@ static void tty_emulate(ShellState *s, int c) s->nb_esc_params = 0; s->state = TTY_STATE_CSI; } else { - s->state = TTY_STATE_NORM; + /* CG: should deal with other sequences: + * ansi: hts=\EH, s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B, + * linux: hts=\EH, rc=\E8, ri=\EM, rs1=\Ec\E]R, sc=\E7, + * vt100: enacs=\E(B\E)0, hts=\EH, rc=\E8, ri=\EM$<5>, + * rmkx=\E[?1l\E>, + * rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, + * smkx=\E[?1h\E=, + * xterm: enacs=\E(B\E)0, hts=\EH, is2=\E[!p\E[?3;4l\E[4l\E>, + * rc=\E8, ri=\EM, rmkx=\E[?1l\E>, rs1=\Ec, + * rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, smkx=\E[?1h\E=, + */ + switch (c) { + case '(': + case ')': + case '*': + case '+': + case ']': + s->esc1 = c; + s->state = TTY_STATE_ESC2; + break; + case 'H': // hts + case '7': // sc + case '8': // rc + case 'M': // ri + case 'c': // rs1 + case '>': // rmkx, is2, rs2 + case '=': // smkx + // XXX: do these + default: + s->state = TTY_STATE_NORM; + break; + } } break; + case TTY_STATE_ESC2: + s->state = TTY_STATE_NORM; +#define ESC2(c1,c2) (((c1)<<8)|((unsigned char)c2)) + switch (ESC2(s->esc1, c)) { + case ESC2('(','B'): + case ESC2(')','B'): + case ESC2('(','0'): + case ESC2(')','0'): + case ESC2('*','B'): + case ESC2('+','B'): + case ESC2(']','R'): + /* XXX: ??? */ + break; + } +#undef ESC2 + break; case TTY_STATE_CSI: if (c >= '0' && c <= '9') { if (s->nb_esc_params < MAX_ESC_PARAMS) { diff --git a/tty.c b/tty.c index 255f80b..7360e68 100644 --- a/tty.c +++ b/tty.c @@ -121,6 +121,7 @@ static int term_init(QEditScreen *s, int w, int h) } } #endif + printf("\033)0\033(B\017"); /* select character sets in block 0 and 1 */ atexit(term_exit);