From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id LAA08648 for ; Mon, 14 Oct 1996 11:20:40 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id VAA17472; Sun, 13 Oct 1996 21:18:16 -0400 (EDT) Resent-Date: Sun, 13 Oct 1996 21:18:16 -0400 (EDT) From: Geoff Wing Message-Id: <199610140114.LAA08554@coral.primenet.com.au> Subject: zle_refresh.c patch To: zsh-workers@math.gatech.edu (zsh-workers) Date: Mon, 14 Oct 1996 11:14:24 +1000 (EST) X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"FSxNB.0.wG4.OJPOo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2221 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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