This source file includes following definitions.
- wsemul_vt100_translate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32
33 #include <dev/wscons/wsdisplayvar.h>
34 #include <dev/wscons/wsksymvar.h>
35 #include <dev/wscons/wsksymdef.h>
36 #include <dev/wscons/wsemul_vt100var.h>
37
38 static char *vt100_fkeys[] = {
39 "\033[11~",
40 "\033[12~",
41 "\033[13~",
42 "\033[14~",
43 "\033[15~",
44 "\033[17~",
45 "\033[18~",
46 "\033[19~",
47 "\033[20~",
48 "\033[21~",
49 "\033[23~",
50 "\033[24~",
51 "\033[25~",
52 "\033[26~",
53 "\033[28~",
54 "\033[29~",
55 "\033[31~",
56 "\033[32~",
57 "\033[33~",
58 "\033[34~",
59 };
60
61 static char *vt100_pfkeys[] = {
62 "\033OP",
63 "\033OQ",
64 "\033OR",
65 "\033OS",
66 };
67
68 static char *vt100_numpad[] = {
69 "\033Op",
70 "\033Oq",
71 "\033Or",
72 "\033Os",
73 "\033Ot",
74 "\033Ou",
75 "\033Ov",
76 "\033Ow",
77 "\033Ox",
78 "\033Oy",
79 };
80
81 int
82 wsemul_vt100_translate(cookie, in, out)
83 void *cookie;
84 keysym_t in;
85 char **out;
86 {
87 struct wsemul_vt100_emuldata *edp = cookie;
88 static char c;
89
90 if (in >= KS_f1 && in <= KS_f20) {
91 *out = vt100_fkeys[in - KS_f1];
92 return (5);
93 }
94 if (in >= KS_F1 && in <= KS_F20) {
95 *out = vt100_fkeys[in - KS_F1];
96 return (5);
97 }
98 if (in >= KS_KP_F1 && in <= KS_KP_F4) {
99 *out = vt100_pfkeys[in - KS_KP_F1];
100 return (3);
101 }
102 if (edp->flags & VTFL_APPLKEYPAD) {
103 if (in >= KS_KP_0 && in <= KS_KP_9) {
104 *out = vt100_numpad[in - KS_KP_0];
105 return (3);
106 }
107 switch (in) {
108 case KS_KP_Tab:
109 *out = "\033OI";
110 return (3);
111 case KS_KP_Enter:
112 *out = "\033OM";
113 return (3);
114 case KS_KP_Multiply:
115 *out = "\033Oj";
116 return (3);
117 case KS_KP_Add:
118 *out = "\033Ok";
119 return (3);
120 case KS_KP_Separator:
121 *out = "\033Ol";
122 return (3);
123 case KS_KP_Subtract:
124 *out = "\033Om";
125 return (3);
126 case KS_KP_Decimal:
127 *out = "\033On";
128 return (3);
129 case KS_KP_Divide:
130 *out = "\033Oo";
131 return (3);
132 }
133 } else {
134 if (!(in & 0x80)) {
135 c = in & 0xff;
136 *out = &c;
137 return (1);
138 }
139 }
140 switch (in) {
141 case KS_Help:
142 *out = vt100_fkeys[15 - 1];
143 return (5);
144 case KS_Execute:
145 *out = vt100_fkeys[16 - 1];
146 return (5);
147 case KS_Find:
148 *out = "\033[1~";
149 return (4);
150 case KS_Insert:
151 case KS_KP_Insert:
152 *out = "\033[2~";
153 return (4);
154 case KS_KP_Delete:
155 *out = "\033[3~";
156 return (4);
157 case KS_Select:
158 *out = "\033[4~";
159 return (4);
160 case KS_Prior:
161 case KS_KP_Prior:
162 *out = "\033[5~";
163 return (4);
164 case KS_Next:
165 case KS_KP_Next:
166 *out = "\033[6~";
167 return (4);
168 case KS_Home:
169 case KS_KP_Home:
170 *out = "\033[7~";
171 return (4);
172 case KS_End:
173 case KS_KP_End:
174 *out = "\033[8~";
175 return (4);
176 case KS_Up:
177 case KS_KP_Up:
178 if (edp->flags & VTFL_APPLCURSOR)
179 *out = "\033OA";
180 else
181 *out = "\033[A";
182 return (3);
183 case KS_Down:
184 case KS_KP_Down:
185 if (edp->flags & VTFL_APPLCURSOR)
186 *out = "\033OB";
187 else
188 *out = "\033[B";
189 return (3);
190 case KS_Left:
191 case KS_KP_Left:
192 if (edp->flags & VTFL_APPLCURSOR)
193 *out = "\033OD";
194 else
195 *out = "\033[D";
196 return (3);
197 case KS_Right:
198 case KS_KP_Right:
199 if (edp->flags & VTFL_APPLCURSOR)
200 *out = "\033OC";
201 else
202 *out = "\033[C";
203 return (3);
204 }
205 return (0);
206 }