mirror of git://git.suckless.org/st
Optimize tputtab.
Before this patch executing printf '\e[10000000000I' or printf '\e[10000000000Z' resulted in long delay.
This commit is contained in:
parent
1b0b9759dc
commit
844c503c80
28
st.c
28
st.c
|
@ -375,7 +375,7 @@ static void tmoveto(int, int);
|
||||||
static void tmoveato(int, int);
|
static void tmoveato(int, int);
|
||||||
static void tnew(int, int);
|
static void tnew(int, int);
|
||||||
static void tnewline(int);
|
static void tnewline(int);
|
||||||
static void tputtab(bool);
|
static void tputtab(int);
|
||||||
static void tputc(char *, int);
|
static void tputc(char *, int);
|
||||||
static void treset(void);
|
static void treset(void);
|
||||||
static int tresize(int, int);
|
static int tresize(int, int);
|
||||||
|
@ -1996,8 +1996,7 @@ csihandle(void) {
|
||||||
break;
|
break;
|
||||||
case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
|
case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
while(csiescseq.arg[0]--)
|
tputtab(csiescseq.arg[0]);
|
||||||
tputtab(1);
|
|
||||||
break;
|
break;
|
||||||
case 'J': /* ED -- Clear screen */
|
case 'J': /* ED -- Clear screen */
|
||||||
selclear(NULL);
|
selclear(NULL);
|
||||||
|
@ -2065,8 +2064,7 @@ csihandle(void) {
|
||||||
break;
|
break;
|
||||||
case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */
|
case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
while(csiescseq.arg[0]--)
|
tputtab(-csiescseq.arg[0]);
|
||||||
tputtab(0);
|
|
||||||
break;
|
break;
|
||||||
case 'd': /* VPA -- Move to <row> */
|
case 'd': /* VPA -- Move to <row> */
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
|
@ -2281,19 +2279,17 @@ tdump(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tputtab(bool forward) {
|
tputtab(int n) {
|
||||||
uint x = term.c.x;
|
uint x = term.c.x;
|
||||||
|
|
||||||
if(forward) {
|
if(n > 0) {
|
||||||
if(x == term.col)
|
while(x < term.col && n--)
|
||||||
return;
|
for(++x; x < term.col && !term.tabs[x]; ++x)
|
||||||
for(++x; x < term.col && !term.tabs[x]; ++x)
|
/* nothing */ ;
|
||||||
/* nothing */ ;
|
} else if(n < 0) {
|
||||||
} else {
|
while(x > 0 && n++)
|
||||||
if(x == 0)
|
for(--x; x > 0 && !term.tabs[x]; --x)
|
||||||
return;
|
/* nothing */ ;
|
||||||
for(--x; x > 0 && !term.tabs[x]; --x)
|
|
||||||
/* nothing */ ;
|
|
||||||
}
|
}
|
||||||
tmoveto(x, term.c.y);
|
tmoveto(x, term.c.y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue