zsh-workers
 help / color / mirror / code / Atom feed
From: Geoff Wing <gwing@primenet.com.au>
To: zsh-workers@math.gatech.edu (zsh-workers)
Subject: zle_refresh trial patch
Date: Sat, 9 Nov 1996 21:22:46 +1100 (EST)	[thread overview]
Message-ID: <199611091022.VAA29372@coral.primenet.com.au> (raw)

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


             reply	other threads:[~1996-11-09 10:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-09 10:22 Geoff Wing [this message]
     [not found] ` <gwing@primenet.com.au>
1996-11-09 17:09   ` zle_refresh trial patch (and unrelated bug) Bart Schaefer
1996-11-12 12:40     ` Peter Stephenson
  -- strict thread matches above, loose matches on Subject: below --
1996-11-08 15:26 Handling for ZLE modules Peter Stephenson
     [not found] ` <pws@ifh.de>
1996-11-08 16:45   ` Bart Schaefer
1996-11-11 16:02   ` Bart Schaefer
1996-11-13 18:53   ` zle_refresh trial patch (and unrelated bug) Bart Schaefer
1996-11-14  9:03     ` Peter Stephenson
1996-11-14 14:57       ` Zefram
1996-11-08 17:16 ` Handling for ZLE modules Zefram
1996-11-08 17:26   ` Bruce Stephens
1996-11-10 23:55   ` Zoltan Hidvegi
1996-11-11 13:07   ` Peter Stephenson
1996-03-12 13:53 zle_refresh trial patch Geoff Wing
1996-03-12 15:02 ` Zefram

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=199611091022.VAA29372@coral.primenet.com.au \
    --to=gwing@primenet.com.au \
    --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).