zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: gwing@primenet.com.au, zsh-workers@math.gatech.edu (zsh-workers)
Subject: Re: zle_refresh patch 2
Date: Mon, 3 Feb 1997 10:05:07 -0800	[thread overview]
Message-ID: <970203100507.ZM10555@candle.brasslantern.com> (raw)
In-Reply-To: gwing@primenet.com.au "zle_refresh patch 2" (Feb  3,  9:55pm)

On Feb 3,  9:55pm, gwing@primenet.com.au 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


  reply	other threads:[~1997-02-03 18:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-03 10:55 gwing
1997-02-03 18:05 ` Bart Schaefer [this message]
1997-02-03 18:34   ` gwing
1997-02-03 19:03     ` Bart Schaefer
1997-02-04  8:25     ` Peter Stephenson
1997-03-05 20:56   ` Zoltan T. Hidvegi
1997-03-05 21:55     ` Bart Schaefer
1997-03-05 23:06       ` Bart Schaefer
1997-03-05 23:47         ` Zoltan T. Hidvegi
1997-03-06  0:51           ` Bart Schaefer
1997-03-06  3:56             ` gwing
1997-03-06  4:58               ` Bart Schaefer
1997-03-06  5:03                 ` gwing
1997-03-06 18:32                   ` Zoltan T. Hidvegi
1997-03-06 18:58             ` Zoltan T. Hidvegi
1997-03-05 23:52 Zoltan T. Hidvegi

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=970203100507.ZM10555@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=gwing@primenet.com.au \
    --cc=schaefer@nbn.com \
    --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).