Support the DECSCUSR CSI escape sequence

master
LemonBoy 2015-03-18 21:12:47 +01:00 committed by Roberto E. Vargas Caballero
parent 86d1e432a8
commit 580302f317
1 changed files with 49 additions and 13 deletions

44
st.c
View File

@ -197,14 +197,14 @@ typedef struct {
} TCursor; } TCursor;
/* CSI Escape sequence structs */ /* CSI Escape sequence structs */
/* ESC '[' [[ [<priv>] <arg> [;]] <mode>] */ /* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
typedef struct { typedef struct {
char buf[ESC_BUF_SIZ]; /* raw string */ char buf[ESC_BUF_SIZ]; /* raw string */
int len; /* raw string length */ int len; /* raw string length */
char priv; char priv;
int arg[ESC_ARG_SIZ]; int arg[ESC_ARG_SIZ];
int narg; /* nb of args */ int narg; /* nb of args */
char mode; char mode[2];
} CSIEscape; } CSIEscape;
/* STR Escape sequence structs */ /* STR Escape sequence structs */
@ -257,6 +257,7 @@ typedef struct {
int ch; /* char height */ int ch; /* char height */
int cw; /* char width */ int cw; /* char width */
char state; /* focus, redraw, visible */ char state; /* focus, redraw, visible */
int cursor; /* cursor style */
} XWindow; } XWindow;
typedef struct { typedef struct {
@ -1545,7 +1546,8 @@ csiparse(void) {
break; break;
p++; p++;
} }
csiescseq.mode = *p; csiescseq.mode[0] = *p++;
csiescseq.mode[1] = (p < csiescseq.buf+csiescseq.len) ? *p : '\0';
} }
/* for absolute user moves, when decom is set */ /* for absolute user moves, when decom is set */
@ -1983,7 +1985,7 @@ csihandle(void) {
char buf[40]; char buf[40];
int len; int len;
switch(csiescseq.mode) { switch(csiescseq.mode[0]) {
default: default:
unknown: unknown:
fprintf(stderr, "erresc: unknown csi "); fprintf(stderr, "erresc: unknown csi ");
@ -2171,6 +2173,19 @@ csihandle(void) {
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */ case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
tcursor(CURSOR_LOAD); tcursor(CURSOR_LOAD);
break; break;
case ' ':
switch (csiescseq.mode[1]) {
case 'q': /* DECSCUSR -- Set Cursor Style */
DEFAULT(csiescseq.arg[0], 1);
if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
goto unknown;
}
xw.cursor = csiescseq.arg[0];
break;
default:
goto unknown;
}
break;
} }
} }
@ -3551,6 +3566,10 @@ xdrawcursor(void) {
/* draw the new one */ /* draw the new one */
if(xw.state & WIN_FOCUSED) { if(xw.state & WIN_FOCUSED) {
switch (xw.cursor) {
case 0: /* Blinking Block */
case 1: /* Blinking Block (Default) */
case 2: /* Steady Block */
if(IS_SET(MODE_REVERSE)) { if(IS_SET(MODE_REVERSE)) {
g.mode |= ATTR_REVERSE; g.mode |= ATTR_REVERSE;
g.fg = defaultcs; g.fg = defaultcs;
@ -3561,6 +3580,22 @@ xdrawcursor(void) {
width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\
? 2 : 1; ? 2 : 1;
xdraws(g.c, g, term.c.x, term.c.y, width, sl); xdraws(g.c, g, term.c.x, term.c.y, width, sl);
break;
case 3: /* Blinking Underline */
case 4: /* Steady Underline */
XftDrawRect(xw.draw, &dc.col[defaultcs],
borderpx + curx * xw.cw,
borderpx + (term.c.y + 1) * xw.ch - 1,
xw.cw, 1);
break;
case 5: /* Blinking bar */
case 6: /* Steady bar */
XftDrawRect(xw.draw, &dc.col[defaultcs],
borderpx + curx * xw.cw,
borderpx + term.c.y * xw.ch,
1, xw.ch);
break;
}
} else { } else {
XftDrawRect(xw.draw, &dc.col[defaultcs], XftDrawRect(xw.draw, &dc.col[defaultcs],
borderpx + curx * xw.cw, borderpx + curx * xw.cw,
@ -3985,6 +4020,7 @@ main(int argc, char *argv[]) {
xw.l = xw.t = 0; xw.l = xw.t = 0;
xw.isfixed = False; xw.isfixed = False;
xw.cursor = 0;
ARGBEGIN { ARGBEGIN {
case 'a': case 'a':