Sidebar: Static vs. Dynamic Windows
The decision to register lines and columns as a terminal
capability
dates from the time when terminals (and thus applications)
could support
only static window sizes. Since many terminals now can
switch between
80- and 132-column modes and many other "terminals"
are actually a
window on a graphical work station, the hardware no
longer forces the
window size to be fixed. A lot of older software depends
on the
automatic margin behavior in combination with a static
column count from
the terminfo description. Output from such applications
can become
seriously scrambled if the window size changes during
the session. More
recent software sometimes tries to be more dynamic,
and looks at shell
variables LINES and COLS or COLUMNS (many implementations
of the ls
command are a good example of this). Even these applications,
however,
still assume that the number of columns does not vary
during the
lifetime of the process invocation.
The X Window System generates a "window change
event" when a user
changes some window dimensions. The X server sends this
notification to
the xterm client via X protocol messages. xterm reacts
by adapting
kernel parameters at the ioctl/stty level for the pseudo-tty
which
connects it to the application. Addition of these lines/columns
parameters at the terminal line discipline level inside
the kernel
happened fairly recently, and was the appropriate reaction
to the
appearance of a windowing environment. The application
running inside
the xterm window is supposed to ask for up-to-date numbers
from its pty
every time it generates new screen output. Alternatively,
the
application may choose to catch the Window Change signal
which xterm
generates at every change (default behavior for this
signal is SIG_IGN,
so older applications which don't even know about the
existence of this
mechanism don't notice it either). Modern versions of
vi and pg are good
examples of this dynamic adaptation.
|