Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zle_refresh trial patch



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@xxxxxxxxxxxxxxx]   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



Messages sorted by: Reverse Date, Date, Thread, Author