wsemul_vt100var.h revision 1.3 1 1.3 drochner /* $NetBSD: wsemul_vt100var.h,v 1.3 1998/08/12 20:04:12 drochner Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1998
5 1.1 drochner * Matthias Drochner. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Redistribution and use in source and binary forms, with or without
8 1.1 drochner * modification, are permitted provided that the following conditions
9 1.1 drochner * are met:
10 1.1 drochner * 1. Redistributions of source code must retain the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer.
12 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 drochner * notice, this list of conditions and the following disclaimer in the
14 1.1 drochner * documentation and/or other materials provided with the distribution.
15 1.1 drochner * 3. All advertising materials mentioning features or use of this software
16 1.1 drochner * must display the following acknowledgement:
17 1.1 drochner * This product includes software developed for the NetBSD Project
18 1.1 drochner * by Matthias Drochner.
19 1.1 drochner * 4. The name of the author may not be used to endorse or promote products
20 1.1 drochner * derived from this software without specific prior written permission.
21 1.1 drochner *
22 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 drochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 drochner *
33 1.1 drochner */
34 1.1 drochner
35 1.1 drochner #define VT100_EMUL_NARGS 10 /* max # of args to a command */
36 1.1 drochner
37 1.1 drochner struct wsemul_vt100_emuldata {
38 1.1 drochner const struct wsdisplay_emulops *emulops;
39 1.1 drochner void *emulcookie;
40 1.1 drochner int scrcapabilities;
41 1.1 drochner u_int nrows, ncols, crow, ccol;
42 1.1 drochner long defattr; /* default attribute */
43 1.1 drochner
44 1.1 drochner long kernattr; /* attribute for kernel output */
45 1.1 drochner void *cbcookie;
46 1.1 drochner #ifdef DIAGNOSTIC
47 1.1 drochner int console;
48 1.1 drochner #endif
49 1.1 drochner
50 1.1 drochner u_int state; /* processing state */
51 1.1 drochner int flags;
52 1.2 drochner #define VTFL_LASTCHAR 0x001 /* printed last char on line (below cursor) */
53 1.2 drochner #define VTFL_INSERTMODE 0x002
54 1.2 drochner #define VTFL_APPLKEYPAD 0x004
55 1.2 drochner #define VTFL_APPLCURSOR 0x008
56 1.2 drochner #define VTFL_DECOM 0x010 /* origin mode */
57 1.2 drochner #define VTFL_DECAWM 0x020 /* auto wrap */
58 1.2 drochner #define VTFL_CURSORON 0x040
59 1.2 drochner #define VTFL_NATCHARSET 0x080 /* national replacement charset mode */
60 1.1 drochner long curattr; /* currently used attribute */
61 1.1 drochner int attrflags, fgcol, bgcol; /* properties of curattr */
62 1.1 drochner int scrreg_startrow;
63 1.1 drochner int scrreg_nrows;
64 1.1 drochner char *tabs;
65 1.2 drochner char *dblwid;
66 1.2 drochner int dw;
67 1.2 drochner
68 1.2 drochner int chartab0, chartab1;
69 1.2 drochner u_int *chartab_G[4];
70 1.2 drochner u_int *isolatin1tab, *decgraphtab, *dectechtab;
71 1.2 drochner u_int *nrctab;
72 1.2 drochner int sschartab; /* single shift */
73 1.1 drochner
74 1.1 drochner int nargs;
75 1.1 drochner u_int args[VT100_EMUL_NARGS]; /* command args */
76 1.1 drochner
77 1.2 drochner char modif1; /* {>?} in VT100_EMUL_STATE_CSI */
78 1.2 drochner char modif2; /* {!"$&} in VT100_EMUL_STATE_CSI */
79 1.2 drochner
80 1.2 drochner int designating; /* substate in VT100_EMUL_STATE_DESIGNATE */
81 1.1 drochner
82 1.1 drochner int dcstype; /* substate in VT100_EMUL_STATE_STRING */
83 1.1 drochner char *dcsarg;
84 1.1 drochner int dcspos;
85 1.1 drochner #define DCS_MAXLEN 256 /* ??? */
86 1.1 drochner #define DCSTYPE_TABRESTORE 1 /* DCS2$t */
87 1.1 drochner
88 1.1 drochner int savedcursor_row, savedcursor_col;
89 1.2 drochner long savedattr;
90 1.2 drochner int savedattrflags, savedfgcol, savedbgcol;
91 1.2 drochner int savedchartab0, savedchartab1;
92 1.2 drochner u_int *savedchartab_G[4];
93 1.1 drochner };
94 1.1 drochner
95 1.1 drochner /* some useful utility macros */
96 1.1 drochner #define ARG(n) (edp->args[(n)])
97 1.2 drochner #define DEF1_ARG(n) (ARG(n) ? ARG(n) : 1)
98 1.3 drochner #define DEFx_ARG(n, x) (ARG(n) ? ARG(n) : (x))
99 1.1 drochner #define ROWS_ABOVE (edp->crow - edp->scrreg_startrow)
100 1.1 drochner #define ROWS_BELOW (edp->scrreg_startrow + edp->scrreg_nrows \
101 1.1 drochner - edp->crow - 1)
102 1.2 drochner #define CHECK_DW do { \
103 1.2 drochner if (edp->dblwid && edp->dblwid[edp->crow]) { \
104 1.2 drochner edp->dw = 1; \
105 1.2 drochner if (edp->ccol > (edp->ncols >> 1) - 1) \
106 1.2 drochner edp->ccol = (edp->ncols >> 1) - 1; \
107 1.2 drochner } else \
108 1.2 drochner edp->dw = 0; \
109 1.2 drochner } while (0)
110 1.2 drochner #define NCOLS (edp->ncols >> edp->dw)
111 1.2 drochner #define COLS_LEFT (NCOLS - edp->ccol - 1)
112 1.2 drochner #define COPYCOLS(f, t, n) (*edp->emulops->copycols)(edp->emulcookie, \
113 1.2 drochner edp->crow, (f) << edp->dw, (t) << edp->dw, (n) << edp->dw)
114 1.2 drochner #define ERASECOLS(f, n, a) (*edp->emulops->erasecols)(edp->emulcookie, \
115 1.2 drochner edp->crow, (f) << edp->dw, (n) << edp->dw, a)
116 1.1 drochner
117 1.1 drochner /*
118 1.1 drochner * response to primary DA request
119 1.1 drochner * operating level: 61 = VT100, 62 = VT200, 63 = VT300
120 1.1 drochner * extensions: 1 = 132 cols, 2 = printer port, 6 = selective erase,
121 1.1 drochner * 7 = soft charset, 8 = UDKs, 9 = NRC sets
122 1.1 drochner * VT100 = "033[?1;2c"
123 1.1 drochner */
124 1.1 drochner #define WSEMUL_VT_ID1 "\033[?62;6c"
125 1.1 drochner /*
126 1.1 drochner * response to secondary DA request
127 1.1 drochner * ident code: 24 = VT320
128 1.1 drochner * firmware version
129 1.1 drochner * hardware options: 0 = no options
130 1.1 drochner */
131 1.1 drochner #define WSEMUL_VT_ID2 "\033[>24;20;0c"
132 1.1 drochner
133 1.1 drochner void wsemul_vt100_reset __P((struct wsemul_vt100_emuldata *));
134 1.1 drochner void wsemul_vt100_scrollup __P((struct wsemul_vt100_emuldata *, int));
135 1.1 drochner void wsemul_vt100_scrolldown __P((struct wsemul_vt100_emuldata *, int));
136 1.1 drochner void wsemul_vt100_ed __P((struct wsemul_vt100_emuldata *, int));
137 1.1 drochner void wsemul_vt100_el __P((struct wsemul_vt100_emuldata *, int));
138 1.1 drochner void wsemul_vt100_handle_csi __P((struct wsemul_vt100_emuldata *, u_char));
139 1.1 drochner void wsemul_vt100_handle_dcs __P((struct wsemul_vt100_emuldata *));
140 1.1 drochner
141 1.2 drochner int wsemul_vt100_translate __P((void *cookie, keysym_t, char **));
142 1.2 drochner
143 1.2 drochner void vt100_initchartables __P((struct wsemul_vt100_emuldata *));
144 1.2 drochner void vt100_setnrc __P((struct wsemul_vt100_emuldata *, int));
145