From: Geoff Wing <mason@primenet.com.au>
To: hzoli@cs.elte.hu (Zoltan Hidvegi)
Cc: zsh-workers@math.gatech.edu
Subject: Re: zle_refresh uncommon bug fix and movement optimisation
Date: Thu, 29 Aug 1996 15:38:52 +1000 (EST) [thread overview]
Message-ID: <199608290541.PAA11374@coral.primenet.com.au> (raw)
In-Reply-To: <199608281913.VAA15626@bolyai.cs.elte.hu> from "Zoltan Hidvegi" at Aug 28, 96 09:13:21 pm
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
next parent reply other threads:[~1996-08-29 5:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <199608281913.VAA15626@bolyai.cs.elte.hu>
1996-08-29 5:38 ` Geoff Wing [this message]
1996-08-28 11:27 Geoff Wing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199608290541.PAA11374@coral.primenet.com.au \
--to=mason@primenet.com.au \
--cc=hzoli@cs.elte.hu \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).