* zle_refresh trial patch
@ 1996-03-12 13:53 Geoff Wing
1996-03-12 15:02 ` Zefram
0 siblings, 1 reply; 3+ messages in thread
From: Geoff Wing @ 1996-03-12 13:53 UTC (permalink / raw)
To: zsh-list
This is a patch for beta13 (Don't patch on top of my previous patch in
message 742. (I lost that message, so I can't produce a successive patch)).
The zle_refresh() code should hopefully produce {less,hardly any} redundant
output. I'm still unhappy with some of the code but it probably won't
undergo any changes soon unless necessary (so find those bugs, please).
Hacked from Zoltan's message 809:
:Type ^V^J^V^J1234567890^A- at a prompt. You get:
Shouldn't appear.
:The other bug is probably the same but I can only reproduce is on a Linux
:console. If a line wraps and there are at most 10 characters between the
:cursor and the right edge of the screen and least 10 characters wraps to the
:next screen line and a character is inserted, the first character on the
:wrapped line will be duplicated.
Sorry, I didn't understand this.
:tries to ensure that cut & paste in xterm works for wrapped lines so that no
:bogous newline will be added to the clipboard. But zsh overdoes that even
:multiline buffers will be cut as a single line. This does not happen when a
:multi-line buffer is directly typed in a buffer but only when such a
:multiline structure comes readily e.g. from the history when using the
:up-arrow key or in vared (zed).
Haven't checked this yet. (It's probably {in,}directly my fault anyway)
BTW, anyone get annoyed by this: when at the bottom of the screen
% rubbishrubbishrubbishrubbishrubbishrubbishrubbishrubbishrubbishrubbishrubbis*
rubbish #don't press return, delete back to *
There is an extra line scrolled. I'll look into it (soon).
Anyway:
*** zle_refresh.c.~1~ Fri Dec 22 09:44:43 1995
--- zle_refresh.c Wed Mar 13 00:24:34 1996
***************
*** 41,47 ****
/* Oct/Nov 94: <mason> some code savagely redesigned to fix several bugs -
refreshline() & tc_rightcurs() majorly rewritten; refresh() fixed -
I've put my fingers into just about every routine in here -
! any queries about updates to mason@werple.apana.org.au */
char **nbuf = NULL, /* new video buffer line-by-line char array */
**obuf = NULL; /* old video buffer line-by-line char array */
--- 41,47 ----
/* Oct/Nov 94: <mason> some code savagely redesigned to fix several bugs -
refreshline() & tc_rightcurs() majorly rewritten; refresh() fixed -
I've put my fingers into just about every routine in here -
! any queries about updates to mason@werple.net.au */
char **nbuf = NULL, /* new video buffer line-by-line char array */
**obuf = NULL; /* old video buffer line-by-line char array */
***************
*** 56,62 ****
winpos; /* singlelinezle: line's position in window */
static unsigned pmpt_attr = 0, /* text attributes after displaying prompt */
rpmpt_attr = 0; /* text attributes after displaying rprompt */
- static char am_char = ' '; /* first col char if needed for automargin */
/**/
void
--- 56,61 ----
***************
*** 103,109 ****
vcs = pptw;
olnct = nlnct = 0;
! if(showinglist > 0)
showinglist = -2;
}
--- 102,108 ----
vcs = pptw;
olnct = nlnct = 0;
! if (showinglist > 0)
showinglist = -2;
}
***************
*** 172,178 ****
* that was called from the end of refresh(), then we don't need to do *
* anything. All this `inlist' code is actually unnecessary, but it *
* improves speed a little in a common case. */
! if(inlist)
return;
#ifdef HAVE_SELECT
--- 171,177 ----
* that was called from the end of refresh(), then we don't need to do *
* anything. All this `inlist' code is actually unnecessary, but it *
* improves speed a little in a common case. */
! if (inlist)
return;
#ifdef HAVE_SELECT
***************
*** 366,372 ****
individually */
if (olnct > nlnct) {
! cleareol = 1;
for (ln = nlnct; ln < olnct; ln++)
refreshline(ln);
}
--- 365,371 ----
individually */
if (olnct > nlnct) {
! cleareol = clearf;
for (ln = nlnct; ln < olnct; ln++)
refreshline(ln);
}
***************
*** 407,419 ****
/* if we have a new list showing, note it; if part of the list has been
overwritten, redisplay it. */
! if(showinglist == -2 || (showinglist > 0 && showinglist < nlnct)) {
inlist = 1;
listmatches();
inlist = 0;
refresh();
}
! if(showinglist == -1)
showinglist = nlnct;
}
--- 406,418 ----
/* if we have a new list showing, note it; if part of the list has been
overwritten, redisplay it. */
! if (showinglist == -2 || (showinglist > 0 && showinglist < nlnct)) {
inlist = 1;
listmatches();
inlist = 0;
refresh();
}
! if (showinglist == -1)
showinglist = nlnct;
}
***************
*** 437,442 ****
--- 436,446 ----
i, j, /* tmp */
nllen, ollen; /* new and old line buffer lengths */
+ /* -1: this is a mini-kludge */
+ if (!nllen && !clearf) /* ha ha: all done */
+ return;
+
+ /* 0: setup */
nl = nbuf[ln];
nllen = nl ? strlen(nl) : 0;
ol = obuf[ln] ? obuf[ln] : "";
***************
*** 470,476 ****
case it messes up cut and paste. */
col_cleareol = -1;
! if (tccan(TCCLEAREOL) && (!hasam || ln == nlnct - 1) &&
(nllen == winw || /* new buffer goes to the end of the line */
put_rpmpt != oput_rpmpt)) {
for (i = nllen; i && nl[i - 1] == ' '; i--);
--- 474,480 ----
case it messes up cut and paste. */
col_cleareol = -1;
! if (tccan(TCCLEAREOL) && !clearf && (!hasam || ln == nlnct - 1) &&
(nllen == winw || /* new buffer goes to the end of the line */
put_rpmpt != oput_rpmpt)) {
for (i = nllen; i && nl[i - 1] == ' '; i--);
***************
*** 480,500 ****
col_cleareol = i;
}
! /* 3: set character for first column, in case automargin stuff needs doing:
! to begin with, this is the first char of the old screen line, if any. */
! am_char = *ol ? *ol : *nl;
!
! /* 4: main display loop - write out the buffer using whatever tricks we can */
for (;;) {
/* skip past all matching characters */
for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
if (!*nl) {
! if ((char_ins <= 0) || (ccs >= winw)) /* written everything */
return;
else /* we've got junk on the right yet to clear */
! if (tccan(TCCLEAREOL) && (char_ins >= tclen[TCCLEAREOL]))
col_cleareol = 0; /* force a clear to end of line */
}
--- 484,502 ----
col_cleareol = i;
}
! /* 3: main display loop - write out the buffer using whatever tricks we can */
for (;;) {
/* skip past all matching characters */
for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
if (!*nl) {
! if ((char_ins <= 0) || (ccs >= winw) /* written everything */
! || (!clearf))
return;
else /* we've got junk on the right yet to clear */
! if (tccan(TCCLEAREOL) && (char_ins >= tclen[TCCLEAREOL]) &&
! (!hasam || ln == nlnct -1))
col_cleareol = 0; /* force a clear to end of line */
}
***************
*** 602,614 ****
putc('\n', shout);
SELECT_ADD_COST(2);
} else {
! putc(am_char, shout);
! tcout(TCLEFT);
! SELECT_ADD_COST(1 + tclen[TCLEFT]);
}
vln++, vcs = 0;
}
- am_char = ' ';
/* move up */
if (ln < vln) {
--- 604,618 ----
putc('\n', shout);
SELECT_ADD_COST(2);
} else {
! if ((vln < nlnct - 1) && *nbuf[vln + 1])
! putc(*nbuf[vln + 1], shout);
! else
! putc(' ', shout);
! putc('\r', shout);
! SELECT_ADD_COST(2);
}
vln++, vcs = 0;
}
/* move up */
if (ln < vln) {
--
Mason [G.C.W] mason@werple.mira.net.au "Hurt...Agony...Pain...LOVE-IT"
^ permalink raw reply [flat|nested] 3+ messages in thread
* zle_refresh trial patch
@ 1996-11-09 10:22 Geoff Wing
0 siblings, 0 replies; 3+ messages in thread
From: Geoff Wing @ 1996-11-09 10:22 UTC (permalink / raw)
To: zsh-workers
Heyla,
here's a trial patch for nicer scrolling. Scrolling in a multiple-screen
buffer should be pretty much emacs style. There is one quirk: if you are
at last screen of the buffer and you go up, the scroll point will not
necessarily be the top of the screen - it is unavoidable without a large
style change.
There is also a bug fix for the status line (unfortunately I wrote it after
I was doing the other stuff so it is dependant on it - though I could
separate if needed).
"<....>" has been added, so if you see that on the right hand side of the
first line of the status line it means there is stuff missing there. It's
a complement to <.... and ....> which are used in the normal text area.
Also, the single line scrolling which was dependant on BAUD has also been
removed.
This patch is dependant on patch zsh-workers/2336
The type of command I've mainly checked it with is:
% zed -f zed
on 24/25 line screens.
Anyway, try and find some bugs. It'll make me happier :-)
*** zle_refresh.c.~1~ Sat Nov 9 20:15:01 1996
--- zle_refresh.c Sat Nov 9 21:08:12 1996
***************
*** 113,185 ****
}
/*
! * Jul 96: <mason> changed to single line scroll for higher speed terminals
! * I've seperated the loops for readability (and it's slightly faster)
! * Returns line number to be used next
*/
/**/
! int
scrollwindow(int tline)
{
! int t0, hwinh;
char *s;
! if (tline || baud >= 19200) { /* single line scroll */
! hwinh = 1;
! s = nbuf[tline];
! for (t0 = tline; t0 < winh - 1; t0++)
! nbuf[t0] = nbuf[t0 + 1];
! nbuf[winh - 1] = s;
! } else { /* half screen scroll */
! hwinh = winh / 2;
! for (t0 = 0; t0 != winh - hwinh; t0++) {
! s = nbuf[t0];
! nbuf[t0] = nbuf[t0 + hwinh];
! nbuf[t0 + hwinh] = s;
! }
! }
if (!tline)
more_start = 1;
! return winh - hwinh;
}
/* this is the messy part. */
/* this define belongs where it's used!!! */
! #define nextline \
! { \
! *s = '\0'; \
! if (++ln == winh) \
! if (nvln != --ln && nvln != -1) \
! break; \
! else { \
! ln = scrollwindow(0); \
! if(nvln != -1) \
! nvln -= winh - ln; \
! } \
! if (!nbuf[ln]) \
! nbuf[ln] = (char *)zalloc(winw + 1); \
! s = (unsigned char *)nbuf[ln]; \
! sen = s + winw; \
}
! #define snextline \
! { \
! *s = '\0'; \
! if (++ln == winh) \
! if (tosln <= nvln + 1) { \
! ln = scrollwindow(0); \
! if (nvln) \
! nvln--, tosln--; \
! } else { \
! tosln--; \
! ln = scrollwindow(tosln); \
! } \
! if (!nbuf[ln]) \
! nbuf[ln] = (char *)zalloc(winw + 1); \
! s = (unsigned char *)nbuf[ln]; \
! sen = s + winw; \
}
#ifdef TIOCGWINSZ
--- 113,186 ----
}
/*
! * Nov 96: <mason> changed to single line scroll
*/
/**/
! void
scrollwindow(int tline)
{
! int t0;
char *s;
! s = nbuf[tline];
! for (t0 = tline; t0 < winh - 1; t0++)
! nbuf[t0] = nbuf[t0 + 1];
! nbuf[winh - 1] = s;
if (!tline)
more_start = 1;
! return;
}
/* this is the messy part. */
/* this define belongs where it's used!!! */
! #define nextline \
! { \
! *s = '\0'; \
! if (ln != winh - 1) \
! ln++; \
! else { \
! if (!canscroll) { \
! if (nvln != -1 && nvln != winh - 1 \
! && (numscrolls != onumscrolls - 1 \
! || nvln <= winh / 2)) \
! break; \
! numscrolls++; \
! canscroll = winh / 2; \
! } \
! canscroll--; \
! scrollwindow(0); \
! if (nvln != -1) \
! nvln--; \
! } \
! if (!nbuf[ln]) \
! nbuf[ln] = (char *)zalloc(winw + 1); \
! s = (unsigned char *)nbuf[ln]; \
! sen = s + winw; \
}
! #define snextline \
! { \
! *s = '\0'; \
! if (ln != winh - 1) \
! ln++; \
! else \
! if (tosln < 3) { \
! more_status = 1; \
! scrollwindow(tosln + 1); \
! } else if (tosln - 1 <= nvln) { \
! scrollwindow(0); \
! if (nvln) \
! nvln--, tosln--; \
! } else { \
! tosln--; \
! scrollwindow(tosln); \
! } \
! if (!nbuf[ln]) \
! nbuf[ln] = (char *)zalloc(winw + 1); \
! s = (unsigned char *)nbuf[ln]; \
! sen = s + winw; \
}
#ifdef TIOCGWINSZ
***************
*** 191,197 ****
hasam; /* terminal should have auto-margin */
static int put_rpmpt, /* whether we should display right-prompt */
oput_rpmpt, /* whether displayed right-prompt last time */
! oxtabs; /* oxtabs - tabs expand to spaces if set */
extern int clearflag; /* set to non-zero if alwayslastprompt used */
/**/
--- 192,199 ----
hasam; /* terminal should have auto-margin */
static int put_rpmpt, /* whether we should display right-prompt */
oput_rpmpt, /* whether displayed right-prompt last time */
! oxtabs, /* oxtabs - tabs expand to spaces if set */
! numscrolls, onumscrolls;
extern int clearflag; /* set to non-zero if alwayslastprompt used */
/**/
***************
*** 199,205 ****
refresh(void)
{
static int inlist; /* avoiding recursion */
! int ln = 0, /* current line we're working on */
nvcs = 0, nvln = -1, /* video cursor column and line */
t0 = -1, /* tmp */
tosln = 0; /* tmp in statusline stuff */
--- 201,209 ----
refresh(void)
{
static int inlist; /* avoiding recursion */
! int canscroll = 0, /* number of lines we are allowed to scroll */
! ln = 0, /* current line we're working on */
! more_status = 0, /* more stuff in status line */
nvcs = 0, nvln = -1, /* video cursor column and line */
t0 = -1, /* tmp */
tosln = 0; /* tmp in statusline stuff */
***************
*** 240,245 ****
--- 244,250 ----
cleareol = 0; /* unset */
more_start = more_end = 0; /* unset */
if (resetneeded) {
+ onumscrolls = 0;
setterm();
#ifdef TIOCGWINSZ
if (winchanged) {
***************
*** 269,278 ****
}
fflush(shout);
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) {
singlerefresh();
--- 274,284 ----
}
fflush(shout);
clearf = clearflag;
! } else if (winw != columns || winh != lines)
resetvideo();
! /* now winw equals columns and winh equals lines
! width comparisons can be made with winw, height comparisons with winh */
if (isset(SINGLELINEZLE) || termok != TERM_OK) {
singlerefresh();
***************
*** 287,292 ****
--- 293,299 ----
cs = 0;
}
scs = line + cs;
+ numscrolls = 0;
/* first, we generate the video line buffers so we know what to put on
the screen - also determine final cursor position (nvln, nvcs) */
***************
*** 326,334 ****
/* if we're really on the next line, don't fake it; do everything properly */
if (t == scs && (nvcs = s - (unsigned char *)(nbuf[nvln = ln])) == winw) {
*s = '\0';
! if (!nbuf[++ln])
! nbuf[ln] = (char *)zalloc(winw + 1);
! s = (unsigned char *)nbuf[ln];
nvcs = 0;
nvln++;
}
--- 333,343 ----
/* if we're really on the next line, don't fake it; do everything properly */
if (t == scs && (nvcs = s - (unsigned char *)(nbuf[nvln = ln])) == winw) {
*s = '\0';
! switch (*s) { /* a sad hack to make the break */
! case '\0': /* in nextline work */
! nextline
! }
! *s = '\0';
nvcs = 0;
nvln++;
}
***************
*** 340,346 ****
tosln = ln + 1;
snextline
t = (unsigned char *)statusline;
! for (; t < (unsigned char *)statusline+statusll; t++) {
if (icntrl(*t)) { /* simplified processing in the status line */
*s++ = '^';
if (s == sen)
--- 349,355 ----
tosln = ln + 1;
snextline
t = (unsigned char *)statusline;
! for (; t < (unsigned char *)statusline + statusll; t++) {
if (icntrl(*t)) { /* simplified processing in the status line */
*s++ = '^';
if (s == sen)
***************
*** 361,366 ****
--- 370,381 ----
nbuf[tosln - 1][winw] = '\0';
}
+ /* insert <....> at end of first status line if status is too big */
+ if (more_status) {
+ strncpy(nbuf[tosln] + winw - 8, " <....> ", 8);
+ nbuf[tosln][winw] = '\0';
+ }
+
*s = '\0';
nlnct = ln + 1;
for (ln = nlnct; ln < winh; ln++)
***************
*** 478,483 ****
--- 493,499 ----
ovln = nvln;
olnct = nlnct;
oput_rpmpt = put_rpmpt;
+ onumscrolls = numscrolls;
if (nlnct > vmaxln)
vmaxln = nlnct;
fflush(shout); /* make sure everything is written out */
--
Geoff Wing [gwing@primenet.com.au] Technical Manager
Phone : +61-3-9818 2977 PrimeNet - Internet Consultancy
Facsimile: +61-3-9819 3788 Web : <URL:http://www.primenet.com.au/>
Mobile : 0412 162 441
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1996-11-09 10:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-12 13:53 zle_refresh trial patch Geoff Wing
1996-03-12 15:02 ` Zefram
1996-11-09 10:22 Geoff Wing
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).