X-Git-Url: https://jasonwoof.com/gitweb/?p=st.git;a=blobdiff_plain;f=st.c;h=0c917fd4a2d6cff6db69fbbab5e063cc39c12792;hp=77ae26ed2b31cb5da063b02663f6a290ba07a055;hb=b4dfa18124451f9ee29a0719ef36ffd58fae4477;hpb=bcbaf5d9beb72f29d228d103634d648ca28fb48d diff --git a/st.c b/st.c index 77ae26e..0c917fd 100644 --- a/st.c +++ b/st.c @@ -89,7 +89,7 @@ char *argv0; #define VT102ID "\033[?6c" enum glyph_attribute { - ATTR_NULL = 0, + ATTR_NULL = 0, ATTR_BOLD = 1, ATTR_FAINT = 2, ATTR_ITALIC = 4, @@ -405,6 +405,7 @@ static void ttyread(void); static void ttyresize(void); static void ttysend(char *, size_t); static void ttywrite(const char *, size_t); +static void tstrsequence(uchar c); static void xdraws(char *, Glyph, int, int, int, int); static void xhints(void); @@ -1717,11 +1718,8 @@ tsetattr(int *attr, int l) { case 9: term.c.attr.mode |= ATTR_STRUCK; break; - case 21: - term.c.attr.mode &= ~ATTR_BOLD; - break; case 22: - term.c.attr.mode &= ~ATTR_FAINT; + term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT); break; case 23: term.c.attr.mode &= ~ATTR_ITALIC; @@ -1730,10 +1728,7 @@ tsetattr(int *attr, int l) { term.c.attr.mode &= ~ATTR_UNDERLINE; break; case 25: - term.c.attr.mode &= ~ATTR_BLINK; - break; - case 26: - term.c.attr.mode &= ~ATTR_FASTBLINK; + term.c.attr.mode &= ~(ATTR_BLINK | ATTR_FASTBLINK); break; case 27: term.c.attr.mode &= ~ATTR_REVERSE; @@ -2348,6 +2343,30 @@ tdeftran(char ascii) { } void +tstrsequence(uchar c) { + if (c & 0x80) { + switch (c) { + case 0x90: /* DCS -- Device Control String */ + c = 'P'; + break; + case 0x9f: /* APC -- Application Program Command */ + c = '_'; + break; + case 0x9e: /* PM -- Privacy Message */ + c = '^'; + break; + case 0x9d: /* OSC -- Operating System Command */ + c = ']'; + break; + } + } + strreset(); + strescseq.type = c; + term.esc |= ESC_STR; + return; +} + +void tcontrolcode(uchar ascii) { static char question[UTF_SIZ] = "?"; @@ -2401,12 +2420,16 @@ tcontrolcode(uchar ascii) { case 0177: /* DEL (IGNORED) */ return; case 0x84: /* TODO: IND */ - case 0x85: /* TODO: NEL */ - case 0x88: /* TODO: HTS */ + break; + case 0x85: /* NEL -- Next line */ + tnewline(1); /* always go to first col */ + break; + case 0x88: /* HTS -- Horizontal tab stop */ + term.tabs[term.c.x] = 1; + break; case 0x8d: /* TODO: RI */ case 0x8e: /* TODO: SS2 */ case 0x8f: /* TODO: SS3 */ - case 0x90: /* TODO: DCS */ case 0x98: /* TODO: SOS */ break; case 0x9a: /* DECID -- Identify Terminal */ @@ -2414,10 +2437,13 @@ tcontrolcode(uchar ascii) { break; case 0x9b: /* TODO: CSI */ case 0x9c: /* TODO: ST */ - case 0x9d: /* TODO: OSC */ - case 0x9e: /* TODO: PM */ - case 0x9f: /* TODO: APC */ break; + case 0x90: /* DCS -- Device Control String */ + case 0x9f: /* APC -- Application Program Command */ + case 0x9e: /* PM -- Privacy Message */ + case 0x9d: /* OSC -- Operating System Command */ + tstrsequence(ascii); + return; } /* only CAN, SUB, \a and C1 chars interrupt a sequence */ term.esc &= ~(ESC_STR_END|ESC_STR); @@ -2533,9 +2559,7 @@ tputc(char *c, int len) { case '^': /* PM -- Privacy Message */ case ']': /* OSC -- Operating System Command */ case 'k': /* old title set compatibility */ - strreset(); - strescseq.type = ascii; - term.esc |= ESC_STR; + tstrsequence(ascii); return; case '(': /* set primary charset G0 */ case ')': /* set secondary charset G1 */ @@ -3756,6 +3780,8 @@ run(void) { /* Waiting for window mapping */ while(1) { XNextEvent(xw.dpy, &ev); + if(XFilterEvent(&ev, None)) + continue; if(ev.type == ConfigureNotify) { w = ev.xconfigure.width; h = ev.xconfigure.height;