From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 754 invoked from network); 24 Oct 1998 10:55:00 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 24 Oct 1998 10:55:00 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id GAA09602; Sat, 24 Oct 1998 06:47:50 -0400 (EDT) Resent-Date: Sat, 24 Oct 1998 06:47:50 -0400 (EDT) Message-Id: <199810241051.TAA14130@pop1.ngy.3web.ne.jp> From: Tatsuo Furukawa To: zsh-workers@math.gatech.edu Cc: olsenc@ichips.intel.com Subject: [3.0.5] patch for resize problem Mime-Version: 1.0 (generated by tm-edit 7.52) Content-Type: text/plain; charset=US-ASCII Date: Sat, 24 Oct 1998 19:52:56 +0900 X-Dispatcher: impost version 0.99i (Apr. 6, 1997) Resent-Message-ID: <"SB9x02.0.zL2.L1RCs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4446 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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)