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

Re: zle_refresh patch 2



On Feb 3,  9:55pm, gwing@xxxxxxxxxxxxxxx wrote:
} Subject: zle_refresh patch 2
}
} 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.

There's already code that causes SINGLE_LINE_ZLE to become set if the
terminal starts out at, or is shrunk to, 1 line high or 1 column wide.
(It happens when $COLUMNS or $LINES changes.)  Some of that code is a
few lines above your changes to test (lines < 3).  If it's necessary to
behave as SINGLE_LINE_ZLE for 2 lines as well, the other code should be
changed so that SINGLE_LINE_ZLE *is* set when zsh is `acting as if' it
is set.

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

The following patch, which should be applied -after- Geoff's patch, does
the following things:
  * Centralizes all the columns/USEZLE and lines/SINGLINEZLE fixups in
    zlevarsetfn(), rather than having them spread around in the code;
  * Changes the tests in zlevarsetfn() to punt on ZLE below 3 lines or
    columns rather than only below 2 lines or columns;
  * Calls pm->sets.ifn from setintenv() to make sure zlevarsetfn() is
    called [this should have been in setintenv() long ago];
  * Calls setintenv() everywhere that COLUMNS and LINES change, not just
    from adjustwinsize();
  * In adjustwinsize(), changes LINES, COLUMNS, USEZLE, and SINGLINEZLE
    -before- calling refresh(), so that refresh() can take care of the
    setting of shortterm;
  * Changes Geoff's safety code in adjustwinsize() to a DPUTS() so we
    can see if the other code ever fails.

Can anybody see anything wrong with this?  The one change I'm uncertain
about is reversing the order of setting columns and lines with calling
of refresh(), but it sure looked wrong to me the way it was.

diff -ru zsh-3.0.3-test4-patch/Src/init.c zsh-3.0.3-test4-work/Src/init.c
--- zsh-3.0.3-test4-patch/Src/init.c	Fri Jan 31 21:24:10 1997
+++ zsh-3.0.3-test4-work/Src/init.c	Mon Feb  3 09:16:50 1997
@@ -61,7 +61,7 @@
     opts[LOGINSHELL] = (**argv == '-');
     opts[MONITOR] = 1;   /* may be unset in init_io() */
     opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid());
-    opts[USEZLE] = 1;   /* may be unset in init_io() */
+    opts[USEZLE] = 1;   /* may be unset in init_io() or setupvals() */
     parseargs(argv);   /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
 
     SHTTY = -1;
@@ -541,14 +541,8 @@
     term  = ztrdup("");
 
 #ifdef TIOCGWINSZ
-    if (!(columns = shttyinfo.winsize.ws_col))
-	columns = 80;
-    if (columns < 2)
-	opts[USEZLE] = 0;
-    if (!(lines = shttyinfo.winsize.ws_row))
-	lines = 24;
-    if (lines < 2)
-	opts[SINGLELINEZLE] = 1;
+    setintenv("COLUMNS", shttyinfo.winsize.ws_col); /* Fixes USEZLE */
+    setintenv("LINES", shttyinfo.winsize.ws_row);   /* Fixes SINGLELINEZLE */
 #else
     columns = 80;
     lines = 24;
diff -ru zsh-3.0.3-test4-patch/Src/params.c zsh-3.0.3-test4-work/Src/params.c
--- zsh-3.0.3-test4-patch/Src/params.c	Fri Jan 31 21:24:10 1997
+++ zsh-3.0.3-test4-work/Src/params.c	Mon Feb  3 09:12:07 1997
@@ -882,6 +882,7 @@
     char buf[DIGBUFSIZE];
 
     if ((pm = (Param) paramtab->getnode(paramtab, s)) && pm->env) {
+	(pm->sets.ifn)(pm, val);
 	sprintf(buf, "%ld", val);
 	pm->env = replenv(pm->env, buf);
     }
@@ -1246,16 +1247,16 @@
 void
 zlevarsetfn(Param pm, long x)
 {
-    if (x < 2) {
+    if (x < 3) {
 	if ((long *)pm->data == & columns) {
 	    if (x <= 0)
-		x = 80;		/* Arbitary, but same as init.c */
+		x = 80;		/* Arbitary */
 	    else
-		x = 2;
+		x = 3;
 	    opts[USEZLE] = 0;
 	} else if ((long *)pm->data == & lines) {
 	    if (x <= 0)
-		x = 24;		/* Arbitrary, but same as init.c */
+		x = 24;		/* Arbitrary */
 	    else
 		opts[SINGLELINEZLE] = 1;
 	}
diff -ru zsh-3.0.3-test4-patch/Src/utils.c zsh-3.0.3-test4-work/Src/utils.c
--- zsh-3.0.3-test4-patch/Src/utils.c	Mon Feb  3 08:29:36 1997
+++ zsh-3.0.3-test4-work/Src/utils.c	Mon Feb  3 09:32:19 1997
@@ -850,24 +850,19 @@
 	columns = shttyinfo.winsize.ws_col;
     if (shttyinfo.winsize.ws_row)
 	lines = shttyinfo.winsize.ws_row;
-    if (oldcols != columns) {
-	if (columns < 2)
-	    opts[USEZLE] = 0;
-	if (lines < 2)
-	    opts[SINGLELINEZLE] = 1;
+    if (oldcols != columns || oldrows != lines) {
+	if (oldcols != columns)
+	    setintenv("COLUMNS", columns);
+	if (oldrows != lines)
+	    setintenv("LINES", lines);
 	if (zleactive) {
 	    resetneeded = winchanged = 1;
 	    refresh();
 	}
-	setintenv("COLUMNS", columns);
     }
-    if (oldrows != lines)
-	setintenv("LINES", lines);
 #endif   /*  TIOCGWINSZ */
-    if (isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3) /* safety */
-	shortterm = 1;
-    else
-	shortterm = 0;
+    DPUTS((!(isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3)
+	   != !shortterm), "BUG: shortterm wrong in adjustwinsize");
 }
 
 /* Move a fd to a place >= 10 and mark the new fd in fdtable.  If the fd *

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern



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