diff options
author | Christoph Lohmann <20h@r-36.net> | 2012-08-30 21:17:54 +0200 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2012-08-30 21:17:54 +0200 |
commit | c58950f2efd8f203e72add7b22e7f5b973c09a7d (patch) | |
tree | 5524eb86864c0e30823bf07d999293a12e182557 | |
parent | 91fa81dbac4f09de234921cdf5afacb8c8295919 (diff) | |
download | st-c58950f2efd8f203e72add7b22e7f5b973c09a7d.tar.gz st-c58950f2efd8f203e72add7b22e7f5b973c09a7d.zip |
Applying the CBT patch of Roberto Vargas. Thanks.
-rw-r--r-- | st.c | 59 |
1 files changed, 36 insertions, 23 deletions
@@ -97,11 +97,11 @@ enum glyph_state { | |||
97 | }; | 97 | }; |
98 | 98 | ||
99 | enum term_mode { | 99 | enum term_mode { |
100 | MODE_WRAP = 1, | 100 | MODE_WRAP = 1, |
101 | MODE_INSERT = 2, | 101 | MODE_INSERT = 2, |
102 | MODE_APPKEYPAD = 4, | 102 | MODE_APPKEYPAD = 4, |
103 | MODE_ALTSCREEN = 8, | 103 | MODE_ALTSCREEN = 8, |
104 | MODE_CRLF = 16, | 104 | MODE_CRLF = 16, |
105 | MODE_MOUSEBTN = 32, | 105 | MODE_MOUSEBTN = 32, |
106 | MODE_MOUSEMOTION = 64, | 106 | MODE_MOUSEMOTION = 64, |
107 | MODE_MOUSE = 32|64, | 107 | MODE_MOUSE = 32|64, |
@@ -110,8 +110,8 @@ enum term_mode { | |||
110 | 110 | ||
111 | enum escape_state { | 111 | enum escape_state { |
112 | ESC_START = 1, | 112 | ESC_START = 1, |
113 | ESC_CSI = 2, | 113 | ESC_CSI = 2, |
114 | ESC_STR = 4, /* DSC, OSC, PM, APC */ | 114 | ESC_STR = 4, /* DSC, OSC, PM, APC */ |
115 | ESC_ALTCHARSET = 8, | 115 | ESC_ALTCHARSET = 8, |
116 | ESC_STR_END = 16, /* a final string was encountered */ | 116 | ESC_STR_END = 16, /* a final string was encountered */ |
117 | }; | 117 | }; |
@@ -152,21 +152,21 @@ typedef struct { | |||
152 | /* ESC '[' [[ [<priv>] <arg> [;]] <mode>] */ | 152 | /* ESC '[' [[ [<priv>] <arg> [;]] <mode>] */ |
153 | typedef struct { | 153 | typedef struct { |
154 | char buf[ESC_BUF_SIZ]; /* raw string */ | 154 | char buf[ESC_BUF_SIZ]; /* raw string */ |
155 | int len; /* raw string length */ | 155 | int len; /* raw string length */ |
156 | char priv; | 156 | char priv; |
157 | int arg[ESC_ARG_SIZ]; | 157 | int arg[ESC_ARG_SIZ]; |
158 | int narg; /* nb of args */ | 158 | int narg; /* nb of args */ |
159 | char mode; | 159 | char mode; |
160 | } CSIEscape; | 160 | } CSIEscape; |
161 | 161 | ||
162 | /* STR Escape sequence structs */ | 162 | /* STR Escape sequence structs */ |
163 | /* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */ | 163 | /* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */ |
164 | typedef struct { | 164 | typedef struct { |
165 | char type; /* ESC type ... */ | 165 | char type; /* ESC type ... */ |
166 | char buf[STR_BUF_SIZ]; /* raw string */ | 166 | char buf[STR_BUF_SIZ]; /* raw string */ |
167 | int len; /* raw string length */ | 167 | int len; /* raw string length */ |
168 | char *args[STR_ARG_SIZ]; | 168 | char *args[STR_ARG_SIZ]; |
169 | int narg; /* nb of args */ | 169 | int narg; /* nb of args */ |
170 | } STREscape; | 170 | } STREscape; |
171 | 171 | ||
172 | /* Internal representation of the screen */ | 172 | /* Internal representation of the screen */ |
@@ -262,7 +262,7 @@ static void tinsertblankline(int); | |||
262 | static void tmoveto(int, int); | 262 | static void tmoveto(int, int); |
263 | static void tnew(int, int); | 263 | static void tnew(int, int); |
264 | static void tnewline(int); | 264 | static void tnewline(int); |
265 | static void tputtab(void); | 265 | static void tputtab(bool); |
266 | static void tputc(char*); | 266 | static void tputc(char*); |
267 | static void treset(void); | 267 | static void treset(void); |
268 | static int tresize(int, int); | 268 | static int tresize(int, int); |
@@ -1243,7 +1243,7 @@ csihandle(void) { | |||
1243 | case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */ | 1243 | case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */ |
1244 | DEFAULT(csiescseq.arg[0], 1); | 1244 | DEFAULT(csiescseq.arg[0], 1); |
1245 | while (csiescseq.arg[0]--) | 1245 | while (csiescseq.arg[0]--) |
1246 | tputtab(); | 1246 | tputtab(1); |
1247 | break; | 1247 | break; |
1248 | case 'J': /* ED -- Clear screen */ | 1248 | case 'J': /* ED -- Clear screen */ |
1249 | sel.bx = -1; | 1249 | sel.bx = -1; |
@@ -1356,7 +1356,11 @@ csihandle(void) { | |||
1356 | DEFAULT(csiescseq.arg[0], 1); | 1356 | DEFAULT(csiescseq.arg[0], 1); |
1357 | tdeletechar(csiescseq.arg[0]); | 1357 | tdeletechar(csiescseq.arg[0]); |
1358 | break; | 1358 | break; |
1359 | /* XXX: (CSI n Z) CBT -- Cursor Backward Tabulation <n> tab stops */ | 1359 | case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */ |
1360 | DEFAULT(csiescseq.arg[0], 1); | ||
1361 | while (csiescseq.arg[0]--) | ||
1362 | tputtab(0); | ||
1363 | break; | ||
1360 | case 'd': /* VPA -- Move to <row> */ | 1364 | case 'd': /* VPA -- Move to <row> */ |
1361 | DEFAULT(csiescseq.arg[0], 1); | 1365 | DEFAULT(csiescseq.arg[0], 1); |
1362 | tmoveto(term.c.x, csiescseq.arg[0]-1); | 1366 | tmoveto(term.c.x, csiescseq.arg[0]-1); |
@@ -1528,11 +1532,20 @@ strreset(void) { | |||
1528 | } | 1532 | } |
1529 | 1533 | ||
1530 | void | 1534 | void |
1531 | tputtab(void) { | 1535 | tputtab(bool forward) { |
1532 | unsigned x; | 1536 | unsigned x = term.c.x; |
1533 | 1537 | ||
1534 | for (x = term.c.x + 1; x < term.col && !term.tabs[x]; ++x) | 1538 | if (forward) { |
1535 | /* nothing */ ; | 1539 | if (x == term.col) |
1540 | return; | ||
1541 | for (++x; x < term.col && !term.tabs[x]; ++x) | ||
1542 | /* nothing */ ; | ||
1543 | } else { | ||
1544 | if (x == 0) | ||
1545 | return; | ||
1546 | for (--x; x > 0 && !term.tabs[x]; --x) | ||
1547 | /* nothing */ ; | ||
1548 | } | ||
1536 | tmoveto(x, term.c.y); | 1549 | tmoveto(x, term.c.y); |
1537 | } | 1550 | } |
1538 | 1551 | ||
@@ -1650,7 +1663,7 @@ tputc(char *c) { | |||
1650 | sel.bx = -1; | 1663 | sel.bx = -1; |
1651 | switch(ascii) { | 1664 | switch(ascii) { |
1652 | case '\t': | 1665 | case '\t': |
1653 | tputtab(); | 1666 | tputtab(1); |
1654 | break; | 1667 | break; |
1655 | case '\b': | 1668 | case '\b': |
1656 | tmoveto(term.c.x-1, term.c.y); | 1669 | tmoveto(term.c.x-1, term.c.y); |
@@ -1806,8 +1819,8 @@ void | |||
1806 | xclear(int x1, int y1, int x2, int y2) { | 1819 | xclear(int x1, int y1, int x2, int y2) { |
1807 | XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? DefaultFG : DefaultBG]); | 1820 | XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? DefaultFG : DefaultBG]); |
1808 | XFillRectangle(xw.dpy, xw.buf, dc.gc, | 1821 | XFillRectangle(xw.dpy, xw.buf, dc.gc, |
1809 | BORDER + x1 * xw.cw, BORDER + y1 * xw.ch, | 1822 | BORDER + x1 * xw.cw, BORDER + y1 * xw.ch, |
1810 | (x2-x1+1) * xw.cw, (y2-y1+1) * xw.ch); | 1823 | (x2-x1+1) * xw.cw, (y2-y1+1) * xw.ch); |
1811 | } | 1824 | } |
1812 | 1825 | ||
1813 | void | 1826 | void |
@@ -1982,8 +1995,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { | |||
1982 | /* copy buffer pixmap to screen pixmap */ | 1995 | /* copy buffer pixmap to screen pixmap */ |
1983 | void | 1996 | void |
1984 | xcopy() { | 1997 | xcopy() { |
1985 | XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}}; | 1998 | XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}}; |
1986 | XdbeSwapBuffers(xw.dpy, swpinfo, 1); | 1999 | XdbeSwapBuffers(xw.dpy, swpinfo, 1); |
1987 | 2000 | ||
1988 | } | 2001 | } |
1989 | 2002 | ||
@@ -2080,8 +2093,8 @@ expose(XEvent *ev) { | |||
2080 | if(xw.state & WIN_REDRAW) { | 2093 | if(xw.state & WIN_REDRAW) { |
2081 | if(!e->count) | 2094 | if(!e->count) |
2082 | xw.state &= ~WIN_REDRAW; | 2095 | xw.state &= ~WIN_REDRAW; |
2083 | } | 2096 | } |
2084 | xcopy(); | 2097 | xcopy(); |
2085 | } | 2098 | } |
2086 | 2099 | ||
2087 | void | 2100 | void |