aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/st.c b/st.c
index ff9bdd8..c9ef574 100644
--- a/st.c
+++ b/st.c
@@ -375,7 +375,7 @@ static void tmoveto(int, int);
375static void tmoveato(int, int); 375static void tmoveato(int, int);
376static void tnew(int, int); 376static void tnew(int, int);
377static void tnewline(int); 377static void tnewline(int);
378static void tputtab(bool); 378static void tputtab(int);
379static void tputc(char *, int); 379static void tputc(char *, int);
380static void treset(void); 380static void treset(void);
381static int tresize(int, int); 381static int tresize(int, int);
@@ -1996,8 +1996,7 @@ csihandle(void) {
1996 break; 1996 break;
1997 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */ 1997 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
1998 DEFAULT(csiescseq.arg[0], 1); 1998 DEFAULT(csiescseq.arg[0], 1);
1999 while(csiescseq.arg[0]--) 1999 tputtab(csiescseq.arg[0]);
2000 tputtab(1);
2001 break; 2000 break;
2002 case 'J': /* ED -- Clear screen */ 2001 case 'J': /* ED -- Clear screen */
2003 selclear(NULL); 2002 selclear(NULL);
@@ -2065,8 +2064,7 @@ csihandle(void) {
2065 break; 2064 break;
2066 case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */ 2065 case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */
2067 DEFAULT(csiescseq.arg[0], 1); 2066 DEFAULT(csiescseq.arg[0], 1);
2068 while(csiescseq.arg[0]--) 2067 tputtab(-csiescseq.arg[0]);
2069 tputtab(0);
2070 break; 2068 break;
2071 case 'd': /* VPA -- Move to <row> */ 2069 case 'd': /* VPA -- Move to <row> */
2072 DEFAULT(csiescseq.arg[0], 1); 2070 DEFAULT(csiescseq.arg[0], 1);
@@ -2281,19 +2279,17 @@ tdump(void) {
2281} 2279}
2282 2280
2283void 2281void
2284tputtab(bool forward) { 2282tputtab(int n) {
2285 uint x = term.c.x; 2283 uint x = term.c.x;
2286 2284
2287 if(forward) { 2285 if(n > 0) {
2288 if(x == term.col) 2286 while(x < term.col && n--)
2289 return; 2287 for(++x; x < term.col && !term.tabs[x]; ++x)
2290 for(++x; x < term.col && !term.tabs[x]; ++x) 2288 /* nothing */ ;
2291 /* nothing */ ; 2289 } else if(n < 0) {
2292 } else { 2290 while(x > 0 && n++)
2293 if(x == 0) 2291 for(--x; x > 0 && !term.tabs[x]; --x)
2294 return; 2292 /* nothing */ ;
2295 for(--x; x > 0 && !term.tabs[x]; --x)
2296 /* nothing */ ;
2297 } 2293 }
2298 tmoveto(x, term.c.y); 2294 tmoveto(x, term.c.y);
2299} 2295}