ttydX and xterm size (LINES and COLUMNS understanding)

Dan Nelson dnelson at allantgroup.com
Mon Mar 7 23:29:20 PST 2005


In the last episode (Mar 08), Emanuel Strobl said:
> When I open a xterm on the local machine, say with 100x37, vi and man
> recognizes the size and display the content correctly. If I use
> cu/tip in a 100x37 xterm "ls" works fine (uses all lines) as long as
> I start vi but man doesn't work (no scrolling possible). After the vi
> session only 24 lines (or whatever type I set in /etc/ttys) are used,
> but man works correctly. Why can I use different terminal sizes on
> the local machine and in ssh sessions but not over a serial console?
> If I set "setenv LINES 37" and "setenv COLUMNS 100" it works also on
> the serial line but why or how can vi and others know what size my
> terminal is via ssh session? I'm sure this behaviour is adoptable to
> serial consoles too.

Telnet and ssh have out-of-band control sequences that let the client
pass things like terminal size to the server.  There's no equivalent
for serial lines.  You can get the screen size from vt100 terminals
(and many emulators) though, by moving the cursor to the far
lower-right corner, asking the terminal for the cursor position, and
reading the result on stdin.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list