* Terminal initialization routines.
* %G% (Berkeley) @(#)setterm.c 1.11
static bool *sflags
[] = {
&AM
, &BS
, &EO
, &HZ
, &IN
, &MI
, &MS
, &NC
, &OS
, &UL
, &XN
&AL
, &BC
, &BT
, &CD
, &CE
, &CL
, &CM
, &CR
, &DC
,
&DL
, &DM
, &DO
, &ED
, &EI
, &HO
, &IC
, &IM
, &IP
,
&LL
, &MA
, &ND
, &NL
, &xPC
, &SE
, &SF
, &SO
, &SR
,
&TA
, &TE
, &TI
, &UC
, &UE
, &UP
, &US
, &VB
, &VS
,
static char tspace
[256], /* Space for capability strings */
*aoftspace
; /* Address of tspace for relocation */
static int destcol
, destline
;
* This routine does terminal type initialization routines, and
* calculation of flags at entry. It is almost entirely stolen from
* Bill Joy's ex version 2.6.
if (gtty(_tty_ch
, &_tty
) < 0)
if (stty(_tty_ch
, &_tty
) < 0)
_tty
.sg_flags
= _res_flg
;
_res_flg
= _tty
.sg_flags
;
UPPERCASE
= (_tty
.sg_flags
& LCASE
) != 0;
GT
= ((_tty
.sg_flags
& XTABS
) == 0);
NONL
= ((_tty
.sg_flags
& CRMOD
) == 0);
fprintf(outf
, "GETTMODE: UPPERCASE = %s\n", UPPERCASE
? "TRUE":"FALSE");
fprintf(outf
, "GETTMODE: GT = %s\n", GT
? "TRUE" : "FALSE");
fprintf(outf
, "GETTMODE: NONL = %s\n", NONL
? "TRUE" : "FALSE");
fprintf(outf
, "GETTMODE: ospeed = %d\n", ospeed
);
fprintf(outf
, "SETTERM(\"%s\")\n", type
);
fprintf(outf
, "SETTERM: LINES = %d, COLS = %d\n", LINES
, COLS
);
if (tgetent(genbuf
, type
) != 1) {
strcpy(genbuf
, "xx|dumb:");
fprintf(outf
, "SETTERM: tty = %s\n", type
);
fprintf(outf
, "SETTERM: LINES = %d, COLS = %d\n", LINES
, COLS
);
zap(); /* get terminal description */
if (tgoto(CM
, destcol
, destline
)[0] == 'O')
PC
= xPC
? xPC
[0] : FALSE
;
strcpy(ttytype
, longname(genbuf
, type
));
* This routine gets all the terminal flags from the termcap database
namp
= "ambseohzinmimsncosulxn\0\0";
fprintf(outf
, "ZAP: namp = \"%s\"\n", namp
);
*(*fp
++) = tgetflag(namp
);
fprintf(outf
, "ZAP: %.2s = %d", namp
, *(*(fp
- 1)));
namp
= "albcbtcdceclcmcrdcdldmdoedeihoicimipllmandnlpcsesfsosrtatetiucueupusvbvsve";
fprintf(outf
, "ZAP: namp = \"%s\"\n", namp
);
*(*sp
++) = tgetstr(namp
, &aoftspace
);
fprintf(outf
, "ZAP: %.2s = \"%s\"\n", namp
, *(*(sp
-1)));
if ((SG
> 0 || !SO
) && (UG
<= 0 && US
)) {
* return a capability from termcap
return tgetstr(name
, &aoftspace
);