[comp.terminals] Lines and columns under 4.3

goldberg@su-russell.ARPA (Jeffrey Goldberg) (01/09/87)

Basically my question is is there a work around to the fact that
under 4.3 some programs (vi and more in particular) don't inspect
the termcap entry to determine the number of lines or the number of
columns of a given terminal.

I recently got an account on a 4.3 machine (a VAX 780) and I moved
some stuff over from a machine running 4.2.  What I have is my own
little termcap file that contains the entry for an hp9836 which I
found on one of the local Vaxen and works fine, and my own thing
which is just a 36 with 40 lines instead of 24.  This works fine on
the 4.2 machine, but doesn't on the 4.3 machine.  Vi and more
behave as if I were working on a 24 line terminal.

Looking at the manual page for termcap on 4.3 I find under BUGS and
CAVEATS:

"Lines and columns are now stored in the kernel as well as in the
termcap entry.  Most programs now use the kernel information
primarily; the information in this file is used only if the kernel
does not have any information."

I don't pretend to begin to understand where the kernel gets its
information about these terminals, but there is no indication that
anyone has ever defined a terminal with the name that I give it.
So I don't understand how the kernel could have prior knowledge of
it.

I do use tc extensively in my entries.  Should I just duplicate the
stuff in different entries instead of using tc?

Jeff Goldberg 
ARPA:   goldberg@russell.stanford.edu, goldberg@csli.stanford.edu
UUCP:   ...!hplabs!russell.stanford.edu!goldberg

cryptography, terrorist, DES, drugs, cipher, secret, decode,
NSA, CIA, NRO.
 The above is food for the NSA line eater.  Add it to your
 .signature and you too can help overflow the NSA's ability to
 scan all traffic going in or out of the USA looking for
 "significant" words.  (I am told that this is no joke.)

gwyn@brl-smoke.ARPA (Doug Gwyn ) (01/09/87)

In article <234@su-russell.ARPA> goldberg@su-russell.UUCP (Jeffrey Goldberg) writes:
>"Lines and columns are now stored in the kernel as well as in the
>termcap entry.  Most programs now use the kernel information
>primarily; the information in this file is used only if the kernel
>does not have any information."

The 4.3BSD kernel (following the lead of Sun and/or AT&T) maintains
information about the dimensions of each "terminal" (which may
actually be just a window on a multi-window display) in a

/*
 * Window size structure
 */
struct winsize {
	unsigned short	ws_row, ws_col;		/* character size of window */
	unsigned short	ws_xpixel, ws_ypixel;	/* pixel size of window */
};

That contains all 0 data if the "terminal" size has never been set.
The only way to set the size is via a TIOCSWINSZ ioctl, and the only
way to query the size is via a TIOCGWINSZ ioctl, both of which take
a (struct winsize *) as their third parameter.

(Note: DMD-supporting UNIX System Vs, such as SVR3, have analogous
information contained in a (struct jwinsize) with a JWINSIZE ioctl
to retrieve it; it's updated automatically inside the kernel when
a window size changes.)

The general procedure for determining a terminal's screen size is:
	1) Try a TIOCGWINSZ.  If it fails, or if it returns 0 data,
		then proceed to step 3; otherwise use the returned
		information as the terminal's screen size.
	2) Some sites have added pagination to their terminal
		handler; in this case one might be able to obtain
		the number of rows via an ioctl analogous to the
		procedure of step 1; if supported and successful
		(and non-zero!), use this value and proceed to
		step 3 just to get columns information.
	3) Try to fetch COLUMNS and/or LINES from the environment
		(if not yet known from previous steps).  If either
		is available, use it for the terminal size in that
		direction; if either is not set in the environment,
		find it out by proceeding to step 4.
	4) Get TERM from the environment and use it in a tgetent (or
		equivalent call to initialize the display-handling
		package).  The termcap capability "li" (terminfo
		"lines") is the default number of lines and termcap
		"co" (terminfo "cols") is the default number of
		columns to assume for that terminal type.
	5) If one still hasn't determined the terminal screen size,
		assume that it is an "infinite quadrant".  This
		probably isn't correct, but then it's what the user
		deserves for not setting up any information about
		his terminal.

colonel@sunybcs.UUCP (01/11/87)

I don't know about the kernel, but a lot of programs look at the
environment variable $termcap, which is set at login.  You can reset
it with "setenv".
-- 
Col. G. L. Sicherman
UU: ...{rocksvax|decvax}!sunybcs!colonel
CS: colonel@buffalo-cs
BI: colonel@sunybcs, csdsiche@ubvms

jc@piaget.UUCP (John Cornelius) (01/19/87)

In article <234@su-russell.ARPA> goldberg@su-russell.UUCP (Jeffrey Goldberg) writes:
 >Basically my question is is there a work around to the fact that
 >under 4.3 some programs (vi and more in particular) don't inspect
 >the termcap entry to determine the number of lines or the number of
 >columns of a given terminal.
 >
 >I recently got an account on a 4.3 machine (a VAX 780) and I moved
 >some stuff over from a machine running 4.2.  What I have is my own
 >little termcap file that contains the entry for an hp9836 which I
 >found on one of the local Vaxen and works fine, and my own thing
 >which is just a 36 with 40 lines instead of 24.  This works fine on
 >the 4.2 machine, but doesn't on the 4.3 machine.  Vi and more
 >behave as if I were working on a 24 line terminal.
 >
 >Looking at the manual page for termcap on 4.3 I find under BUGS and
 >CAVEATS:
 >
 >"Lines and columns are now stored in the kernel as well as in the
 >termcap entry.  Most programs now use the kernel information
 >primarily; the information in this file is used only if the kernel
 >does not have any information."
 >
 >I don't pretend to begin to understand where the kernel gets its
 >information about these terminals, but there is no indication that
 >anyone has ever defined a terminal with the name that I give it.
 >So I don't understand how the kernel could have prior knowledge of
 >it.

The command "stty rows #" where # is the number of rows causes vi
and more to work correctly.  I believe the same is true of
columns.  The command "stty everything" will show you the current
settings.  See stty(I).

 >I do use tc extensively in my entries.  Should I just duplicate the
 >stuff in different entries instead of using tc?
 >
 >Jeff Goldberg 
 >ARPA:   goldberg@russell.stanford.edu, goldberg@csli.stanford.edu
 >UUCP:   ...!hplabs!russell.stanford.edu!goldberg
 >
 >cryptography, terrorist, DES, drugs, cipher, secret, decode,
 >NSA, CIA, NRO.
 > The above is food for the NSA line eater.  Add it to your
 > .signature and you too can help overflow the NSA's ability to
 > scan all traffic going in or out of the USA looking for
 > "significant" words.  (I am told that this is no joke.)


-- 
John Cornelius
(...!sdcsvax!piaget!jc)