zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Tatsuo Furukawa <frkwtto@osk3.3web.ne.jp>, zsh-workers@sunsite.auc.dk
Subject: Re: COLUMNS/LINES environment variable
Date: Mon, 7 Jun 1999 21:59:07 +0000	[thread overview]
Message-ID: <990607215907.ZM19785@candle.brasslantern.com> (raw)
In-Reply-To: <199906071911.EAA12590@pop1.ngy.3web.ne.jp>

On Jun 8,  4:13am, Tatsuo Furukawa wrote:
> Subject: COLUMNS/LINES environment variable
> 
> 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.

I think it was discussed, though perhaps how the code eventually ended
up is not reflected in any specific patch.  Here are some messages about
it (sorry for not having zsh-workers article numbers, I'm searching an
experimental archive that happens to be using zsh-workers messages as
test cases but doesn't spit out the X- headers yet):

Date	 Sender					Subject
03/30/97 zefram@dcs.warwick.ac.uk		setting window size
03/31/97 zefram@dcs.warwick.ac.uk		window size bugfix
05/18/97 hzoli@ny.frontiercomm.net		More LINES/COLUMNS changes
05/10/97 schaefer@candle.brasslantern.com	Re: test patches
05/10/97 hzoli@ny.frontiercomm.net		Re: test patches
12/09/97 schaefer@brasslantern.com		zsh 3.0.5 WINSZ stuff is
						messing up my vi
12/09/97 schaefer@brasslantern.com		PATCH: 3.0.5: terminal size
						should not be reset by zsh -c

> But now zsh does not act such that.  Current zsh receives SIGWINCH,
> but it does not change COLUMNS/LINES environment variable.

3.0.5 doesn't even change the internal lines/columns on WINCH.  (We had
this conversation last October.)

> I think this is just a bug.

The export should probably have occurred when the internal lines/columns
are updated.  I didn't put that into the patch that started recognizing
SIGWINCH again.

> 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.

There's an additional source of lines/columns information:  The terminal
information database (either termcap or terminfo).  The problem with
asserting "value is ALWAYS same" is that, at shell startup, you may have
three conflicting values for terminal size.  Any one of them may be wrong
in various circumstances, and it's difficult/impossible to cause the
term{cap,info} one to change.  Which one do we believe?

> 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.

The startup code in init.c calls adjustwinsize(0), which means "believe
the environment first, and if that produces zero, then (if TIOCGWINSZ
works) believe the terminal driver or (otherwise) termcap."  However,
we still don't know which of those was actually correct, so we do not
impose the environment on the terminal driver unless LINES/COLUMNS are
explicitly set [adjustwinsize(2) or adjustwinsize(3)].

> 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.

These should all be happening, except for the oversight about exporting
LINES/COLUMNS.

> 7. After some command is executed, zsh measures terminal size, and
>    sets LINES/COLUMNS.

This is where we ran into trouble before.  "After some command" you are
back in the same boat as you are at shell startup -- you have no idea if
the terminal was resized during the external command or if the tty driver
values for lines/columns have simply been wrong all along.  So we chose
to do nothing (again unless COLUMNS/LINES give no information).

Probably in that last case we could see whether the tty driver values of
lines/columns actually changed since the last TIOCGWINSZ, and elect to
believe them in that event.

The correct course for the user is to explicitly set LINES/COLUMNS if he
knows the correct values [e.g. eval $(resize)] or to unset them if he
knows that the terminal driver has the right values.  (Hmm, there isn't
any way to assert that the termcap entry is correct ....)  We should
document this somewhere, at least in the FAQ, and fix any export issues.


  reply	other threads:[~1999-06-07 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-07 19:13 Tatsuo Furukawa
1999-06-07 21:59 ` Bart Schaefer [this message]
1999-06-09 17:13   ` Tatsuo Furukawa
1999-06-09 18:08     ` Bart Schaefer

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=990607215907.ZM19785@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=frkwtto@osk3.3web.ne.jp \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).