diff options
| author | LemonBoy <thatlemon@gmail.com> | 2015-03-18 21:12:47 +0100 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2015-03-19 05:36:54 +0000 |
| commit | 580302f3179ef3f24cf0329755686dfa7100996b (patch) | |
| tree | 4915df8f3ca36285f6b87724fc71e7c5718a5b69 | |
| parent | 86d1e432a823dad7bb64808b8192014fddc8cd9f (diff) | |
| download | st-580302f3179ef3f24cf0329755686dfa7100996b.tar.gz st-580302f3179ef3f24cf0329755686dfa7100996b.zip | |
Support the DECSCUSR CSI escape sequence
| -rw-r--r-- | st.c | 62 |
1 files changed, 49 insertions, 13 deletions
| @@ -197,14 +197,14 @@ typedef struct { | |||
| 197 | } TCursor; | 197 | } TCursor; |
| 198 | 198 | ||
| 199 | /* CSI Escape sequence structs */ | 199 | /* CSI Escape sequence structs */ |
| 200 | /* ESC '[' [[ [<priv>] <arg> [;]] <mode>] */ | 200 | /* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */ |
| 201 | typedef struct { | 201 | typedef struct { |
| 202 | char buf[ESC_BUF_SIZ]; /* raw string */ | 202 | char buf[ESC_BUF_SIZ]; /* raw string */ |
| 203 | int len; /* raw string length */ | 203 | int len; /* raw string length */ |
| 204 | char priv; | 204 | char priv; |
| 205 | int arg[ESC_ARG_SIZ]; | 205 | int arg[ESC_ARG_SIZ]; |
| 206 | int narg; /* nb of args */ | 206 | int narg; /* nb of args */ |
| 207 | char mode; | 207 | char mode[2]; |
| 208 | } CSIEscape; | 208 | } CSIEscape; |
| 209 | 209 | ||
| 210 | /* STR Escape sequence structs */ | 210 | /* STR Escape sequence structs */ |
| @@ -257,6 +257,7 @@ typedef struct { | |||
| 257 | int ch; /* char height */ | 257 | int ch; /* char height */ |
| 258 | int cw; /* char width */ | 258 | int cw; /* char width */ |
| 259 | char state; /* focus, redraw, visible */ | 259 | char state; /* focus, redraw, visible */ |
| 260 | int cursor; /* cursor style */ | ||
| 260 | } XWindow; | 261 | } XWindow; |
| 261 | 262 | ||
| 262 | typedef struct { | 263 | typedef struct { |
| @@ -1545,7 +1546,8 @@ csiparse(void) { | |||
| 1545 | break; | 1546 | break; |
| 1546 | p++; | 1547 | p++; |
| 1547 | } | 1548 | } |
| 1548 | csiescseq.mode = *p; | 1549 | csiescseq.mode[0] = *p++; |
| 1550 | csiescseq.mode[1] = (p < csiescseq.buf+csiescseq.len) ? *p : '\0'; | ||
| 1549 | } | 1551 | } |
| 1550 | 1552 | ||
| 1551 | /* for absolute user moves, when decom is set */ | 1553 | /* for absolute user moves, when decom is set */ |
| @@ -1983,7 +1985,7 @@ csihandle(void) { | |||
| 1983 | char buf[40]; | 1985 | char buf[40]; |
| 1984 | int len; | 1986 | int len; |
| 1985 | 1987 | ||
| 1986 | switch(csiescseq.mode) { | 1988 | switch(csiescseq.mode[0]) { |
| 1987 | default: | 1989 | default: |
| 1988 | unknown: | 1990 | unknown: |
| 1989 | fprintf(stderr, "erresc: unknown csi "); | 1991 | fprintf(stderr, "erresc: unknown csi "); |
| @@ -2171,6 +2173,19 @@ csihandle(void) { | |||
| 2171 | case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */ | 2173 | case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */ |
| 2172 | tcursor(CURSOR_LOAD); | 2174 | tcursor(CURSOR_LOAD); |
| 2173 | break; | 2175 | break; |
| 2176 | case ' ': | ||
| 2177 | switch (csiescseq.mode[1]) { | ||
| 2178 | case 'q': /* DECSCUSR -- Set Cursor Style */ | ||
| 2179 | DEFAULT(csiescseq.arg[0], 1); | ||
| 2180 | if (!BETWEEN(csiescseq.arg[0], 0, 6)) { | ||
| 2181 | goto unknown; | ||
| 2182 | } | ||
| 2183 | xw.cursor = csiescseq.arg[0]; | ||
| 2184 | break; | ||
| 2185 | default: | ||
| 2186 | goto unknown; | ||
| 2187 | } | ||
| 2188 | break; | ||
| 2174 | } | 2189 | } |
| 2175 | } | 2190 | } |
| 2176 | 2191 | ||
| @@ -3551,16 +3566,36 @@ xdrawcursor(void) { | |||
| 3551 | 3566 | ||
| 3552 | /* draw the new one */ | 3567 | /* draw the new one */ |
| 3553 | if(xw.state & WIN_FOCUSED) { | 3568 | if(xw.state & WIN_FOCUSED) { |
| 3554 | if(IS_SET(MODE_REVERSE)) { | 3569 | switch (xw.cursor) { |
| 3555 | g.mode |= ATTR_REVERSE; | 3570 | case 0: /* Blinking Block */ |
| 3556 | g.fg = defaultcs; | 3571 | case 1: /* Blinking Block (Default) */ |
| 3557 | g.bg = defaultfg; | 3572 | case 2: /* Steady Block */ |
| 3558 | } | 3573 | if(IS_SET(MODE_REVERSE)) { |
| 3574 | g.mode |= ATTR_REVERSE; | ||
| 3575 | g.fg = defaultcs; | ||
| 3576 | g.bg = defaultfg; | ||
| 3577 | } | ||
| 3559 | 3578 | ||
| 3560 | sl = utf8len(g.c); | 3579 | sl = utf8len(g.c); |
| 3561 | width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ | 3580 | width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ |
| 3562 | ? 2 : 1; | 3581 | ? 2 : 1; |
| 3563 | xdraws(g.c, g, term.c.x, term.c.y, width, sl); | 3582 | xdraws(g.c, g, term.c.x, term.c.y, width, sl); |
| 3583 | break; | ||
| 3584 | case 3: /* Blinking Underline */ | ||
| 3585 | case 4: /* Steady Underline */ | ||
| 3586 | XftDrawRect(xw.draw, &dc.col[defaultcs], | ||
| 3587 | borderpx + curx * xw.cw, | ||
| 3588 | borderpx + (term.c.y + 1) * xw.ch - 1, | ||
| 3589 | xw.cw, 1); | ||
| 3590 | break; | ||
| 3591 | case 5: /* Blinking bar */ | ||
| 3592 | case 6: /* Steady bar */ | ||
| 3593 | XftDrawRect(xw.draw, &dc.col[defaultcs], | ||
| 3594 | borderpx + curx * xw.cw, | ||
| 3595 | borderpx + term.c.y * xw.ch, | ||
| 3596 | 1, xw.ch); | ||
| 3597 | break; | ||
| 3598 | } | ||
| 3564 | } else { | 3599 | } else { |
| 3565 | XftDrawRect(xw.draw, &dc.col[defaultcs], | 3600 | XftDrawRect(xw.draw, &dc.col[defaultcs], |
| 3566 | borderpx + curx * xw.cw, | 3601 | borderpx + curx * xw.cw, |
| @@ -3985,6 +4020,7 @@ main(int argc, char *argv[]) { | |||
| 3985 | 4020 | ||
| 3986 | xw.l = xw.t = 0; | 4021 | xw.l = xw.t = 0; |
| 3987 | xw.isfixed = False; | 4022 | xw.isfixed = False; |
| 4023 | xw.cursor = 0; | ||
| 3988 | 4024 | ||
| 3989 | ARGBEGIN { | 4025 | ARGBEGIN { |
| 3990 | case 'a': | 4026 | case 'a': |
