[net.sources] 3B2 and 'tset'

hansen@pegasus.UUCP (Tony L. Hansen) (09/20/85)

< Back in the good(?) old days of System III and Version 7 there was a
< terminal initialization program called 'tset'.  Even though this is still
< referenced in the 3B2 documentation in TERMINFO(4) I can find neither hide
< nor hair of it.  If anyone has implemented the equivalent function or knows
< of one I would very much appreciate hearing about it.

[I've cross-posted this to net.unix and net.unix-wizards because a similar
question was posted in those newsgroups a couple of months ago and I never
got around to replying to the question back then.]

The tset program, created by Eric Allman at Berkeley, has several major
functions:

    1) determine the terminal type for setting $TERM,
    2) initialize the terminal for screen-oriented programs,
    3) initialize the carriage-return and newline delays in the tty driver,
    4) set the erase/kill/interrupt characters,
    5) initialize $TERMCAP, and,
    6) reinitializing (resetting) the terminal.

Number 5, setting $TERMCAP, is obviously not needed anymore with terminfo.
Using the compiled terminfo entry is still faster than interpreting from the
$TERMCAP variable.

Number 4, setting ^H, etc., is handled just fine by stty.

Personally I believe that number 1, setting $TERM, belongs in a separate
program from the program that does numbers 2 and 3. A simple invocation of
such a program, call it "getterm", would be:

	TERM=`getterm`; export TERM
or
	setenv TERM `getterm`

Of course, this program should do everything that tset used to do: looking
in a database of hardwired lines and looking at your tty speed, then
assuming or asking questions based on what it found.

Number 2 is the most crucial step, terminal initialization. It is fairly
easy to handle because of a tool provided with Unix System Vr2 called
tput(1). My version of how to do terminal initialization follows. I call
this shell "initterm".

	# initterm - initialize the terminal like tset used to do.
	eval `tput iprog`
	tput is1
	tput is2
	if [ -n "`tput ht`" ]
	then stty tabs; tabs -8
	else stty -tabs
	fi
	cat -s "`tput if`"
	tput is3

Number 3, setting the carriage-return/newline delays, is non-trivial. If a
program were written to do such a thing, it should be done after the above.

Number 6, reset, could be done with very slight modifications to the above
script, such as:

	RS1=`tput rs1`
	if [ -n "$RS1" ]
	then echo "$RS1"
	else tput is1
	fi

for each of the rs1/is1, rs2/is2, rs3/is3 and rf/if pairs.

I hope that all of this helps.

					Tony Hansen
					ihnp4!pegasus!hansen

greg@ncr-sd.UUCP (Greg Noel) (09/24/85)

>< Back in the good(?) old days of System III and Version 7 there was a
>< terminal initialization program called 'tset'.  Even though this is still
>< referenced in the 3B2 documentation in TERMINFO(4) I can find neither hide
>< nor hair of it.  If anyone has implemented the equivalent function or knows
>< of one I would very much appreciate hearing about it.

I've had this same complaint.  The answer I've received has been that the
"tabs" program is supposed to do terminal-specific initialization.  Now, while
there is a certain kind of sideways logic to using "tabs" that way, the problem
is that "tabs" doesn't do it -- in fact, the version we have doesn't even know
about curses/terminfo; it has wired-in knowledge about a few specific terminals
and makes no attempt whatever to send out generic initialization strings, nor
is it smart about baud rates or terminal padding.

I don't care if the logic is in "tabs", "tset", or a totally new program; this
information is readily available via terminfo and it should be usable somehow.
Like the directory-reading routines, this is an area where AT&T has dropped the
ball and probably needs some encouragement to get its act together.  Maybe if
we knew where we could send some nastygrams, we could inundate them with memos
until they saw the light........
-- 
-- Greg Noel, NCR Rancho Bernardo    Greg@ncr-sd.UUCP or Greg@nosc.ARPA