* Copyright (c) 1983 Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Edward Wang at The University of California, Berkeley.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)ttgeneric.c 3.45 (Berkeley) 6/6/90";
/* ANSI graphics frame */
#define G (WWM_GRP << WWC_MSHIFT)
' ', 'x'|G
, 'Q'|G
, 'm'|G
,
'x'|G
, 'x'|G
, 'l'|G
, 't'|G
,
'q'|G
, 'j'|G
, 'q'|G
, 'v'|G
,
'k'|G
, 'u'|G
, 'w'|G
, 'n'|G
struct tt_str ansi_AS
= {
diff
= new ^ tt
.tt_modes
;
if (tt
.tt_modes
) /* for concept 100 */
ttpgoto(gen_ALn
, 0, n
, gen_LI
- tt
.tt_row
);
tttputs(gen_AL
, gen_LI
- tt
.tt_row
);
if (tt
.tt_modes
) /* for concept 100 */
ttpgoto(gen_DLn
, 0, n
, gen_LI
- tt
.tt_row
);
tttputs(gen_DL
, gen_LI
- tt
.tt_row
);
if (tt
.tt_nmodes
!= tt
.tt_modes
)
gen_setmodes(tt
.tt_nmodes
);
if (++tt
.tt_col
== gen_CO
)
tt
.tt_col
= tt
.tt_row
= -10;
tt
.tt_col
= 0, tt
.tt_row
++;
if (tt
.tt_nmodes
!= tt
.tt_modes
)
gen_setmodes(tt
.tt_nmodes
);
tt
.tt_col
= tt
.tt_row
= -10;
tt
.tt_col
= 0, tt
.tt_row
++;
if (tt
.tt_row
== row
&& tt
.tt_col
== col
)
if (!gen_MI
&& tt
.tt_insert
)
if (!gen_MS
&& tt
.tt_modes
)
if (row
< tt
.tt_scroll_top
|| row
> tt
.tt_scroll_bot
)
gen_setscroll(0, tt
.tt_nrow
- 1);
if (tt
.tt_col
== col
- 1) {
} else if (tt
.tt_col
== col
+ 1) {
if (tt
.tt_row
== row
+ 1) {
} else if (tt
.tt_row
== row
- 1) {
if (gen_HO
&& col
== 0 && row
== 0) {
tttgoto(gen_CM
, col
, row
);
tt
.tt_col
= tt
.tt_row
= 0;
tt
.tt_nmodes
= tt
.tt_modes
= 0;
if (tt
.tt_modes
) /* for concept 100 */
tttputs(gen_CE
, gen_CO
- tt
.tt_col
);
if (tt
.tt_modes
) /* for concept 100 */
tttputs(gen_CD
, gen_LI
- tt
.tt_row
);
if (tt
.tt_modes
) /* for concept 100 */
if (tt
.tt_nmodes
!= tt
.tt_modes
)
gen_setmodes(tt
.tt_nmodes
);
tttputs(gen_IC
, gen_CO
- tt
.tt_col
);
tttputs(gen_IP
, gen_CO
- tt
.tt_col
);
if (++tt
.tt_col
== gen_CO
)
tt
.tt_col
= tt
.tt_row
= -10;
tt
.tt_col
= 0, tt
.tt_row
++;
ttpgoto(gen_ICn
, 0, n
, gen_CO
- tt
.tt_col
);
tttputs(gen_IC
, gen_CO
- tt
.tt_col
);
ttpgoto(gen_DCn
, 0, n
, gen_CO
- tt
.tt_col
);
tttputs(gen_DC
, gen_CO
- tt
.tt_col
);
gen_move(tt
.tt_scroll_bot
, 0);
ttpgoto(gen_SFn
, 0, n
, n
);
gen_move(tt
.tt_scroll_top
, 0);
ttpgoto(gen_SRn
, 0, n
, n
);
tttgoto(gen_CS
, bot
, top
);
tt
.tt_row
= tt
.tt_col
= -10;
gen_PC
= tttgetstr("pc");
PC
= gen_PC
? *gen_PC
->ts_str
: 0;
ospeed
= wwoldtty
.ww_sgttyb
.sg_ospeed
;
ospeed
= wwoldtty
.ww_termios
.c_cflag
& CBAUD
;
ospeed
= wwoldtty
.ww_termios
.c_ospeed
; /* XXX */
gen_CM
= ttxgetstr("cm"); /* may not work */
gen_IM
= ttxgetstr("im");
gen_IC
= tttgetstr("ic");
gen_ICn
= tttgetstr("IC");
gen_IP
= tttgetstr("ip");
gen_EI
= ttxgetstr("ei");
gen_DC
= tttgetstr("dc");
gen_DCn
= tttgetstr("DC");
gen_AL
= tttgetstr("al");
gen_ALn
= tttgetstr("AL");
gen_DL
= tttgetstr("dl");
gen_DLn
= tttgetstr("DL");
gen_CE
= tttgetstr("ce");
gen_CD
= tttgetstr("cd");
gen_CL
= ttxgetstr("cl");
gen_VS
= ttxgetstr("vs");
gen_VE
= ttxgetstr("ve");
gen_TI
= ttxgetstr("ti");
gen_TE
= ttxgetstr("te");
gen_SO
= ttxgetstr("so");
gen_SE
= ttxgetstr("se");
gen_US
= ttxgetstr("us");
gen_UE
= ttxgetstr("ue");
gen_LE
= ttxgetstr("le");
gen_ND
= ttxgetstr("nd");
gen_UP
= ttxgetstr("up");
gen_DO
= ttxgetstr("do");
gen_BC
= ttxgetstr("bc");
gen_NL
= ttxgetstr("nl");
gen_CR
= ttxgetstr("cr");
gen_HO
= ttxgetstr("ho");
gen_AS
= ttxgetstr("as");
gen_AE
= ttxgetstr("ae");
gen_XS
= ttxgetstr("XS");
gen_XE
= ttxgetstr("XE");
gen_SF
= ttxgetstr("sf");
gen_SFn
= ttxgetstr("SF");
gen_SR
= ttxgetstr("sr");
gen_SRn
= ttxgetstr("SR");
gen_CS
= ttxgetstr("cs");
if (gen_CL
== 0 || gen_OS
|| gen_CM
== 0)
* Deal with obsolete termcap fields.
static struct tt_str bc
= { "\b", 1 };
static struct tt_str nl
= { "\n", 1 };
static struct tt_str cr
= { "\r", 1 };
* Most terminal will scroll with "nl", but very few specify "sf".
* We shouldn't use "do" here.
if (gen_SF
== 0 && !gen_NS
)
BC
= gen_LE
? gen_LE
->ts_str
: 0;
UP
= gen_UP
? gen_UP
->ts_str
: 0;
* Fix up display attributes that we can't handle, or don't
if (gen_UG
> 0 || gen_US
&& gen_SO
&& ttstrcmp(gen_US
, gen_SO
) == 0)
if (gen_IM
&& gen_IM
->ts_n
== 0) {
if (gen_EI
&& gen_EI
->ts_n
== 0) {
if (gen_IC
&& gen_IC
->ts_n
== 0) {
tt
.tt_inschar
= gen_inschar
;
tt
.tt_insspace
= gen_insspace
;
tt
.tt_delchar
= gen_delchar
;
tt
.tt_insline
= gen_insline
;
tt
.tt_delline
= gen_delline
;
tt
.tt_clreol
= gen_clreol
;
tt
.tt_clreos
= gen_clreos
;
tt
.tt_scroll_down
= gen_scroll_down
;
* Don't allow scroll_up if da or db but not cs.
* See comment in wwscroll.c.
if (gen_SR
&& (gen_CS
|| !gen_DA
&& !gen_DB
))
tt
.tt_scroll_up
= gen_scroll_up
;
tt
.tt_setscroll
= gen_setscroll
;
tt
.tt_availmodes
|= WWM_REV
;
tt
.tt_availmodes
|= WWM_UL
;
tt
.tt_availmodes
|= WWM_GRP
;
tt
.tt_availmodes
|= WWM_USR
;
tt
.tt_setmodes
= gen_setmodes
;
tt
.tt_frame
= gen_AS
&& ttstrcmp(gen_AS
, &ansi_AS
) == 0 ?