1 /*
2  * Copyright (c) 2018 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef SHELL_VT100_H__
8 #define SHELL_VT100_H__
9 
10 #define SHELL_VT100_ASCII_ESC		(0x1b)
11 #define SHELL_VT100_ASCII_DEL		(0x7F)
12 #define SHELL_VT100_ASCII_BSPACE	(0x08)
13 #define SHELL_VT100_ASCII_CTRL_A	(0x01)
14 #define SHELL_VT100_ASCII_CTRL_B	(0x02)
15 #define SHELL_VT100_ASCII_CTRL_C	(0x03)
16 #define SHELL_VT100_ASCII_CTRL_D	(0x04)
17 #define SHELL_VT100_ASCII_CTRL_E	(0x05)
18 #define SHELL_VT100_ASCII_CTRL_F	(0x06)
19 #define SHELL_VT100_ASCII_CTRL_K	(0x0B)
20 #define SHELL_VT100_ASCII_CTRL_L	(0x0C)
21 #define SHELL_VT100_ASCII_CTRL_N	(0x0E)
22 #define SHELL_VT100_ASCII_CTRL_P	(0x10)
23 #define SHELL_VT100_ASCII_CTRL_U	(0x15)
24 #define SHELL_VT100_ASCII_CTRL_W	(0x17)
25 #define SHELL_VT100_ASCII_ALT_B		(0x62)
26 #define SHELL_VT100_ASCII_ALT_F		(0x66)
27 #define SHELL_VT100_ASCII_ALT_R		(0x72)
28 
29 /* Set new line mode */
30 #define SHELL_VT100_SETNL		"\e[20h\0"
31 /* Set cursor key to application */
32 #define SHELL_VT100_SETAPPL		"\e[?1h\0"
33 /* Set number of columns to 132 */
34 #define SHELL_VT100_SETCOL_132		"\e[?3h\0"
35 /* Set smooth scrolling */
36 #define SHELL_VT100_SETSMOOTH		"\e[?4h\0"
37 /* Set reverse video on screen */
38 #define SHELL_VT100_SETREVSCRN		"\e[?5h\0"
39 /* Set origin to relative */
40 #define SHELL_VT100_SETORGREL		"\e[?6h\0"
41 /* Set auto-wrap mode */
42 #define SHELL_VT100_SETWRAP_ON		"\e[?7h\0"
43 /* Set auto-wrap mode */
44 #define SHELL_VT100_SETWRAP_OFF		"\e[?7l\0"
45 /* Set auto-repeat mode */
46 #define SHELL_VT100_SETREP		"\e[?8h\0"
47 /* Set interlacing mode */
48 #define SHELL_VT100_SETINTER		"\e[?9h\0"
49 /* Set line feed mode */
50 #define SHELL_VT100_SETLF		"\e[20l\0"
51 /* Set cursor key to cursor */
52 #define SHELL_VT100_SETCURSOR		"\e[?1l\0"
53 /* Set VT52 (versus ANSI) */
54 #define SHELL_VT100_SETVT52		"\e[?2l\0"
55 /* Set number of columns to 80 */
56 #define SHELL_VT100_SETCOL_80		"\e[?3l\0"
57 /* Set jump scrolling */
58 #define SHELL_VT100_SETJUMP		"\e[?4l\0"
59 /* Set normal video on screen */
60 #define SHELL_VT100_SETNORMSCRN		"\e[?5l\0"
61 /* Set origin to absolute */
62 #define SHELL_VT100_SETORGABS		"\e[?6l\0"
63 /* Reset auto-wrap mode */
64 #define SHELL_VT100_RESETWRAP		"\e[?7l\0"
65 /* Reset auto-repeat mode */
66 #define SHELL_VT100_RESETREP		"\e[?8l\0"
67 /* Reset interlacing mode */
68 #define SHELL_VT100_RESETINTER		"\e[?9l\0"
69 /* Set alternate keypad mode */
70 #define SHELL_VT100_ALTKEYPAD		"\e=\0"
71 /* Set numeric keypad mode */
72 #define SHELL_VT100_NUMKEYPAD		"\e>\0"
73 /* Set United Kingdom G0 character set */
74 #define SHELL_VT100_SETUKG0		"\e(A\0"
75 /* Set United Kingdom G1 character set */
76 #define SHELL_VT100_SETUKG1		"\e)A\0"
77 /* Set United States G0 character set */
78 #define SHELL_VT100_SETUSG0		"\e(B\0"
79 /* Set United States G1 character set */
80 #define SHELL_VT100_SETUSG1		"\e)B\0"
81 /* Set G0 special chars. & line set */
82 #define SHELL_VT100_SETSPECG0		"\e(0\0"
83 /* Set G1 special chars. & line set */
84 #define SHELL_VT100_SETSPECG1		"\e)0\0"
85 /* Set G0 alternate character ROM */
86 #define SHELL_VT100_SETALTG0		"\e(1\0"
87 /* Set G1 alternate character ROM */
88 #define SHELL_VT100_SETALTG1		"\e)1\0"
89 /* Set G0 alt char ROM and spec. graphics */
90 #define SHELL_VT100_SETALTSPECG0	"\e(2\0"
91 /* Set G1 alt char ROM and spec. graphics */
92 #define SHELL_VT100_SETALTSPECG1	"\e)2\0"
93 /* Set single shift 2 */
94 #define SHELL_VT100_SETSS2		"\eN\0"
95 /* Set single shift 3 */
96 #define SHELL_VT100_SETSS3		"\eO\0"
97 /* Turn off character attributes */
98 #define SHELL_VT100_MODESOFF		"\e[m\0"
99 /* Turn off character attributes */
100 #define SHELL_VT100_MODESOFF_		"\e[0m\0"
101 /* Turn bold mode on */
102 #define SHELL_VT100_BOLD		"\e[1m\0"
103 /* Turn low intensity mode on */
104 #define SHELL_VT100_LOWINT		"\e[2m\0"
105 /* Turn underline mode on */
106 #define SHELL_VT100_UNDERLINE		"\e[4m\0"
107 /* Turn blinking mode on */
108 #define SHELL_VT100_BLINK		"\e[5m\0"
109 /* Turn reverse video on */
110 #define SHELL_VT100_REVERSE		"\e[7m\0"
111 /* Turn invisible text mode on */
112 #define SHELL_VT100_INVISIBLE		"\e[8m\0"
113 /* Move cursor to upper left corner */
114 #define SHELL_VT100_CURSORHOME		"\e[H\0"
115 /* Move cursor to upper left corner */
116 #define SHELL_VT100_CURSORHOME_		"\e[;H\0"
117 /* Move cursor to upper left corner */
118 #define SHELL_VT100_HVHOME		"\e[f\0"
119 /* Move cursor to upper left corner */
120 #define SHELL_VT100_HVHOME_		"\e[;f\0"
121 /* Move/scroll window up one line */
122 #define SHELL_VT100_INDEX		"\eD\0"
123 /* Move/scroll window down one line */
124 #define SHELL_VT100_REVINDEX		"\eM\0"
125 /* Move to next line */
126 #define SHELL_VT100_NEXTLINE		"\eE\0"
127 /* Save cursor position and attributes */
128 #define SHELL_VT100_SAVECURSOR		"\e7\0"
129 /* Restore cursor position and attribute */
130 #define SHELL_VT100_RESTORECURSOR	"\e8\0"
131 /* Set a tab at the current column */
132 #define SHELL_VT100_TABSET		"\eH\0"
133 /* Clear a tab at the current column */
134 #define SHELL_VT100_TABCLR		"\e[g\0"
135 /* Clear a tab at the current column */
136 #define SHELL_VT100_TABCLR_		"\e[0g\0"
137 /* Clear all tabs */
138 #define SHELL_VT100_TABCLRALL		"\e[3g\0"
139 /* Double-height letters, top half */
140 #define SHELL_VT100_DHTOP		"\e#3\0"
141 /* Double-height letters, bottom hal */
142 #define SHELL_VT100_DHBOT		"\e#4\0"
143 /* Single width, single height letters */
144 #define SHELL_VT100_SWSH		"\e#5\0"
145 /* Double width, single height letters */
146 #define SHELL_VT100_DWSH		"\e#6\0"
147 /* Clear line from cursor right */
148 #define SHELL_VT100_CLEAREOL		"\e[K\0"
149 /* Clear line from cursor right */
150 #define SHELL_VT100_CLEAREOL_		"\e[0K\0"
151 /* Clear line from cursor left */
152 #define SHELL_VT100_CLEARBOL		"\e[1K\0"
153 /* Clear entire line */
154 #define SHELL_VT100_CLEARLINE		"\e[2K\0"
155 /* Clear screen from cursor down */
156 #define SHELL_VT100_CLEAREOS		"\e[J\0"
157 /* Clear screen from cursor down */
158 #define SHELL_VT100_CLEAREOS_		"\e[0J\0"
159 /* Clear screen from cursor up */
160 #define SHELL_VT100_CLEARBOS		"\e[1J\0"
161 /* Clear entire screen */
162 #define SHELL_VT100_CLEARSCREEN		"\e[2J\0"
163 /* Device status report */
164 #define SHELL_VT100_DEVSTAT		"\e5n\0"
165 /* Response: terminal is OK */
166 #define SHELL_VT100_TERMOK		"\e0n\0"
167 /* Response: terminal is OK */
168 #define SHELL_VT100_TERMNOK		"\e3n\0"
169 /* Get cursor position */
170 #define SHELL_VT100_GETCURSOR		"\e[6n\0"
171 /* Response: cursor is at v,h */
172 #define SHELL_VT100_CURSORPOSAT		"\e, (v);', (h)R\0"
173 /* Identify what terminal type */
174 #define SHELL_VT100_IDENT		"\e[c\0"
175 /* Identify what terminal type */
176 #define SHELL_VT100_IDENT_		"\e[0c\0"
177 /* Response: terminal type code n */
178 #define SHELL_VT100_GETTYPE		"\e[?1;', (n)0c\0"
179 /*Reset terminal to initial state */
180 #define SHELL_VT100_RESET		"\ec\0"
181 /* Screen alignment display */
182 #define SHELL_VT100_ALIGN		"\e#8\0"
183 /* Confidence power up test */
184 #define SHELL_VT100_TESTPU		"\e[2;1y\0"
185 /* Confidence loopback test */
186 #define SHELL_VT100_TESTLB		"\e[2;2y\0"
187 /* Repeat power up test */
188 #define SHELL_VT100_TESTPUREP		"\e[2;9y\0"
189 /* Repeat loopback test */
190 #define SHELL_VT100_TESTLBREP		"\e[2;10y\0"
191 /* Turn off all four leds */
192 #define SHELL_VT100_LEDSOFF		"\e[0q\0"
193 /* Turn on LED #1 */
194 #define SHELL_VT100_LED1		"\e[1q\0"
195 /* Turn on LED #2 */
196 #define SHELL_VT100_LED2		"\e[2q\0"
197 /* Turn on LED #3 */
198 #define SHELL_VT100_LED3		"\e[3q\0"
199 /* Turn on LED #4 */
200 #define SHELL_VT100_LED4		"\e[4q\0"
201 
202 /* Function Keys */
203 #define SHELL_VT100_PF1			"\eOP\0"
204 #define SHELL_VT100_PF2			"\eOQ\0"
205 #define SHELL_VT100_PF3			"\eOR\0"
206 #define SHELL_VT100_PF4			"\eOS\0"
207 
208 /* Arrow keys */
209 #define SHELL_VT100_UP_RESET		"\eA\0"
210 #define SHELL_VT100_UP_SET		"\eOA\0"
211 #define SHELL_VT100_DOWN_RESET		"\eB\0"
212 #define SHELL_VT100_DOWN_SET		"\eOB\0"
213 #define SHELL_VT100_RIGHT_RESET		"\eC\0"
214 #define SHELL_VT100_RIGHT_SET		"\eOC\0"
215 #define SHELL_VT100_LEFT_RESET		"\eD\0"
216 #define SHELL_VT100_LEFT_SET		"\eOD\0"
217 
218 /* Numeric Keypad Keys */
219 #define SHELL_VT100_NUMERIC_0		"0\0"
220 #define SHELL_VT100_ALT_0		"\eOp\0"
221 #define SHELL_VT100_NUMERIC_1		"1\0"
222 #define SHELL_VT100_ALT_1		"\eOq\0"
223 #define SHELL_VT100_NUMERIC_2		"2\0"
224 #define SHELL_VT100_ALT_2		"\eOr\0"
225 #define SHELL_VT100_NUMERIC_3		"3\0"
226 #define SHELL_VT100_ALT_3		"\eOs\0"
227 #define SHELL_VT100_NUMERIC_4		"4\0"
228 #define SHELL_VT100_ALT_4		"\eOt\0"
229 #define SHELL_VT100_NUMERIC_5		"5\0"
230 #define SHELL_VT100_ALT_5		"\eOu\0"
231 #define SHELL_VT100_NUMERIC_6		"6\0"
232 #define SHELL_VT100_ALT_6		"\eOv\0"
233 #define SHELL_VT100_NUMERIC_7		"7\0"
234 #define SHELL_VT100_ALT_7		"\eOw\0"
235 #define SHELL_VT100_NUMERIC_8		"8\0"
236 #define SHELL_VT100_ALT_8		"\eOx\0"
237 #define SHELL_VT100_NUMERIC_9		"9\0"
238 #define SHELL_VT100_ALT_9		"\eOy\0"
239 #define SHELL_VT100_NUMERIC_MINUS	"-\0"
240 #define SHELL_VT100_ALT_MINUS		"\eOm\0"
241 #define SHELL_VT100_NUMERIC_COMMA	",\0"
242 #define SHELL_VT100_ALT_COMMA		"\eOl\0"
243 #define SHELL_VT100_NUMERIC_ENTER	ASCII_CR
244 #define SHELL_VT100_NUMERIC_PERIOD	".\0"
245 #define SHELL_VT100_ALT_PERIOD		"\eOn\0"
246 #define SHELL_VT100_ALT_ENTER		"\eOM\0"
247 
248 #endif /* SHELL_VT100_H__ */
249