From mboxrd@z Thu Jan 1 00:00:00 1970 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 PAA11434 for ; Thu, 29 Aug 1996 15:47:42 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id BAA18936; Thu, 29 Aug 1996 01:42:41 -0400 (EDT) Resent-Date: Thu, 29 Aug 1996 01:42:41 -0400 (EDT) From: Geoff Wing Message-Id: <199608290541.PAA11374@coral.primenet.com.au> Subject: Re: zle_refresh uncommon bug fix and movement optimisation To: hzoli@cs.elte.hu (Zoltan Hidvegi) Date: Thu, 29 Aug 1996 15:38:52 +1000 (EST) Cc: zsh-workers@math.gatech.edu In-Reply-To: <199608281913.VAA15626@bolyai.cs.elte.hu> from "Zoltan Hidvegi" at Aug 28, 96 09:13:21 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: mason@primenet.com.au Resent-Message-ID: <"yVYja1.0.od4.GtI9o"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2091 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zoltan Hidvegi wrote: :The patch fails to apply to vanilla zsh-3.0.0 because the first hunk fails. I forgot to mention that you might need a greater fuzz factor. Here's a patch on the vanilla version. *** zle_refresh.c.~3~ Thu Aug 29 15:34:22 1996 --- zle_refresh.c Thu Aug 29 15:34:31 1996 *************** *** 232,255 **** --- 232,257 ---- if (tccan(TCCLEAREOD)) tcout(TCCLEAREOD); else cleareol = 1; /* request: clear to end of line */ if (t0 > -1) olnct = t0; if (isset(SINGLELINEZLE) || termok != TERM_OK) vcs = 0; else if (!clearflag && lpptlen) { fwrite(lpptbuf, lpptlen, 1, shout); + SELECT_ADD_COST(lpptlen); fflush(shout); } if (clearflag) { putc('\r', shout); + SELECT_ADD_COST(1); vcs = 0; moveto(0, pptw); } clearf = clearflag; } else if (winw != COLUMNS) resetvideo(); /* now winw equals columns; now all width comparisons can be made to winw */ if (isset(SINGLELINEZLE) || termok != TERM_OK) { *************** *** 747,812 **** tcout(cap); return 1; } return 0; } /**/ void tc_rightcurs(int cl) { ! int ct = cl - vcs, /* number of characters to move across */ horz_tabs = 0, /* number of horizontal tabs if we do them */ i = vcs, /* cursor position after initial movements */ ! j = 0; /* number of chars outputted if we use tabs */ char *t; /* calculate how many horizontal tabs it would take, if we can do them - tabs are assumed to be 8 spaces */ if (tccan(TCNEXTTAB) && ((vcs | 7) < cl)) { horz_tabs = 1; i = (vcs | 7) + 1; for (; i + 8 <= cl; i += 8) horz_tabs++; j = cl - i; /* number of chars after last tab */ - if (tccan(TCRIGHT)) - j *= tclen[TCRIGHT]; j += (horz_tabs * tclen[TCNEXTTAB]); /* # of chars if we use tabs */ } /* do a multright if we can - if it's cheaper or we can't use other tricks */ ! if (tccan(TCMULTRIGHT) && ! (!tccan(TCRIGHT) || (tclen[TCMULTRIGHT] < tclen[TCRIGHT] * ct) || ! !tccan(TCNEXTTAB) || (tclen[TCMULTRIGHT] < j))) { tcoutarg(TCMULTRIGHT, ct); SELECT_ADD_COST(tclen[TCMULTRIGHT]); return; } /* try to go with tabs if a multright is not feasible/convenient */ if (horz_tabs) { SELECT_ADD_COST((tclen[TCNEXTTAB] * horz_tabs)); for (; horz_tabs--;) tcout(TCNEXTTAB); if ((ct = cl - i) == 0) /* number of chars still to move across */ return; } ! /* or try to dump lots of right movements */ ! if (tccan(TCRIGHT)) { ! SELECT_ADD_COST((tclen[TCRIGHT] * ct)); ! for (; ct--;) ! tcout(TCRIGHT); ! return; } - /* otherwise _carefully_ write the contents of the video buffer */ 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 */ } /**/ --- 749,829 ---- tcout(cap); return 1; } return 0; } /**/ void tc_rightcurs(int cl) { ! int ct, /* number of characters to move across */ horz_tabs = 0, /* number of horizontal tabs if we do them */ i = vcs, /* cursor position after initial movements */ ! j; /* number of chars outputted */ char *t; + j = ct = cl - vcs; + /* calculate how many horizontal tabs it would take, if we can do them - tabs are assumed to be 8 spaces */ if (tccan(TCNEXTTAB) && ((vcs | 7) < cl)) { horz_tabs = 1; i = (vcs | 7) + 1; for (; i + 8 <= cl; i += 8) horz_tabs++; j = cl - i; /* number of chars after last tab */ j += (horz_tabs * tclen[TCNEXTTAB]); /* # of chars if we use tabs */ } /* do a multright if we can - if it's cheaper or we can't use other tricks */ ! if (tccan(TCMULTRIGHT) ! && (!tccan(TCNEXTTAB) || (tclen[TCMULTRIGHT] <= j) ! || (vln == 0 && i < pptw))) { tcoutarg(TCMULTRIGHT, ct); SELECT_ADD_COST(tclen[TCMULTRIGHT]); return; } /* try to go with tabs if a multright is not feasible/convenient */ if (horz_tabs) { SELECT_ADD_COST((tclen[TCNEXTTAB] * horz_tabs)); for (; horz_tabs--;) tcout(TCNEXTTAB); if ((ct = cl - i) == 0) /* number of chars still to move across */ return; } ! /* otherwise _carefully_ write the contents of the video buffer. ! if we're anywhere in the prompt, goto the left column and write the whole ! prompt out unless lpptlen == pptw : we can cheat then */ ! if (vln == 0 && i < pptw) { ! 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--; ) ! tcout(TCRIGHT); ! } else { ! if (i != 0) { ! SELECT_ADD_COST(1); ! putc('\r', shout); ! } ! SELECT_ADD_COST(lpptlen); ! fwrite(lpptbuf, lpptlen, 1, shout); ! } ! i = pptw; ! ct = cl - i; } 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 */ } /**/ -- Geoff Wing [mason@primenet.com.au] PrimeNet - Internet Consultancy Web: http://www.primenet.com.au/ Facsimile: +61-3-9819 3788