]>
Commit | Line | Data |
---|---|---|
5eef597e MP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com> | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | /* | |
23 | * VTE Character Sets | |
24 | * These are predefined charactersets that can be loaded into GL and GR. By | |
25 | * default we use unicode_lower and unicode_upper, that is, both sets have the | |
26 | * exact unicode mapping. unicode_lower is effectively ASCII and unicode_upper | |
27 | * as defined by the unicode standard (I guess, ISO 8859-1). | |
28 | * Several other character sets are defined here. However, all of them are | |
29 | * limited to the 96 character space of GL or GR. Everything beyond GR (which | |
30 | * was not supported by the classic VTs by DEC but is available in VT emulators | |
31 | * that support unicode/UTF8) is always mapped to unicode and cannot be changed | |
32 | * by these character sets. Even mapping GL and GR is only available for | |
33 | * backwards compatibility as new applications can use the Unicode functionality | |
34 | * of the VTE. | |
35 | * | |
36 | * Moreover, mapping GR is almost unnecessary to support. In fact, Unicode UTF-8 | |
37 | * support in VTE works by reading every incoming data as UTF-8 stream. This | |
38 | * maps GL/ASCII to ASCII, as UTF-8 is backwards compatible to ASCII, however, | |
39 | * everything that has the 8th bit set is a >=2-byte haracter in UTF-8. That is, | |
40 | * this is in no way backwards compatible to >=VT220 8bit support. Therefore, if | |
41 | * someone maps a character set into GR and wants to use them with this VTE, | |
42 | * then they must already send UTF-8 characters to use GR (all GR characters are | |
43 | * 8-bits). Hence, they can easily also send the correct UTF-8 character for the | |
44 | * unicode mapping. | |
45 | * The only advantage is that most characters in many sets are 3-byte UTF-8 | |
46 | * characters and by mapping the set into GR/GL you can use 2 or 1 byte UTF-8 | |
47 | * characters which saves bandwidth. | |
48 | * Another reason is, if you have older applications that use the VT220 8-bit | |
49 | * support and you put a ASCII/8bit-extension to UTF-8 converter in between, you | |
50 | * need these mappings to have the application behave correctly if it uses GL/GR | |
51 | * mappings extensively. | |
52 | * | |
53 | * Anyway, we support GL/GR mappings so here are the most commonly used maps as | |
54 | * defined by Unicode-standard, DEC-private maps and other famous charmaps. | |
55 | * | |
56 | * Characters 1-32 are always the control characters (part of CL) and cannot be | |
57 | * mapped. Characters 34-127 (94 characters) are part of GL and can be mapped. | |
58 | * Characters 33 and 128 are not part of GL and always mapped by the VTE. | |
59 | * However, for GR they can be mapped differently (96 chars) so we have to | |
60 | * include them. The mapper has to take care not to use them in GL. | |
61 | */ | |
62 | ||
5eef597e MP |
63 | #include "term-internal.h" |
64 | ||
65 | /* | |
66 | * Lower Unicode character set. This maps the characters to the basic ASCII | |
67 | * characters 33-126. These are all graphics characters defined in ASCII. | |
68 | */ | |
69 | term_charset term_unicode_lower = { | |
70 | [0] = 32, | |
71 | [1] = 33, | |
72 | [2] = 34, | |
73 | [3] = 35, | |
74 | [4] = 36, | |
75 | [5] = 37, | |
76 | [6] = 38, | |
77 | [7] = 39, | |
78 | [8] = 40, | |
79 | [9] = 41, | |
80 | [10] = 42, | |
81 | [11] = 43, | |
82 | [12] = 44, | |
83 | [13] = 45, | |
84 | [14] = 46, | |
85 | [15] = 47, | |
86 | [16] = 48, | |
87 | [17] = 49, | |
88 | [18] = 50, | |
89 | [19] = 51, | |
90 | [20] = 52, | |
91 | [21] = 53, | |
92 | [22] = 54, | |
93 | [23] = 55, | |
94 | [24] = 56, | |
95 | [25] = 57, | |
96 | [26] = 58, | |
97 | [27] = 59, | |
98 | [28] = 60, | |
99 | [29] = 61, | |
100 | [30] = 62, | |
101 | [31] = 63, | |
102 | [32] = 64, | |
103 | [33] = 65, | |
104 | [34] = 66, | |
105 | [35] = 67, | |
106 | [36] = 68, | |
107 | [37] = 69, | |
108 | [38] = 70, | |
109 | [39] = 71, | |
110 | [40] = 72, | |
111 | [41] = 73, | |
112 | [42] = 74, | |
113 | [43] = 75, | |
114 | [44] = 76, | |
115 | [45] = 77, | |
116 | [46] = 78, | |
117 | [47] = 79, | |
118 | [48] = 80, | |
119 | [49] = 81, | |
120 | [50] = 82, | |
121 | [51] = 83, | |
122 | [52] = 84, | |
123 | [53] = 85, | |
124 | [54] = 86, | |
125 | [55] = 87, | |
126 | [56] = 88, | |
127 | [57] = 89, | |
128 | [58] = 90, | |
129 | [59] = 91, | |
130 | [60] = 92, | |
131 | [61] = 93, | |
132 | [62] = 94, | |
133 | [63] = 95, | |
134 | [64] = 96, | |
135 | [65] = 97, | |
136 | [66] = 98, | |
137 | [67] = 99, | |
138 | [68] = 100, | |
139 | [69] = 101, | |
140 | [70] = 102, | |
141 | [71] = 103, | |
142 | [72] = 104, | |
143 | [73] = 105, | |
144 | [74] = 106, | |
145 | [75] = 107, | |
146 | [76] = 108, | |
147 | [77] = 109, | |
148 | [78] = 110, | |
149 | [79] = 111, | |
150 | [80] = 112, | |
151 | [81] = 113, | |
152 | [82] = 114, | |
153 | [83] = 115, | |
154 | [84] = 116, | |
155 | [85] = 117, | |
156 | [86] = 118, | |
157 | [87] = 119, | |
158 | [88] = 120, | |
159 | [89] = 121, | |
160 | [90] = 122, | |
161 | [91] = 123, | |
162 | [92] = 124, | |
163 | [93] = 125, | |
164 | [94] = 126, | |
165 | [95] = 127, | |
166 | }; | |
167 | ||
168 | /* | |
169 | * Upper Unicode Table | |
170 | * This maps all characters to the upper unicode characters 161-254. These are | |
171 | * not compatible to any older 8 bit character sets. See the Unicode standard | |
172 | * for the definitions of each symbol. | |
173 | */ | |
174 | term_charset term_unicode_upper = { | |
175 | [0] = 160, | |
176 | [1] = 161, | |
177 | [2] = 162, | |
178 | [3] = 163, | |
179 | [4] = 164, | |
180 | [5] = 165, | |
181 | [6] = 166, | |
182 | [7] = 167, | |
183 | [8] = 168, | |
184 | [9] = 169, | |
185 | [10] = 170, | |
186 | [11] = 171, | |
187 | [12] = 172, | |
188 | [13] = 173, | |
189 | [14] = 174, | |
190 | [15] = 175, | |
191 | [16] = 176, | |
192 | [17] = 177, | |
193 | [18] = 178, | |
194 | [19] = 179, | |
195 | [20] = 180, | |
196 | [21] = 181, | |
197 | [22] = 182, | |
198 | [23] = 183, | |
199 | [24] = 184, | |
200 | [25] = 185, | |
201 | [26] = 186, | |
202 | [27] = 187, | |
203 | [28] = 188, | |
204 | [29] = 189, | |
205 | [30] = 190, | |
206 | [31] = 191, | |
207 | [32] = 192, | |
208 | [33] = 193, | |
209 | [34] = 194, | |
210 | [35] = 195, | |
211 | [36] = 196, | |
212 | [37] = 197, | |
213 | [38] = 198, | |
214 | [39] = 199, | |
215 | [40] = 200, | |
216 | [41] = 201, | |
217 | [42] = 202, | |
218 | [43] = 203, | |
219 | [44] = 204, | |
220 | [45] = 205, | |
221 | [46] = 206, | |
222 | [47] = 207, | |
223 | [48] = 208, | |
224 | [49] = 209, | |
225 | [50] = 210, | |
226 | [51] = 211, | |
227 | [52] = 212, | |
228 | [53] = 213, | |
229 | [54] = 214, | |
230 | [55] = 215, | |
231 | [56] = 216, | |
232 | [57] = 217, | |
233 | [58] = 218, | |
234 | [59] = 219, | |
235 | [60] = 220, | |
236 | [61] = 221, | |
237 | [62] = 222, | |
238 | [63] = 223, | |
239 | [64] = 224, | |
240 | [65] = 225, | |
241 | [66] = 226, | |
242 | [67] = 227, | |
243 | [68] = 228, | |
244 | [69] = 229, | |
245 | [70] = 230, | |
246 | [71] = 231, | |
247 | [72] = 232, | |
248 | [73] = 233, | |
249 | [74] = 234, | |
250 | [75] = 235, | |
251 | [76] = 236, | |
252 | [77] = 237, | |
253 | [78] = 238, | |
254 | [79] = 239, | |
255 | [80] = 240, | |
256 | [81] = 241, | |
257 | [82] = 242, | |
258 | [83] = 243, | |
259 | [84] = 244, | |
260 | [85] = 245, | |
261 | [86] = 246, | |
262 | [87] = 247, | |
263 | [88] = 248, | |
264 | [89] = 249, | |
265 | [90] = 250, | |
266 | [91] = 251, | |
267 | [92] = 252, | |
268 | [93] = 253, | |
269 | [94] = 254, | |
270 | [95] = 255, | |
271 | }; | |
272 | ||
273 | /* | |
274 | * The DEC supplemental graphics set. For its definition see here: | |
275 | * http://vt100.net/docs/vt220-rm/table2-3b.html | |
276 | * Its basically a mixture of common European symbols that are not part of | |
277 | * ASCII. Most often, this is mapped into GR to extend the basci ASCII part. | |
278 | * | |
279 | * This is very similar to unicode_upper, however, few symbols differ so do not | |
280 | * mix them up! | |
281 | */ | |
282 | term_charset term_dec_supplemental_graphics = { | |
283 | [0] = -1, /* undefined */ | |
284 | [1] = 161, | |
285 | [2] = 162, | |
286 | [3] = 163, | |
287 | [4] = 0, | |
288 | [5] = 165, | |
289 | [6] = 0, | |
290 | [7] = 167, | |
291 | [8] = 164, | |
292 | [9] = 169, | |
293 | [10] = 170, | |
294 | [11] = 171, | |
295 | [12] = 0, | |
296 | [13] = 0, | |
297 | [14] = 0, | |
298 | [15] = 0, | |
299 | [16] = 176, | |
300 | [17] = 177, | |
301 | [18] = 178, | |
302 | [19] = 179, | |
303 | [20] = 0, | |
304 | [21] = 181, | |
305 | [22] = 182, | |
306 | [23] = 183, | |
307 | [24] = 0, | |
308 | [25] = 185, | |
309 | [26] = 186, | |
310 | [27] = 187, | |
311 | [28] = 188, | |
312 | [29] = 189, | |
313 | [30] = 0, | |
314 | [31] = 191, | |
315 | [32] = 192, | |
316 | [33] = 193, | |
317 | [34] = 194, | |
318 | [35] = 195, | |
319 | [36] = 196, | |
320 | [37] = 197, | |
321 | [38] = 198, | |
322 | [39] = 199, | |
323 | [40] = 200, | |
324 | [41] = 201, | |
325 | [42] = 202, | |
326 | [43] = 203, | |
327 | [44] = 204, | |
328 | [45] = 205, | |
329 | [46] = 206, | |
330 | [47] = 207, | |
331 | [48] = 0, | |
332 | [49] = 209, | |
333 | [50] = 210, | |
334 | [51] = 211, | |
335 | [52] = 212, | |
336 | [53] = 213, | |
337 | [54] = 214, | |
338 | [55] = 338, | |
339 | [56] = 216, | |
340 | [57] = 217, | |
341 | [58] = 218, | |
342 | [59] = 219, | |
343 | [60] = 220, | |
344 | [61] = 376, | |
345 | [62] = 0, | |
346 | [63] = 223, | |
347 | [64] = 224, | |
348 | [65] = 225, | |
349 | [66] = 226, | |
350 | [67] = 227, | |
351 | [68] = 228, | |
352 | [69] = 229, | |
353 | [70] = 230, | |
354 | [71] = 231, | |
355 | [72] = 232, | |
356 | [73] = 233, | |
357 | [74] = 234, | |
358 | [75] = 235, | |
359 | [76] = 236, | |
360 | [77] = 237, | |
361 | [78] = 238, | |
362 | [79] = 239, | |
363 | [80] = 0, | |
364 | [81] = 241, | |
365 | [82] = 242, | |
366 | [83] = 243, | |
367 | [84] = 244, | |
368 | [85] = 245, | |
369 | [86] = 246, | |
370 | [87] = 339, | |
371 | [88] = 248, | |
372 | [89] = 249, | |
373 | [90] = 250, | |
374 | [91] = 251, | |
375 | [92] = 252, | |
376 | [93] = 255, | |
377 | [94] = 0, | |
378 | [95] = -1, /* undefined */ | |
379 | }; | |
380 | ||
381 | /* | |
382 | * DEC special graphics character set. See here for its definition: | |
383 | * http://vt100.net/docs/vt220-rm/table2-4.html | |
384 | * This contains several characters to create ASCII drawings and similar. Its | |
385 | * commonly mapped into GR to extend the basic ASCII characters. | |
386 | * | |
387 | * Lower 62 characters map to ASCII 33-64, everything beyond is special and | |
388 | * commonly used for ASCII drawings. It depends on the Unicode Standard 3.2 for | |
389 | * the extended horizontal scan-line characters 3, 5, 7, and 9. | |
390 | */ | |
391 | term_charset term_dec_special_graphics = { | |
392 | [0] = -1, /* undefined */ | |
393 | [1] = 33, | |
394 | [2] = 34, | |
395 | [3] = 35, | |
396 | [4] = 36, | |
397 | [5] = 37, | |
398 | [6] = 38, | |
399 | [7] = 39, | |
400 | [8] = 40, | |
401 | [9] = 41, | |
402 | [10] = 42, | |
403 | [11] = 43, | |
404 | [12] = 44, | |
405 | [13] = 45, | |
406 | [14] = 46, | |
407 | [15] = 47, | |
408 | [16] = 48, | |
409 | [17] = 49, | |
410 | [18] = 50, | |
411 | [19] = 51, | |
412 | [20] = 52, | |
413 | [21] = 53, | |
414 | [22] = 54, | |
415 | [23] = 55, | |
416 | [24] = 56, | |
417 | [25] = 57, | |
418 | [26] = 58, | |
419 | [27] = 59, | |
420 | [28] = 60, | |
421 | [29] = 61, | |
422 | [30] = 62, | |
423 | [31] = 63, | |
424 | [32] = 64, | |
425 | [33] = 65, | |
426 | [34] = 66, | |
427 | [35] = 67, | |
428 | [36] = 68, | |
429 | [37] = 69, | |
430 | [38] = 70, | |
431 | [39] = 71, | |
432 | [40] = 72, | |
433 | [41] = 73, | |
434 | [42] = 74, | |
435 | [43] = 75, | |
436 | [44] = 76, | |
437 | [45] = 77, | |
438 | [46] = 78, | |
439 | [47] = 79, | |
440 | [48] = 80, | |
441 | [49] = 81, | |
442 | [50] = 82, | |
443 | [51] = 83, | |
444 | [52] = 84, | |
445 | [53] = 85, | |
446 | [54] = 86, | |
447 | [55] = 87, | |
448 | [56] = 88, | |
449 | [57] = 89, | |
450 | [58] = 90, | |
451 | [59] = 91, | |
452 | [60] = 92, | |
453 | [61] = 93, | |
454 | [62] = 94, | |
455 | [63] = 0, | |
456 | [64] = 9830, | |
457 | [65] = 9618, | |
458 | [66] = 9225, | |
459 | [67] = 9228, | |
460 | [68] = 9229, | |
461 | [69] = 9226, | |
462 | [70] = 176, | |
463 | [71] = 177, | |
464 | [72] = 9252, | |
465 | [73] = 9227, | |
466 | [74] = 9496, | |
467 | [75] = 9488, | |
468 | [76] = 9484, | |
469 | [77] = 9492, | |
470 | [78] = 9532, | |
471 | [79] = 9146, | |
472 | [80] = 9147, | |
473 | [81] = 9472, | |
474 | [82] = 9148, | |
475 | [83] = 9149, | |
476 | [84] = 9500, | |
477 | [85] = 9508, | |
478 | [86] = 9524, | |
479 | [87] = 9516, | |
480 | [88] = 9474, | |
481 | [89] = 8804, | |
482 | [90] = 8805, | |
483 | [91] = 960, | |
484 | [92] = 8800, | |
485 | [93] = 163, | |
486 | [94] = 8901, | |
487 | [95] = -1, /* undefined */ | |
488 | }; |