* zle_refresh.c patch
@ 1995-07-06 19:30 Geoff Wing
0 siblings, 0 replies; 3+ messages in thread
From: Geoff Wing @ 1995-07-06 19:30 UTC (permalink / raw)
To: zsh-workers
OK, here's a patch for zle_refresh.c to fix a couple of bugs:
1. not clearing properly if more characters were inserted than deleted
2. not clearing the last character in the line if rprompt printed (Who
introduced this? Why?)
This is a patch on the last RCS source I got, with no other patches applied.
Don't include Peter Stephenson's patch (message 158 or 160) with this.
*** zle_refresh.c.orig Mon Jul 3 01:01:02 1995
--- zle_refresh.c Fri Jul 7 05:15:34 1995
***************
*** 416,421 ****
--- 416,422 ----
{
char *nl, *ol, *p1; /* line buffer pointers */
int ccs = 0, /* temporary count for cursor position */
+ char_ins = 0, /* number of characters inserted/deleted */
col_cleareol, /* clear to end-of-line from this column */
i, j, /* tmp */
nllen, ollen; /* new and old line buffer lengths */
***************
*** 429,435 ****
which need to be written. do this now to allow some pre-processing */
if (cleareol || /* request to clear to end of line */
! !nllen) { /* no line buffer given */
p1 = halloc(winw + 1);
if (nllen)
strncpy(p1, nl, nllen);
--- 430,437 ----
which need to be written. do this now to allow some pre-processing */
if (cleareol || /* request to clear to end of line */
! !nllen || /* no line buffer given */
! (ln == 0 && (put_rpmpt != oput_rpmpt))) { /* prompt changed */
p1 = halloc(winw + 1);
if (nllen)
strncpy(p1, nl, nllen);
***************
*** 437,451 ****
p1[winw] = '\0';
nl = p1;
nllen = winw;
- } else if (ln == 0 && put_rpmpt != oput_rpmpt && winw - 1 > nllen) {
- /* prompt changed */
- p1 = halloc(winw);
- if (nllen)
- strncpy(p1, nl, nllen);
- memset(p1 + nllen, ' ', winw - 1 - nllen);
- p1[winw - 1] = '\0';
- nl = p1;
- nllen = winw - 1;
} else if (ollen > nllen) { /* make new line at least as long as old */
p1 = halloc(ollen + 1);
strncpy(p1, nl, nllen);
--- 439,444 ----
***************
*** 461,467 ****
col_cleareol = -1;
if (tccan(TCCLEAREOL) &&
(nllen == winw || /* new buffer goes to the end of the line */
! !put_rpmpt)) {
for (i = nllen; i && nl[i - 1] == ' '; i--);
for (j = ollen; j && ol[j - 1] == ' '; j--);
if ((j > i + tclen[TCCLEAREOL]) || /* new buf's spaces early enough */
--- 454,460 ----
col_cleareol = -1;
if (tccan(TCCLEAREOL) &&
(nllen == winw || /* new buffer goes to the end of the line */
! put_rpmpt != oput_rpmpt)) {
for (i = nllen; i && nl[i - 1] == ' '; i--);
for (j = ollen; j && ol[j - 1] == ' '; j--);
if ((j > i + tclen[TCCLEAREOL]) || /* new buf's spaces early enough */
***************
*** 478,485 ****
/* skip past all matching characters */
for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
! if (!*nl) /* we've finished writing the new line */
! return;
moveto(ln, ccs); /* move to where we do all output from */
--- 471,484 ----
/* skip past all matching characters */
for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
! if (!*nl) {
! if ((char_ins <= 0) || (vcs >= winw)) /* written everything */
! return;
! else /* we've got junk on the right yet to clear */
! if (tccan(TCCLEAREOL) && (char_ins >= tclen[TCCLEAREOL])
! && ccs < winw)
! col_cleareol = 0; /* force a clear to end of line */
! }
moveto(ln, ccs); /* move to where we do all output from */
***************
*** 490,495 ****
--- 489,509 ----
return;
}
+ /* we've written out the new but yet to clear rubbish due to inserts */
+ if (!*nl) {
+ if ((i = (winw - ccs < char_ins ? winw - ccs : char_ins)) == 0)
+ return;
+ if (tccan(TCDEL) && (tcdelcost(i) <= i + 1))
+ tc_delchars(i);
+ else {
+ SELECT_ADD_COST(i);
+ vcs += i;
+ while (i-- > 0)
+ putc(' ', shout);
+ }
+ return;
+ }
+
/* if we've reached the end of the old buffer, then there are few tricks
we can do, so we just dump out what we must and clear if we can */
if (!*ol) {
***************
*** 520,525 ****
--- 534,540 ----
tc_delchars(i);
SELECT_ADD_COST(i);
ol = p1;
+ char_ins -= i;
break;
}
if (*p1)
***************
*** 538,543 ****
--- 553,559 ----
fwrite(nl, i, 1, shout);
ccs = (vcs += i);
nl = p1;
+ char_ins += i;
break;
}
if (*p1)
--
Mason [G.C.W] mason@werple.mira.net.au Hurt...Agony...Pain...LOVE-IT
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: zle_refresh.c patch
1996-10-14 1:14 Geoff Wing
@ 1996-10-14 1:57 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1996-10-14 1:57 UTC (permalink / raw)
To: Geoff Wing, zsh-workers
On Oct 14, 11:14am, Geoff Wing wrote:
} Subject: zle_refresh.c patch
}
} Heyla,
} here's an optimisation and bug fix. Bart Schaefer's problem from 2202
} should be fixed
I can confirm that. It's not only fixed, but scrolling up and down through
multi-line commands with C-P and C-N is noticeably smoother, even with my
old/stupid/incomplete vs100 termcap entry.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
New male in /home/schaefer:
>N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"
^ permalink raw reply [flat|nested] 3+ messages in thread
* zle_refresh.c patch
@ 1996-10-14 1:14 Geoff Wing
1996-10-14 1:57 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Geoff Wing @ 1996-10-14 1:14 UTC (permalink / raw)
To: zsh-workers
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@primenet.com.au] PrimeNet - Internet Consultancy
Web: http://www.primenet.com.au/ Facsimile: +61-3-9819 3788
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1996-10-14 1:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-07-06 19:30 zle_refresh.c patch Geoff Wing
1996-10-14 1:14 Geoff Wing
1996-10-14 1:57 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).