vt: track charsets G0-G3 and support either ASCII or graphical mode

This commit is contained in:
Daniel Eklöf 2019-07-04 19:17:18 +02:00
parent dd5a3b1009
commit ea6e06d689
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 12 additions and 15 deletions

View file

@ -126,6 +126,7 @@ struct kbd {
enum decckm { DECCKM_CSI, DECCKM_SS3 };
enum keypad_mode { KEYPAD_NUMERICAL, KEYPAD_APPLICATION };
enum charset { CHARSET_ASCII, CHARSET_GRAPHIC };
struct terminal {
pid_t slave;
@ -138,6 +139,9 @@ struct terminal {
bool insert_mode;
bool bracketed_paste;
int selected_charset;
enum charset charset[4]; /* G0-G3 */
struct vt vt;
struct kbd kbd;

23
vt.c
View file

@ -572,15 +572,10 @@ esc_dispatch(struct terminal *term, uint8_t final)
char param = term->vt.params.idx > 0 ? term->vt.params.v[0].value : '(';
switch (param) {
case '(':
/* This is the default charset */
break;
case ')':
case '*':
case '+':
LOG_WARN("unimplemented: charset %c uses ASCII", param);
return false;
case '(': term->charset[0] = CHARSET_ASCII; break;
case ')': term->charset[1] = CHARSET_ASCII; break;
case '*': term->charset[2] = CHARSET_ASCII; break;
case '+': term->charset[3] = CHARSET_ASCII; break;
default:
LOG_ERR("<ESC>%cB: invalid charset identifier", param);
@ -594,12 +589,10 @@ esc_dispatch(struct terminal *term, uint8_t final)
char param = term->vt.params.idx > 0 ? term->vt.params.v[0].value : '(';
switch (param) {
case '(':
case ')':
case '*':
case '+':
LOG_WARN("unimplemented: charset %c uses special characters and line drawings", param);
break;
case '(': term->charset[0] = CHARSET_GRAPHIC; break;
case ')': term->charset[1] = CHARSET_GRAPHIC; break;
case '*': term->charset[2] = CHARSET_GRAPHIC; break;
case '+': term->charset[3] = CHARSET_GRAPHIC; break;
default:
LOG_ERR("<ESC>%c0: invalid charset identifier", param);