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