zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: <hzoli@vnet.ibm.com> (Zoltan T. Hidvegi), zsh-workers@math.gatech.edu
Cc: gwing@primenet.com.au
Subject: Re: zle_refresh patch 2
Date: Wed, 5 Mar 1997 15:06:05 -0800	[thread overview]
Message-ID: <970305150606.ZM7318@candle.brasslantern.com> (raw)
In-Reply-To: "Bart Schaefer" <schaefer@candle.brasslantern.com> "Re: zle_refresh patch 2" (Mar  5,  1:55pm)

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


  reply	other threads:[~1997-03-05 23:14 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
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 [this message]
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=970305150606.ZM7318@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=gwing@primenet.com.au \
    --cc=hzoli@vnet.ibm.com \
    --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).