FabGL
ESP32 Display Controller and Graphics Library
terminfo.cpp
1/*
2 Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3 Copyright (c) 2019-2022 Fabrizio Di Vittorio.
4 All rights reserved.
5
6
7* Please contact fdivitto2013@gmail.com if you need a commercial license.
8
9
10* This library and related software is available under GPL v3.
11
12 FabGL is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 FabGL is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26
27#include "terminfo.h"
28
29
30
31namespace fabgl {
32
33
34
35const TermInfoKbdConv kbdConv_Generic[] = {
36 // Cursor Up => CTRL-E, WordStar Up
37 { VK_UP, "\x05" },
38
39 // Cursor Down => CTRL-X, WordStar Down
40 { VK_DOWN, "\x18" },
41
42 // Cursor Left => CTRL-S, WordStar Left
43 { VK_LEFT, "\x13" },
44
45 // Cursor Right => CTRL-D, WordStar right
46 { VK_RIGHT, "\x04" },
47
48 // Home => CTRL-Q S, WordStar Home
49 { VK_HOME, "\x11" "S" },
50
51 // End => CTRL-Q D, WordStar End
52 { VK_END, "\x11" "D" },
53
54 // PageUp => CTRL-C, WordStar PageUp
55 { VK_PAGEUP, "\x12" },
56
57 // PageDown => CTRL-R, WordStar PageDown
58 { VK_PAGEDOWN, "\x03" },
59
60 // Backspace => CTRL-H, CP/M delete char left (but WordStar just moves cursor left)
61 { VK_BACKSPACE, "\x08" },
62
63 // Delete => CTRL-G, WordStar delete char right
64 { VK_DELETE, "\x07" },
65
66 // Last item marker
67 { VK_NONE, nullptr },
68};
69
70
72// Lear Siegler ADM-3A
73
74
75// sorted by TermSeq name
76const TermInfoVideoConv videoConv_ADM3A[] = {
77 // BS => Cursor Left
78 { "\x08", 1, { ConvCtrl::CursorLeft, ConvCtrl::END } },
79
80 // VT => Cursor Up
81 { "\x0b", 1, { ConvCtrl::CursorUp, ConvCtrl::END} },
82
83 // FF => Cursor Right
84 { "\x0c", 1, { ConvCtrl::CursorRight, ConvCtrl::END} },
85
86 // ETB => Erase to end of screen
87 { "\x17", 1, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
88
89 // CAN => Erase to end of line
90 { "\x18", 1, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
91
92 // SUB => Cursor home and Clear screen
93 { "\x1a", 1, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
94
95 // RS => Cursor Home
96 { "\x1e", 1, { ConvCtrl::CursorHome, ConvCtrl::END} },
97
98 // 'ESC G 0' => Char Attribute: Normal video
99 { "\eG0", 3, { ConvCtrl::AttrNormal, ConvCtrl::END} },
100
101 // 'ESC G 1' => Char Attribute: Blank
102 { "\eG1", 3, { ConvCtrl::AttrBlank, ConvCtrl::END} },
103
104 // 'ESC G 2' => Char Attribute: Blink
105 { "\eG2", 3, { ConvCtrl::AttrBlink, ConvCtrl::END} },
106
107 // 'ESC G 4' => Char Attribute: Reverse
108 { "\eG4", 3, { ConvCtrl::AttrReverse, ConvCtrl::END} },
109
110 // 'ESC G 6' => Char Attribute: Reverse blinking
111 { "\eG6", 3, { ConvCtrl::AttrReverse, ConvCtrl::AttrBlink, ConvCtrl::END} },
112
113 // 'ESC G 8' => Char Attribute: Underline
114 { "\eG8", 3, { ConvCtrl::AttrUnderline, ConvCtrl::END} },
115
116 // 'ESC G :' => Char Attribute: Underline blinking
117 { "\eG:", 3, { ConvCtrl::AttrUnderline, ConvCtrl::AttrBlink, ConvCtrl::END} },
118
119 // 'ESC G <' => Char Attribute: Underline reverse
120 { "\eG<", 3, { ConvCtrl::AttrUnderline, ConvCtrl::AttrReverse, ConvCtrl::END} },
121
122 // 'ESC G >' => Char Attribute: Underline, reverse, bliking
123 { "\eG>", 3, { ConvCtrl::AttrUnderline, ConvCtrl::AttrReverse, ConvCtrl::AttrBlink, ConvCtrl::END} },
124
125 // 'ESC G @' => Char Attribute: Reduce
126 { "\eG@", 3, { ConvCtrl::AttrReduce, ConvCtrl::END} },
127
128 // 'ESC G B' => Char Attribute: Reduce blinking
129 { "\eGB", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrBlink, ConvCtrl::END} },
130
131 // 'ESC G D' => Char Attribute: Reduce reverse
132 { "\eGD", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrReverse, ConvCtrl::END} },
133
134 // 'ESC G F' => Char Attribute: Reduce reverse blinking
135 { "\eGF", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrReverse, ConvCtrl::AttrBlink, ConvCtrl::END} },
136
137 // 'ESC G H' => Char Attribute: Reduce underline
138 { "\eGH", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrUnderline, ConvCtrl::END} },
139
140 // 'ESC G J' => Char Attribute: Reduce underline blinking
141 { "\eGJ", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrUnderline, ConvCtrl::AttrBlink, ConvCtrl::END} },
142
143 // 'ESC G L' => Char Attribute: Reduce underline reverse
144 { "\eGL", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrUnderline, ConvCtrl::AttrReverse, ConvCtrl::END} },
145
146 // 'ESC G N' => Char Attribute: Reduce underline reverse blinking
147 { "\eGN", 3, { ConvCtrl::AttrReduce, ConvCtrl::AttrUnderline, ConvCtrl::AttrReverse, ConvCtrl::AttrBlink, ConvCtrl::END} },
148
149 // 'ESC = y x' => Cursor Position (cursorX = x-31, cursorY = y-31)
150 { "\e=\xff\xff", 4, { ConvCtrl::CursorPos, ConvCtrl::END} },
151
152 // Last item marker
153 { nullptr, 0, { } },
154};
155
156
157const TermInfo term_ADM3A = {
158 "",
159 videoConv_ADM3A,
160 kbdConv_Generic
161};
162
163
164
166// Lear Siegler ADM-31
167
168
169// sorted by TermSeq name
170const TermInfoVideoConv videoConv_ADM31[] = {
171 // BS => Cursor Left
172 { "\x08", 1, { ConvCtrl::CursorLeft, ConvCtrl::END } },
173
174 // VT => Cursor Up
175 { "\x0b", 1, { ConvCtrl::CursorUp, ConvCtrl::END} },
176
177 // FF => Cursor Right
178 { "\x0c", 1, { ConvCtrl::CursorRight, ConvCtrl::END} },
179
180 // SUB => Cursor home and Clear screen
181 { "\x1a", 1, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
182
183 // RS => Cursor Home
184 { "\x1e", 1, { ConvCtrl::CursorHome, ConvCtrl::END} },
185
186 // US => New line
187 { "\x1f", 1, { ConvCtrl::CarriageReturn, ConvCtrl::LineFeed, ConvCtrl::END} },
188
189 // 'ESC = y x' => Cursor Position (cursorX = x-31, cursorY = y-31)
190 { "\e=\xff\xff", 4, { ConvCtrl::CursorPos, ConvCtrl::END} },
191
192 // 'ESC G 4' => Char Attribute: Reverse
193 { "\eG4", 3, { ConvCtrl::AttrReverse, ConvCtrl::END} },
194
195 // 'ESC G 3' => Char Attribute: Underline
196 { "\eG3", 3, { ConvCtrl::AttrUnderline, ConvCtrl::END} },
197
198 // 'ESC G 2' => Char Attribute: Blink
199 { "\eG2", 3, { ConvCtrl::AttrBlink, ConvCtrl::END} },
200
201 // 'ESC G 0' => Char Attribute: Normal video
202 { "\eG0", 3, { ConvCtrl::AttrNormal, ConvCtrl::END} },
203
204 // 'ESC )' => Char Attribute: Half intensity ON
205 { "\e)", 2, { ConvCtrl::AttrReduce, ConvCtrl::END} },
206
207 // 'ESC (' => Char Attribute: Half intensity OFF
208 { "\e(", 2, { ConvCtrl::AttrReduceOff, ConvCtrl::END} },
209
210 // 'ESC E' => Insert Line
211 { "\eE", 2, { ConvCtrl::InsertLine, ConvCtrl::END} },
212
213 // 'ESC Q' => Insert Character
214 { "\eQ", 2, { ConvCtrl::InsertChar, ConvCtrl::END} },
215
216 // 'ESC R' => Delete Line
217 { "\eR", 2, { ConvCtrl::DeleteLine, ConvCtrl::END} },
218
219 // 'ESC W' => Delete Character
220 { "\eW", 2, { ConvCtrl::DeleteCharacter, ConvCtrl::END} },
221
222 // 'ESC T' => Erase to end of line
223 { "\eT", 2, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
224
225 // 'ESC t' => Erase to end of line
226 { "\et", 2, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
227
228 // 'ESC Y' => Erase to end of screen
229 { "\eY", 2, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
230
231 // 'ESC y' => Erase to end of screen
232 { "\ey", 2, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
233
234 // 'ESC *' => Cursor home and Clear screen
235 { "\e*", 2, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
236
237 // 'ESC :' => Cursor home and Clear screen
238 { "\e:", 2, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
239
240 // Last item marker
241 { nullptr, 0, { } },
242};
243
244
245const TermInfo term_ADM31 = {
246 "",
247 videoConv_ADM31,
248 kbdConv_Generic
249};
250
251
252
254// Hazeltine 1500
255
256
257// sorted by TermSeq name
258const TermInfoVideoConv videoConv_Hazeltine1500[] = {
259 // '~ VT' => Cursor Down
260 { "~\x0b", 2, { ConvCtrl::LineFeed, ConvCtrl::END} },
261
262 // '~ FF' => Cursor Up
263 { "~\x0c", 2, { ConvCtrl::CursorUp, ConvCtrl::END} },
264
265 // DLE => Cursor Right
266 { "\x10", 1, { ConvCtrl::CursorRight, ConvCtrl::END} },
267
268 // '~ SI' => Erase to end of line
269 { "~\x0f", 2, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
270
271 // '~ DC1 x y' => Cursor Position (cursorX = x+1, cursorY = y+1)
272 { "~\x11\xff\xff", 4, { ConvCtrl::CursorPos2, ConvCtrl::END} },
273
274 // '~ DC2' => Cursor Home
275 { "~\x12", 2, { ConvCtrl::CursorHome, ConvCtrl::END} },
276
277 // '~ DC3' => Delete Line
278 { "~\x13", 2, { ConvCtrl::DeleteLine, ConvCtrl::END} },
279
280 // '~ CAN' => Clear to end of Screen
281 { "~\x18", 2, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
282
283 // '~ ETB' => Clear to end of Screen
284 { "~\x17", 2, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
285
286 // '~ FS' => Cursor home and Clear screen
287 { "~\x1c", 2, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
288
289 // '~ SUB' => Insert Line
290 { "~\x1a", 2, { ConvCtrl::InsertLine, ConvCtrl::END} },
291
292 // '~ EM' => Char Attribute: Half intensity ON
293 { "~\x19", 2, { ConvCtrl::AttrReduce, ConvCtrl::END} },
294
295 // '~ US' => Char Attribute: Half intensity oFF
296 { "~\x1f", 2, { ConvCtrl::AttrReduceOff, ConvCtrl::END} },
297
298 // Last item marker
299 { nullptr, 0, { } },
300};
301
302
303const TermInfo term_Hazeltine1500 = {
304 "",
305 videoConv_Hazeltine1500,
306 kbdConv_Generic
307};
308
309
311// Osborne I
312
313
314// sorted by TermSeq name
315const TermInfoVideoConv videoConv_Osborne[] = {
316 // BS => Cursor Left
317 { "\x08", 1, { ConvCtrl::CursorLeft, ConvCtrl::END } },
318
319 // 'VT' => Cursor Up
320 { "\x0b", 1, { ConvCtrl::CursorUp, ConvCtrl::END} },
321
322 // 'FF' => Cursor Right
323 { "\x0c", 1, { ConvCtrl::CursorRight, ConvCtrl::END} },
324
325 // SUB => Cursor home and Clear screen
326 { "\x1a", 1, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
327
328 // RS => Cursor Home
329 { "\x1e", 1, { ConvCtrl::CursorHome, ConvCtrl::END} },
330
331 // 'ESC )' => Char Attribute: Half intensity ON
332 { "\e)", 2, { ConvCtrl::AttrReduce, ConvCtrl::END} },
333
334 // 'ESC (' => Char Attribute: Half intensity OFF
335 { "\e(", 2, { ConvCtrl::AttrReduceOff, ConvCtrl::END} },
336
337 // 'ESC E' => Insert Line
338 { "\eE", 2, { ConvCtrl::InsertLine, ConvCtrl::END} },
339
340 // 'ESC l' => Char Attribute: Underline
341 { "\el", 3, { ConvCtrl::AttrUnderline, ConvCtrl::END} },
342
343 // 'ESC m' => Char Attribute: Underline OFF
344 { "\el", 3, { ConvCtrl::AttrUnderlineOff, ConvCtrl::END} },
345
346 // 'ESC Q' => Insert Character
347 { "\eQ", 2, { ConvCtrl::InsertChar, ConvCtrl::END} },
348
349 // 'ESC R' => Delete Line
350 { "\eR", 2, { ConvCtrl::DeleteLine, ConvCtrl::END} },
351
352 // 'ESC T' => Erase to end of line
353 { "\eT", 2, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
354
355 // 'ESC W' => Delete Character
356 { "\eW", 2, { ConvCtrl::DeleteCharacter, ConvCtrl::END} },
357
358 // 'ESC = y x' => Cursor Position (cursorX = x-31, cursorY = y-31)
359 { "\e=\xff\xff", 4, { ConvCtrl::CursorPos, ConvCtrl::END} },
360
361 // Last item marker
362 { nullptr, 0, { } },
363};
364
365
366const TermInfo term_Osborne = {
367 "",
368 videoConv_Osborne,
369 kbdConv_Generic
370};
371
372
373
375// Kaypro
376
377
378// sorted by TermSeq name
379const TermInfoVideoConv videoConv_Kaypro[] = {
380
381 // BS => Cursor Left
382 { "\x08", 1, { ConvCtrl::CursorLeft, ConvCtrl::END } },
383
384 // 'FF' => Cursor Right
385 { "\x0c", 1, { ConvCtrl::CursorRight, ConvCtrl::END} },
386
387 // 'VT' => Cursor Up
388 { "\x0b", 1, { ConvCtrl::CursorUp, ConvCtrl::END} },
389
390 // ETB => Erase to end of screen
391 { "\x17", 1, { ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
392
393 // CAN => Erase to end of line
394 { "\x18", 1, { ConvCtrl::EraseToEndOfLine, ConvCtrl::END} },
395
396 // SUB => Cursor home and Clear screen
397 { "\x1a", 1, { ConvCtrl::CursorHome, ConvCtrl::EraseToEndOfScreen, ConvCtrl::END} },
398
399 // RS => Cursor Home
400 { "\x1e", 1, { ConvCtrl::CursorHome, ConvCtrl::END} },
401
402 // 'ESC E' => Insert Line
403 { "\eE", 2, { ConvCtrl::InsertLine, ConvCtrl::END} },
404
405 // 'ESC R' => Delete Line
406 { "\eR", 2, { ConvCtrl::DeleteLine, ConvCtrl::END} },
407
408 // 'ESC = y x' => Cursor Position (cursorX = x-31, cursorY = y-31)
409 { "\e=\xff\xff", 4, { ConvCtrl::CursorPos, ConvCtrl::END} },
410
411 // 'ESC B 0' => Char Attribute: Reverse
412 { "\eB0", 3, { ConvCtrl::AttrReverse, ConvCtrl::END} },
413
414 // 'ESC C 0' => Char Attribute: Reverse Off
415 { "\eC0", 3, { ConvCtrl::AttrReverseOff, ConvCtrl::END} },
416
417 // 'ESC B 1' => Char Attribute: Reduce
418 { "\eB1", 3, { ConvCtrl::AttrReduce, ConvCtrl::END} },
419
420 // 'ESC C 1' => Char Attribute: Reduce Off
421 { "\eC1", 3, { ConvCtrl::AttrReduceOff, ConvCtrl::END} },
422
423 // 'ESC B 2' => Char Attribute: Blink
424 { "\eB2", 3, { ConvCtrl::AttrBlink, ConvCtrl::END} },
425
426 // 'ESC C 2' => Char Attribute: Blink Off
427 { "\eC2", 3, { ConvCtrl::AttrBlinkOff, ConvCtrl::END} },
428
429 // 'ESC B 3' => Char Attribute: Underline
430 { "\eB3", 3, { ConvCtrl::AttrUnderline, ConvCtrl::END} },
431
432 // 'ESC C 3' => Char Attribute: Underline Off
433 { "\eC3", 3, { ConvCtrl::AttrUnderlineOff, ConvCtrl::END} },
434
435 // 'ESC B 4' => Cursor On
436 { "\eB4", 4, { ConvCtrl::CursorOn, ConvCtrl::END} },
437
438 // 'ESC C 4' => Cursor Off
439 { "\eC4", 4, { ConvCtrl::CursorOff, ConvCtrl::END} },
440
441 // 'ESC B 6' => Save Cursor
442 { "\eB6", 4, { ConvCtrl::SaveCursor, ConvCtrl::END} },
443
444 // 'ESC C 6' => Restore Cursor
445 { "\eC6", 4, { ConvCtrl::RestoreCursor, ConvCtrl::END} },
446
447 // Last item marker
448 { nullptr, 0, { } },
449};
450
451
452const TermInfo term_Kaypro = {
453 "",
454 videoConv_Kaypro,
455 kbdConv_Generic
456};
457
458
459
461// VT52
462
463
464// sorted by TermSeq name
465const TermInfoVideoConv videoConv_VT52[] = {
466
467 // Last item marker
468 { nullptr, 0, { } },
469};
470
471
472const TermInfo term_VT52 = {
473 "\e[?2l", // <= set VT52 mode
474 videoConv_VT52,
475 kbdConv_Generic
476};
477
478
480// ANSI Legacy
481
482
483// sorted by TermSeq name
484const TermInfoVideoConv videoConv_ANSILegacy[] = {
485
486 // Last item marker
487 { nullptr, 0, { } },
488};
489
490
491const TermInfo term_ANSILegacy = {
492 "",
493 videoConv_ANSILegacy,
494 kbdConv_Generic
495};
496
497
498}
@ VK_PAGEUP
Definition: fabutils.h:1252
@ VK_UP
Definition: fabutils.h:1256
@ VK_END
Definition: fabutils.h:1241
@ VK_PAGEDOWN
Definition: fabutils.h:1254
@ VK_DOWN
Definition: fabutils.h:1258
@ VK_HOME
Definition: fabutils.h:1239
@ VK_DELETE
Definition: fabutils.h:1236
@ VK_BACKSPACE
Definition: fabutils.h:1238
@ VK_NONE
Definition: fabutils.h:1098
@ VK_LEFT
Definition: fabutils.h:1260
@ VK_RIGHT
Definition: fabutils.h:1262
This file contains terminal emulation definitions.