Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zle_refresh.c patch
- X-seq: zsh-workers 2221
- From: Geoff Wing <gwing@xxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
- Subject: zle_refresh.c patch
- Date: Mon, 14 Oct 1996 11:14:24 +1000 (EST)
Heyla,
here's an optimisation and bug fix. Bart Schaefer's problem from 2202
should be fixed, and the optimisation will prevent a lot of infrequent but
unnecessary code in most people's cases. There are also a couple more
necessary checks.
bye
*** zle_refresh.c.~3~ Tue Oct 8 12:10:00 1996
--- zle_refresh.c Mon Oct 14 11:06:35 1996
***************
*** 501,506 ****
--- 501,516 ----
ol = obuf[ln] ? obuf[ln] : "";
ollen = strlen(ol);
+ /* optimisation: can easily happen for clearing old lines. If the terminal has
+ the capability, then this is the easiest way to skip unnecessary stuff */
+ if (cleareol && !nllen && !(hasam && ln < nlnct - 1)
+ && tccan(TCCLEAREOL)) {
+ moveto(ln, 0);
+ tcout(TCCLEAREOL);
+ SELECT_ADD_COST(tclen[TCCLEAREOL]);
+ return;
+ }
+
/* 1: pad out the new buffer with spaces to contain _all_ of the characters
which need to be written. do this now to allow some pre-processing */
***************
*** 515,521 ****
if (ln && nbuf[ln])
strncpy(nl, p1, winw + 1); /* next time obuf will be up-to-date */
else
! nl = p1; /* don't keep padding for prompt line */
nllen = winw;
} else if (ollen > nllen) { /* make new line at least as long as old */
p1 = halloc(ollen + 1);
--- 525,531 ----
if (ln && nbuf[ln])
strncpy(nl, p1, winw + 1); /* next time obuf will be up-to-date */
else
! nl = p1; /* don't keep the padding for prompt line */
nllen = winw;
} else if (ollen > nllen) { /* make new line at least as long as old */
p1 = halloc(ollen + 1);
***************
*** 548,554 ****
if (hasam && vcs == winw) {
vln++, vcs = 1;
! putc(*nbuf[vln], shout);
nl++;
if (*ol)
ol++;
--- 558,567 ----
if (hasam && vcs == winw) {
vln++, vcs = 1;
! if (nbuf[vln] && *nbuf[vln])
! putc(*nbuf[vln], shout);
! else
! putc(' ', shout); /* I don't think this should happen */
nl++;
if (*ol)
ol++;
***************
*** 810,816 ****
if (lpptlen == pptw) {
SELECT_ADD_COST(lpptlen - i);
fwrite(lpptbuf + i, lpptlen - i, 1, shout);
! } else if (tclen[TCRIGHT] * ct < lpptlen) {
/* it is cheaper to send TCRIGHT than reprint the whole prompt */
SELECT_ADD_COST(ct);
for ( ; ct--; )
--- 823,829 ----
if (lpptlen == pptw) {
SELECT_ADD_COST(lpptlen - i);
fwrite(lpptbuf + i, lpptlen - i, 1, shout);
! } else if (tccan(TCRIGHT) && (tclen[TCRIGHT] * ct < lpptlen)) {
/* it is cheaper to send TCRIGHT than reprint the whole prompt */
SELECT_ADD_COST(ct);
for ( ; ct--; )
***************
*** 828,837 ****
}
SELECT_ADD_COST(ct);
! for (j = 0, t = nbuf[vln]; *t && (j < i); j++, t++);
! if (j == i)
! for ( ; *t && ct; ct--, t++)
! putc(*t, shout);
while (ct--)
putc(' ', shout); /* not my fault your terminal can't go right */
}
--- 841,852 ----
}
SELECT_ADD_COST(ct);
! if (nbuf[vln]) {
! for (j = 0, t = nbuf[vln]; *t && (j < i); j++, t++);
! if (j == i)
! for ( ; *t && ct; ct--, t++)
! putc(*t, shout);
! }
while (ct--)
putc(' ', shout); /* not my fault your terminal can't go right */
}
--
Geoff Wing [gwing@xxxxxxxxxxxxxxx] PrimeNet - Internet Consultancy
Web: http://www.primenet.com.au/ Facsimile: +61-3-9819 3788
Messages sorted by:
Reverse Date,
Date,
Thread,
Author