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

zle_refresh patch 2



Heyla, 
this goes on top of zsh-workers/2817

It fixes coredumps and bad displays when terms are 1 or 2 lines.
When a terminal is 1 or 2 lines high, the terminal will act as if 
SINGLE_LINE_ZLE is set.  This avoids many problems with the status line.
I also noticed a very minor display problem with singlerefresh(), but it
must have already been present previously - there's an off-by-one calculation
which makes the display slightly wrong.  If I get some more time later 
(unlikely before the weekend) I'll fix it.

BTW, I put some code in utils.c - that's mainly laziness / lack of time
on my part - it's there as a safety net because I didn't check every possible
startup situation.  Ah well...


*** utils.c.org	Mon Feb  3 21:37:39 1997
--- utils.c	Mon Feb  3 21:38:15 1997
***************
*** 864,869 ****
--- 864,873 ----
      if (oldrows != lines)
  	setintenv("LINES", lines);
  #endif   /*  TIOCGWINSZ */
+     if (isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3) /* safety */
+ 	shortterm = 1;
+     else
+ 	shortterm = 0;
  }
  
  /* Move a fd to a place >= 10 and mark the new fd in fdtable.  If the fd *

*** zle.h.~2~	Fri Jan 24 22:50:08 1997
--- zle.h	Mon Feb  3 21:31:47 1997
***************
*** 106,111 ****
--- 106,114 ----
  /* height of left prompt */
  ZLEXTERN int lppth;
  
+ /* terminal is too short to do anything */
+ ZLEXTERN int shortterm;
+ 
  /* last named command done */
  ZLEXTERN int lastnamed;
  
*** zle_misc.c.~2~	Fri Jan 24 22:50:08 1997
--- zle_misc.c	Mon Feb  3 21:33:29 1997
***************
*** 763,769 ****
  void
  tsetcap(int cap, int flag)
  {
!     if (termok && unset(SINGLELINEZLE) && tcstr[cap]) {
  	switch(flag) {
  	case -1:
  	    tputs(tcstr[cap], 1, putraw);
--- 763,769 ----
  void
  tsetcap(int cap, int flag)
  {
!     if (!shortterm) {
  	switch(flag) {
  	case -1:
  	    tputs(tcstr[cap], 1, putraw);

*** zle_refresh.c.~2~	Fri Jan 24 22:50:08 1997
--- zle_refresh.c	Mon Feb  3 21:32:59 1997
***************
*** 72,78 ****
   
      genprompts();
      winw = columns;  /* terminal width */
!     if (isset(SINGLELINEZLE) || termok != TERM_OK)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
--- 72,78 ----
   
      genprompts();
      winw = columns;  /* terminal width */
!     if (shortterm)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
***************
*** 245,250 ****
--- 245,254 ----
  
      cleareol = 0;		/* unset */
      more_start = more_end = 0;	/* unset */
+     if (isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3)
+ 	shortterm = 1;
+     else
+ 	shortterm = 0;
      if (resetneeded) {
  	onumscrolls = 0;
  	setterm();
***************
*** 271,277 ****
                  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)
              zwrite(lpptbuf, lpptlen, 1, shout);
--- 275,281 ----
                  cleareol = 1;   /* request: clear to end of line */
          if (t0 > -1)
              olnct = t0;
!         if (shortterm)
              vcs = 0;
          else if (!clearflag && lpptlen)
              zwrite(lpptbuf, lpptlen, 1, shout);
***************
*** 288,294 ****
  /* 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();
  	return;
      }
--- 292,298 ----
  /* now winw equals columns and winh equals lines 
     width comparisons can be made with winw, height comparisons with winh */
  
!     if (shortterm) {
  	singlerefresh();
  	return;
      }
***************
*** 355,360 ****
--- 359,371 ----
  
      if (statusline) {
  	tosln = ln + 1;
+         if (ln == winh - 1) {
+ 	    if (nvln > 0) {
+ 		scrollwindow(0);
+ 		nvln--;
+ 	    }
+ 	    tosln--;
+ 	}
  	snextline
  	t = (unsigned char *)statusline;
  	for (; t < (unsigned char *)statusline + statusll; t++) {



-- 
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