From: Tatsuo Furukawa <frkwtto@wnn.club.or.jp>
To: zsh-workers@math.gatech.edu
Cc: olsenc@ichips.intel.com
Subject: [3.0.5] patch for resize problem
Date: Sat, 24 Oct 1998 19:52:56 +0900 [thread overview]
Message-ID: <199810241051.TAA14130@pop1.ngy.3web.ne.jp> (raw)
Hello zsh developpers.
I fixed the zsh 3.0.5 resize problem. Which is already reported by
Clint Olsen. (archive ID is 3968, 3985-3989)
What is "resize problem"?
===========================
Zsh 3.0.5 believes LINES and COLUMNS fanatically. If I changed
terminal size, SIGWINCH is sent to zsh, but zsh does not measure
terminal size. This symptoms is observed only 3.0.5.
To confirm this, execute following script:
-------------- CUT here ------------------
#/do/not/write/like/a/bin/zsh
#
while
do
ENV_COL=`env | grep COLUMNS`
echo $ZSH_VERSION "\t" $COLUMNS "\t" $ENV_COL
sleep 1
done
-------------- CUT here ------------------
and execure as follows:
$ /bin/zsh this-script
This script prints terminal width forever. Then, change the terminal
width. What will be observed?
zsh-3.0.2 New terminal width is printed.
zsh-3.0.5 Old terminal width is still printed.
zsh-3.1.2 New terminal width is printed.
zsh-3.1.4 New terminal width is printed.
3.0.5 is different. I (and maybe Clint) hope that 3.0.5 acts same.
The Patch
===========
I incorporated 3.1.4's resize code into 3.0.5. And it works well. I
made a patch. This patch is for 3.0.5. I recommend that this patch
will be adopted 3.0.6.
diff -ur zsh-3.0.5/Src/init.c zsh-3.0.5-column/Src/init.c
--- zsh-3.0.5/Src/init.c Fri Sep 26 10:42:16 1997
+++ zsh-3.0.5-column/Src/init.c Fri Oct 23 18:45:14 1998
@@ -602,13 +602,13 @@
createparamtable(); /* create paramater hash table */
#ifdef TIOCGWINSZ
- adjustwinsize(0);
+ adjustwinsize();
#else
/* columns and lines are normally zero, unless something different *
* was inhereted from the environment. If either of them are zero *
* the setiparam calls below set them to the defaults from termcap */
- setiparam("COLUMNS", columns);
- setiparam("LINES", lines);
+ setiparam("COLUMNS", 0);
+ setiparam("LINES", 0);
#endif
/* create hash table for multi-character emacs bindings */
diff -ur zsh-3.0.5/Src/jobs.c zsh-3.0.5-column/Src/jobs.c
--- zsh-3.0.5/Src/jobs.c Fri Sep 26 10:42:17 1997
+++ zsh-3.0.5-column/Src/jobs.c Fri Oct 23 18:45:40 1998
@@ -166,7 +166,7 @@
if (mypgrp != pgrp && inforeground &&
(jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))) {
attachtty(mypgrp);
- adjustwinsize(0); /* check window size and adjust if necessary */
+ adjustwinsize(); /* check window size and adjust if necessary */
}
}
diff -ur zsh-3.0.5/Src/params.c zsh-3.0.5-column/Src/params.c
--- zsh-3.0.5/Src/params.c Fri Sep 26 10:42:17 1997
+++ zsh-3.0.5-column/Src/params.c Fri Oct 23 18:52:30 1998
@@ -1242,9 +1242,23 @@
{
long *p = (long *)pm->data;
+ if (p == & columns) {
+ if(x <= 0)
+ x = tccolumns > 0 ? tccolumns : 80;
+ if (x > 2)
+ termflags &= ~TERM_NARROW;
+ else
+ termflags |= TERM_NARROW;
+ } else if (p == & lines) {
+ if(x <= 0)
+ x = tclines > 0 ? tclines : 24;
+ if (x > 2)
+ termflags &= ~TERM_SHORT;
+ else
+ termflags |= TERM_SHORT;
+ }
+
*p = x;
- if (p == &lines || p == &columns)
- adjustwinsize(2 + (p == &columns));
}
/* Function to set value of generic special scalar *
diff -ur zsh-3.0.5/Src/signals.c zsh-3.0.5-column/Src/signals.c
--- zsh-3.0.5/Src/signals.c Fri Sep 26 10:42:18 1997
+++ zsh-3.0.5-column/Src/signals.c Fri Oct 23 18:46:01 1998
@@ -485,7 +485,7 @@
#ifdef SIGWINCH
case SIGWINCH:
- adjustwinsize(1); /* check window size and adjust */
+ adjustwinsize(); /* check window size and adjust */
if (sigtrapped[SIGWINCH])
dotrap(SIGWINCH);
break;
diff -ur zsh-3.0.5/Src/utils.c zsh-3.0.5-column/Src/utils.c
--- zsh-3.0.5/Src/utils.c Fri Sep 26 10:42:18 1997
+++ zsh-3.0.5-column/Src/utils.c Fri Oct 23 18:43:37 1998
@@ -828,63 +828,26 @@
extern winchanged;
#endif
-/* check the size of the window and adjust if necessary. *
- * The value of from: *
- * 0: called from update_job or setupvals *
- * 1: called from the SIGWINCH handler *
- * 2: the user have just changed LINES manually *
- * 3: the user have just changed COLUMNS manually */
+/* check the size of the window and adjust if necessary */
/**/
void
-adjustwinsize(int from)
+adjustwinsize(void)
{
- int oldcols = columns, oldrows = lines;
-
#ifdef TIOCGWINSZ
- static int userlines, usercols;
+ int oldcols = columns, oldrows = lines;
if (SHTTY == -1)
return;
- if (from == 2)
- userlines = lines > 0;
- if (from == 3)
- usercols = columns > 0;
-
- if (!ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize)) {
- if (!userlines)
- lines = shttyinfo.winsize.ws_row;
- if (!usercols)
- columns = shttyinfo.winsize.ws_col;
- }
-#endif /* TIOCGWINSZ */
-
- if (lines <= 0)
- lines = tclines > 0 ? tclines : 24;
- if (columns <= 0)
- columns = tccolumns > 0 ? tccolumns : 80;
- if (lines > 2)
- termflags &= ~TERM_SHORT;
- else
- termflags |= TERM_SHORT;
- if (columns > 2)
- termflags &= ~TERM_NARROW;
- else
- termflags |= TERM_NARROW;
-
-#ifdef TIOCGWINSZ
- if (from >= 2) {
- shttyinfo.winsize.ws_row = lines;
- shttyinfo.winsize.ws_col = columns;
- ioctl(SHTTY, TIOCSWINSZ, (char *)&shttyinfo.winsize);
- }
-#endif
-
- if (zleactive && (from >= 2 || oldcols != columns || oldrows != lines)) {
+ ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize);
+ setiparam("COLUMNS", shttyinfo.winsize.ws_col);
+ setiparam("LINES", shttyinfo.winsize.ws_row);
+ if (zleactive && (oldcols != columns || oldrows != lines)) {
resetneeded = winchanged = 1;
refresh();
}
+#endif /* TIOCGWINSZ */
}
/* Move a fd to a place >= 10 and mark the new fd in fdtable. If the fd *
--
Tatsuo Furukawa (frkwtto@wnn.club.or.jp)
next reply other threads:[~1998-10-24 10:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-24 10:52 Tatsuo Furukawa [this message]
1998-10-24 18:43 ` Bart Schaefer
1998-10-27 16:22 ` Tatsuo Furukawa
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=199810241051.TAA14130@pop1.ngy.3web.ne.jp \
--to=frkwtto@wnn.club.or.jp \
--cc=olsenc@ichips.intel.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).