Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
COLUMNS/LINES environment variable
- X-seq: zsh-workers 6512
- From: Tatsuo Furukawa <frkwtto@xxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: COLUMNS/LINES environment variable
- Date: Tue, 08 Jun 1999 04:13:42 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Hello, zsh developers.
I have a complaint for following zsh action.
1. When terminal is resized, COLUMNS/LINES shell variable is changed
(that's OK), but COLUMNS/LINES environment variable is NOT changed.
This means that there is a difference between shell variable and
environment variable. [zsh-3.1.5-pws20, zsh-3.0.6-pre4]
2. COLUMNS/LINES cannot be exported. "export COLUMNS" command is
void. [zsh-3.0.6-pre4]
3. COLUMNS/LINES seems to be exported. But it doesn't. "export
COLUMNS" command changes COLUMNS environment variable ONLY once.
When terminal size is changed again, COLUMNS environment variable
is not changed. [zsh-3.1.5-pws20]
Ancient zsh does not act so.
This change is executed after zsh-3.0.4 release, and zsh-3.0.5 has
this code. (And this code also included zsh-3.1.5-pws-XX.)
"ChangeLog" file has following entry. This change is made internally
by Zoltan, who is zsh maintainer. This change was not discussed on
the zsh mailing list. So, Zoltan ONLY knows exact reason.
>> Tue Sep 16 04:43:25 1997 Zolt.. Hidv..i <hzoli@xxxxxxxxxx>
>>
>> * Src/zle_tricky.c: Show explanation if there are no or more
>> than one possible completions.
>>
>> * Src/glob.c: Glob after ((#)) with extendedglob set caused
>> a coredump
>>
>> * Src/builtin.c: read -k sometimes caused a coredump
>>
>> * Src/jobs.c, Src/init.c, Src/params.c, Src/signals.c,
>> Src/utils.c: Setting LINES and COLUMNS manually now works,
>> and it is equivalent to stty rows and stty columns.
According this log, it seems that he just wanted to be same "stty
columns/lines" and "LINES/COLUMNS". Because ancient zsh has a feature
that LINES/COLUMNS are set when stty rows/columns is executed.
NOTE: This is executed as follows:
1. stty rows/columns is executed.
2. SIGWINCH is invoked.
3. zsh recieves SIGWINCH.
4. COLUMNS/LINES is changed.
But now zsh does not act such that. Current zsh receives SIGWINCH,
but it does not change COLUMNS/LINES environment variable.
I think this is just a bug. Because there is NO reason for deleting
this feature. And ksh/sh/bash/etc... has this feature, so zsh should
has it too! I beleve that it is needed for zsh users. (Zoltan, if you
read this mail, please comment it!)
------------------------------------------------------------------------------
Then, I want to propose the feature for terminal size.
1. Following three value is ALWAYS same.
- Environment variable COLUMNS/LINES.
- Shell variable COLUMNS/LINES.
- The value held by TIOCGWINSZ.
2. When starting zsh, terminal size are set by environment variable
COLUMNS/LINES.
3. When user sets value into COLUMNS/LINES explicitly, zsh also set
TIOCSWINSZ.
4. When user sets 0 to COLUMNS/LINES, zsh measures terminal size (by
TIOCGWINSZ), and sets it.
5. When COLUMNS/LINES is "unset", COLUMNS/LINES are deleted.
6. When terminal is resized (by mouse), zsh measures terminal size,
and sets LINES/COLUMNS.
7. After some command is executed, zsh measures terminal size, and
sets LINES/COLUMNS.
------------------------------------------------------------------------------
And here is the patch for realizing this proposal. :-)
This patch is for zsh-3.1.5-pws20. I can make this patch for
zsh-3.0.6-pre4.
diff -urb zsh-3.1.5-pws-20/Src/utils.c zsh-3.1.5-pws-20-modified/Src/utils.c
--- zsh-3.1.5-pws-20/Src/utils.c Mon May 17 00:32:15 1999
+++ zsh-3.1.5-pws-20-modified/Src/utils.c Tue Jun 8 03:59:59 1999
@@ -865,30 +865,46 @@
adjustwinsize(int from)
{
int oldcols = columns, oldrows = lines;
+ int term_columns = 0, term_lines = 0;
+ static int adjusting = 0;
+ int size_changed = 0;
#ifdef TIOCGWINSZ
- static int userlines, usercols;
-
if (SHTTY == -1)
return;
+#endif /* TIOCGWINSZ */
- if (from == 2)
- userlines = lines > 0;
- if (from == 3)
- usercols = columns > 0;
+ /* To prevent recursion */
+ if (adjusting)
+ return;
+ adjusting = 1;
+
+#ifdef TIOCGWINSZ
if (!ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize)) {
- if (!userlines || from == 1)
- lines = shttyinfo.winsize.ws_row;
- if (!usercols || from == 1)
- columns = shttyinfo.winsize.ws_col;
+ term_lines = shttyinfo.winsize.ws_row;
+ term_columns = shttyinfo.winsize.ws_col;
}
+
+ if ((from == 0) || (from == 1)) {
+ lines = term_lines;
+ columns = term_columns;
+ }
+
+ if ((from == 2) && (lines <= 0))
+ lines = term_lines;
+ if ((from == 3) && (columns <= 0))
+ columns = term_columns;
#endif /* TIOCGWINSZ */
+
+ /* When lines/columns are invalid value... */
if (lines <= 0)
lines = tclines > 0 ? tclines : 24;
if (columns <= 0)
columns = tccolumns > 0 ? tccolumns : 80;
+
+ /* setting termflags */
if (lines > 2)
termflags &= ~TERM_SHORT;
else
@@ -898,18 +914,37 @@
else
termflags |= TERM_NARROW;
+
#ifdef TIOCGWINSZ
- if (interact && from >= 2) {
+ if (interact && (lines != term_lines || columns != term_columns)) {
shttyinfo.winsize.ws_row = lines;
shttyinfo.winsize.ws_col = columns;
ioctl(SHTTY, TIOCSWINSZ, (char *)&shttyinfo.winsize);
+ size_changed = 1;
}
#endif
- if (zleactive && (from >= 2 || oldcols != columns || oldrows != lines)) {
+ if (interact) {
+ if (oldcols != columns) {
+ if (getsparam("COLUMNS")) { /* check whether "COLUMNS" is exist or not */
+ setiparam("COLUMNS", columns);
+ size_changed = 1;
+ }
+ }
+ if (oldrows != lines) {
+ if (getsparam("LINES")) { /* check whether "LINES" is exist or not */
+ setiparam("LINES", lines);
+ size_changed = 1;
+ }
+ }
+ }
+
+ if (zleactive && size_changed) {
resetneeded = winchanged = 1;
zrefresh();
}
+
+ adjusting = 0;
}
/* Move a fd to a place >= 10 and mark the new fd in fdtable. If the fd *
--
Tatsuo Furukawa (frkwtto@xxxxxxxxxxxxxxx)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author