|
|
@ -51,7 +51,6 @@ enum term_mode {
|
|
|
|
MODE_ECHO = 1 << 4,
|
|
|
|
MODE_ECHO = 1 << 4,
|
|
|
|
MODE_PRINT = 1 << 5,
|
|
|
|
MODE_PRINT = 1 << 5,
|
|
|
|
MODE_UTF8 = 1 << 6,
|
|
|
|
MODE_UTF8 = 1 << 6,
|
|
|
|
MODE_SIXEL = 1 << 7,
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum cursor_movement {
|
|
|
|
enum cursor_movement {
|
|
|
@ -78,12 +77,11 @@ enum charset {
|
|
|
|
enum escape_state {
|
|
|
|
enum escape_state {
|
|
|
|
ESC_START = 1,
|
|
|
|
ESC_START = 1,
|
|
|
|
ESC_CSI = 2,
|
|
|
|
ESC_CSI = 2,
|
|
|
|
ESC_STR = 4, /* OSC, PM, APC */
|
|
|
|
ESC_STR = 4, /* DCS, OSC, PM, APC */
|
|
|
|
ESC_ALTCHARSET = 8,
|
|
|
|
ESC_ALTCHARSET = 8,
|
|
|
|
ESC_STR_END = 16, /* a final string was encountered */
|
|
|
|
ESC_STR_END = 16, /* a final string was encountered */
|
|
|
|
ESC_TEST = 32, /* Enter in test mode */
|
|
|
|
ESC_TEST = 32, /* Enter in test mode */
|
|
|
|
ESC_UTF8 = 64,
|
|
|
|
ESC_UTF8 = 64,
|
|
|
|
ESC_DCS =128,
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
typedef struct {
|
|
|
@ -2090,12 +2088,9 @@ tdectest(char c)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
tstrsequence(uchar c)
|
|
|
|
tstrsequence(uchar c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
strreset();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
switch (c) {
|
|
|
|
case 0x90: /* DCS -- Device Control String */
|
|
|
|
case 0x90: /* DCS -- Device Control String */
|
|
|
|
c = 'P';
|
|
|
|
c = 'P';
|
|
|
|
term.esc |= ESC_DCS;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 0x9f: /* APC -- Application Program Command */
|
|
|
|
case 0x9f: /* APC -- Application Program Command */
|
|
|
|
c = '_';
|
|
|
|
c = '_';
|
|
|
@ -2107,6 +2102,7 @@ tstrsequence(uchar c)
|
|
|
|
c = ']';
|
|
|
|
c = ']';
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strreset();
|
|
|
|
strescseq.type = c;
|
|
|
|
strescseq.type = c;
|
|
|
|
term.esc |= ESC_STR;
|
|
|
|
term.esc |= ESC_STR;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2304,7 +2300,7 @@ tputc(Rune u)
|
|
|
|
Glyph *gp;
|
|
|
|
Glyph *gp;
|
|
|
|
|
|
|
|
|
|
|
|
control = ISCONTROL(u);
|
|
|
|
control = ISCONTROL(u);
|
|
|
|
if (u < 127 || !IS_SET(MODE_UTF8 | MODE_SIXEL)) {
|
|
|
|
if (u < 127 || !IS_SET(MODE_UTF8)) {
|
|
|
|
c[0] = u;
|
|
|
|
c[0] = u;
|
|
|
|
width = len = 1;
|
|
|
|
width = len = 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -2325,23 +2321,11 @@ tputc(Rune u)
|
|
|
|
if (term.esc & ESC_STR) {
|
|
|
|
if (term.esc & ESC_STR) {
|
|
|
|
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
|
|
|
|
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
|
|
|
|
ISCONTROLC1(u)) {
|
|
|
|
ISCONTROLC1(u)) {
|
|
|
|
term.esc &= ~(ESC_START|ESC_STR|ESC_DCS);
|
|
|
|
term.esc &= ~(ESC_START|ESC_STR);
|
|
|
|
if (IS_SET(MODE_SIXEL)) {
|
|
|
|
|
|
|
|
/* TODO: render sixel */;
|
|
|
|
|
|
|
|
term.mode &= ~MODE_SIXEL;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
term.esc |= ESC_STR_END;
|
|
|
|
term.esc |= ESC_STR_END;
|
|
|
|
goto check_control_code;
|
|
|
|
goto check_control_code;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_SET(MODE_SIXEL)) {
|
|
|
|
|
|
|
|
/* TODO: implement sixel mode */
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
|
|
|
|
|
|
|
|
term.mode |= MODE_SIXEL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strescseq.len+len >= strescseq.siz) {
|
|
|
|
if (strescseq.len+len >= strescseq.siz) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Here is a bug in terminals. If the user never sends
|
|
|
|
* Here is a bug in terminals. If the user never sends
|
|
|
@ -2453,7 +2437,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
|
|
|
|
int n;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < buflen; n += charsize) {
|
|
|
|
for (n = 0; n < buflen; n += charsize) {
|
|
|
|
if (IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
|
|
|
|
if (IS_SET(MODE_UTF8)) {
|
|
|
|
/* process a complete utf8 char */
|
|
|
|
/* process a complete utf8 char */
|
|
|
|
charsize = utf8decode(buf + n, &u, buflen - n);
|
|
|
|
charsize = utf8decode(buf + n, &u, buflen - n);
|
|
|
|
if (charsize == 0)
|
|
|
|
if (charsize == 0)
|
|
|
|