VT100/UNIX Aegis VT100/UNIX
NAME
vt100/unix - Using the vt100 emulator with a Remote UNIX System Running
'termcap'
DESCRIPTION
The following are some tips for using the vt100 emulator when the remote
host is a UNIX system that has the termcap facility.
Most users set the term and termcap environment variables by running the
BSD 'tset' program (/bsd4.3/usr/ucb/tset) in their .login or .profile
startup files. When logging in to UNIX system through the vt100
emulator, you should specify that your terminal is a vt132, which is a
vt100 with insert/delete character and insert/delete lines capabilities.
The only difference is that a real vt132 is always 24 lines by 80
columns, and the emulator will use as many lines and columns as will fit
in the DM window. However, you can automatically modify your termcap
variable at login time so that the li and co capabilities reflect the
actual size of the emulator screen. To do so, place the following two
lines, or something similar, in your .login file (this would need to be
changed slightly for use in a .profile file):
tset -Q -I -s vt132 >tset1.$$; setsize <tset1.$$ >tset.$$
source tset.$$; stty nl0; rm tset.$$ tset1.$$
where setsize is the following c-shell script:
#!/bin/csh
set size=`sz`
set lines=$size[1]
set columns=$size[2]
sed -e "s/li#[0-9]*:/li#${lines}:/" -e "s/co#[0-9]*:/co#${columns}:/"
and sz is a C program, shown below:
#include <stdio.h>
#include <sgtty.h>
#include <sys/file.h>
main()
{
FILE *fp;
int fd, lines, columns;
struct sgttyb otty, ntty;
if ((fd = open("/dev/tty",O_RDWR,777)) < 0)
perror("open"), exit(1);
if ((fp = fdopen(fd, "r")) == NULL)
perror("fdopen"), exit(2);
if (gtty(fd, &otty) < 0)
perror("gtty"), exit(3);
ntty = otty;
ntty.sg_flags = (ntty.sg_flags & ~ECHO) | RAW;
stty(fd, &ntty);
write(fd, "\033[50n", 5);
fscanf(fp, "\033[%d;%dS", &lines, &columns);
stty(fd, &otty);
printf("%d %d\n", lines, columns);
close(fd);
}
This program sends ESC[50n to the emulator. This is a non-standard
escape sequence, in response to which the emulator sends back the
current screen size, in the form ESC[nn;mmS, where nn is the number of
lines, and mm is the number of columns.
Note:
In order for programs such as 'vi' to work properly in windows
larger than 24 lines, there is one change you must make to the
termcap entry for vt100. The sf (scroll forward) capability is
given as sf=30\E7\E[24H\ED\E8. This works by saving the cursor (ESC
7), moving to the bottom line (ESC[24H, which moves the cursor to
the 24th line), doing an index operation (ESC D), and restoring the
cursor (ESC 8). The problem, of course, is that line 24 may not be
the bottom line. This can be fixed by changing the 24 to some very
large number, say 200, since trying to move the cursor outside the
bounds of the screen always causes it to be placed at the edge of
the screen. Thus this change is safe to make, even when a real
vt100 terminal is being used.