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

Re: zle_refresh patch 2



On Mar 5,  1:55pm, Bart Schaefer wrote:
} Subject: Re: zle_refresh patch 2
}
} On Mar 5,  3:56pm,  (Zoltan T. Hidvegi) wrote:
} } Subject: Re: zle_refresh patch 2
} }
} } I'm not exactly sure that it is a good idea to explicitely set
} } SINGLELINEZLE when the terminal shrinks to one or two lines.
} 
} Yes; I already agreed about that in response to a posting from Geoff on
} Feb. 3.  The code is as it is now (and I changed it as I did in that
} patch) because I didn't know about the meaning of "termok".

Way back on Feb. 3, Bart Schaefer wrote:
} 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.

Here's a new patch, having (I hope) the same semantics described above,
but modified to change "termok" in zlevarsetfn() instead of changing the
values of opts[SINGLELINEZLE] and opts[ZLE].  I have not extensively
tested this; the pre-Geoff's-patch code never tests (termok == TERM_NOUP),
so Geoff's "shortterm" patch is still needed for this one to make sense.

This patch is against the base 3.0.3-test4, so there may be a conflict in
the utils.c hunk with Geoff's patch.  Nevertheless, the rest of Geoff's
patch (to the zle* files) is required.

BTW, there's an "if (x <= 0) ... else x = 2;" in there that was originally
to prevent core dumps that occurred when (lines == 1) became true.  It's
possible that is no longer necessary.

diff -ru zsh-3.0.3-test4/Src/init.c zsh-3.0.3-test4-work/Src/init.c
--- zsh-3.0.3-test4/Src/init.c	Fri Jan 31 21:24:10 1997
+++ zsh-3.0.3-test4-work/Src/init.c	Wed Mar  5 14:35:13 1997
@@ -540,20 +540,6 @@
     mypid = (long) getpid();
     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;
-#else
-    columns = 80;
-    lines = 24;
-#endif
-
     /* The following variable assignments cause zsh to behave more *
      * like Bourne and Korn shells when invoked as "sh" or "ksh".  *
      * NULLCMD=":" and READNULLCMD=":"                             */
@@ -601,6 +587,14 @@
     createcompctltable();   /* create hash table for compctls          */
     createnameddirtable();  /* create hash table for named directories */
     createparamtable();     /* create paramater hash table             */
+
+#ifdef TIOCGWINSZ
+    setintenv("COLUMNS", shttyinfo.winsize.ws_col); /* Fixes termok */
+    setintenv("LINES", shttyinfo.winsize.ws_row);   /* Fixes termok */
+#else
+    columns = 80;
+    lines = 24;
+#endif
 
     /* create hash table for multi-character emacs bindings */
     createemkeybindtable();
diff -ru zsh-3.0.3-test4/Src/params.c zsh-3.0.3-test4-work/Src/params.c
--- zsh-3.0.3-test4/Src/params.c	Fri Jan 31 21:24:10 1997
+++ zsh-3.0.3-test4-work/Src/params.c	Wed Mar  5 14:35:13 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,21 +1247,32 @@
 void
 zlevarsetfn(Param pm, long x)
 {
-    if (x < 2) {
-	if ((long *)pm->data == & columns) {
+    int resetneeded = 0;
+
+    if ((long *)pm->data == & columns) {
+	if (x < 3) {
 	    if (x <= 0)
 		x = 80;		/* Arbitary, but same as init.c */
 	    else
-		x = 2;
-	    opts[USEZLE] = 0;
-	} else if ((long *)pm->data == & lines) {
+		x = 2;
+	    termok = TERM_BAD;
+	} else if (columns < 3)
+	    resetneeded = 1;
+    } else if ((long *)pm->data == & lines) {
+	if (x < 3) {
 	    if (x <= 0)
 		x = 24;		/* Arbitrary, but same as init.c */
-	    else
-		opts[SINGLELINEZLE] = 1;
-	}
+	    termok = TERM_NOUP;
+	} else if (lines < 3)
+	    resetneeded = 1;
     }
+
     *((long *)pm->data) = x;
+
+    if (resetneeded) {
+	if (lines > 3 && columns > 3 && termok != TERM_OK)
+	    init_term();	/* Attempt to reset termok properly */
+    }
 }
 
 /* Function to set value of generic special scalar    *
diff -ru zsh-3.0.3-test4/Src/utils.c zsh-3.0.3-test4-work/Src/utils.c
--- zsh-3.0.3-test4/Src/utils.c	Fri Jan 31 21:24:10 1997
+++ zsh-3.0.3-test4-work/Src/utils.c	Mon Feb  3 09:32:19 1997
@@ -850,20 +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 */
+    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