ttx 0.1.0
Loading...
Searching...
No Matches
capabilities.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace ttx::terminal {
6constexpr auto ttx_names = di::Array {
7 "xterm-ttx"_tsv,
8 "ttx"_tsv,
9 "ttx terminal multiplexer"_tsv,
10};
11
12// These capabilities are sourced from different places, including:
13// terminfo man page: https://manned.org/man/arch/terminfo.5
14// user_caps man page: https://manned.org/man/arch/user_caps.5
15// tmux man page (TERMINFO extensions): https://manned.org/man/arch/user_caps.5
16// and checked against ghostty and kitty's terminfo via `infocmp -x`
17//
18// The list is sorted alphabetically (mostly) after grouping by value type. This matches the output
19// of `infocmp -x` so we can easily compare this list of the output.
20constexpr auto ttx_capabilities = di::Array {
22 .long_name = "Automatic right margin"_sv,
23 .short_name = "am"_tsv,
24 .description = "Automatic margins (autowrap enabled by default)"_sv,
25 },
27 .long_name = "Background character erase"_sv,
28 .short_name = "bce"_tsv,
29 .description = "Clearing the screens sets the background color, instead of resetting the cell fully"_sv,
30 // TODO: enable if we ever decide to implement bce
31 .enabled = false,
32 },
34 .long_name = "Modifiable palette"_sv,
35 .short_name = "ccc"_tsv,
36 .description = "Terminal allows modifying the color palette dynamically"_sv,
37 // TODO: enable after support this xterm escape (and the kitty version)
38 // https://sw.kovidgoyal.net/kitty/color-stack/
39 .enabled = false,
40 },
42 .long_name = "Has status line"_sv,
43 .short_name = "hs"_tsv,
44 .description = "Has status line (for displaying window title)"_sv,
45 .enabled = false, // TODO: enable after implementing OSC 1 (set window title)
46 },
48 .long_name = "Has meta key"_sv,
49 .short_name = "km"_tsv,
50 .description = "Keyboard reports include meta key bit on modifiers"_sv,
51 },
53 .long_name = "No built-in echo"_sv,
54 .short_name = "mc5i"_tsv,
55 .description = "Terminal won't echo (presumably key presses) automatically"_sv,
56 },
58 .long_name = "Move in insert mode"_sv,
59 .short_name = "mir"_tsv,
60 .description = "Cursor can move in insert mode"_sv,
61 },
63 .long_name = "Move in standout mode"_sv,
64 .short_name = "msgr"_tsv,
65 .description = "Cursor can move in standout mode (apparently standout mode is inverse (SGR 7))"_sv,
66 },
68 .long_name = "No pad character"_sv,
69 .short_name = "npc"_tsv,
70 .description = "? What is a pad character"_sv,
71 },
73 .long_name = "Newline ignored after 80 cols"_sv,
74 .short_name = "xenl"_tsv,
75 .description = "? - This is set by xterm"_sv,
76 },
78 .long_name = "Default colors"_sv,
79 .short_name = "AX"_tsv,
80 .description = "Supports resetting the foreground/background via SGR 39/49"_sv,
81 },
83 .long_name = "Colored underlines"_sv,
84 .short_name = "Su"_tsv,
85 .description = "Supports changing underline color via SGR 58-59"_sv,
86 },
88 .long_name = "Truecolor"_sv,
89 .short_name = "Tc"_tsv,
90 .description = "Supports 24 bit true color via SGR 38/38"_sv,
91 },
93 .long_name = "Xterm extnesions"_sv,
94 .short_name = "XT"_tsv,
95 .description = "Supports various xterm extensions (tmux uses this to set some default capabilities)"_sv,
96 // TODO: enable if supporting bce
97 .enabled = false,
98 },
100 .long_name = "Kitty keyboard protocol"_sv,
101 .short_name = "fullkbd"_tsv,
102 .description = "Supports kitty keyboard protocol"_sv,
103 },
104 Capability {
105 .long_name = "Maximum colors"_sv,
106 .short_name = "colors"_tsv,
107 .value = 256u,
108 .description = "Number of colors in the palette"_sv,
109 },
110 Capability {
111 .long_name = "Columns"_sv,
112 .short_name = "cols"_tsv,
113 .value = 80u,
114 .description = "Number of columns on screen (this is dynamic)"_sv,
115 },
116 Capability {
117 .long_name = "Initial tab spacing"_sv,
118 .short_name = "it"_tsv,
119 .value = 8u,
120 .description = "Default spacing used for tab characters"_sv,
121 },
122 Capability {
123 .long_name = "Lines"_sv,
124 .short_name = "lines"_tsv,
125 .value = 24u,
126 .description = "Number of lines (rows) on screen (this is dynamic)"_sv,
127 },
128 Capability {
129 .long_name = "Maximum color pairs"_sv,
130 .short_name = "pairs"_tsv,
131 .value = 0x7fffu, // We use a 16-bit style id internally
132 .description = "Number of different graphics renditions which can co-exist on the screen"_sv,
133 },
134 Capability {
135 .long_name = "UTF-8 always"_sv,
136 .short_name = "U8"_tsv,
137 // TODO: remove this capability after supporting box drawing characters
138 .value = 1u,
139 .description = "Disable box drawing characters by saying we only support UTF-8"_sv,
140 },
141 Capability {
142 .long_name = "Alternate charset pairs"_sv,
143 .short_name = "acsc"_tsv,
144 .value = "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"_tsv, // Magic copied from xterm's terminfo
145 .description = "Alternate charset mapping (this is the identity)"_sv,
146 },
147 Capability {
148 .long_name = "Bell"_sv,
149 .short_name = "bel"_tsv,
150 .value = "^G"_tsv,
151 .description = "Bell character - \\a"_sv,
152 },
153 Capability {
154 .long_name = "Blink"_sv,
155 .short_name = "blink"_tsv,
156 .value = "\\E[5m"_tsv,
157 .description = "Set blinking cell via SGR 5"_sv,
158 },
159 Capability {
160 .long_name = "Bold"_sv,
161 .short_name = "bold"_tsv,
162 .value = "\\E[1m"_tsv,
163 .description = "Set bold cell via SGR 1"_sv,
164 },
165 Capability {
166 .long_name = "Shift tab"_sv,
167 .short_name = "cbt"_tsv,
168 .value = "\\E[Z"_tsv,
169 .description = "Terminal sends CSI Z on shift+tab"_sv,
170 },
171 Capability {
172 .long_name = "Invisible cursor"_sv,
173 .short_name = "civis"_tsv,
174 .value = "\\E[?25l"_tsv,
175 .description = "Hide the cursor via CSI ? 25 l"_sv,
176 },
177 Capability {
178 .long_name = "Clear"_sv,
179 .short_name = "clear"_tsv,
180 .value = "\\E[H\\E[2J"_tsv,
181 .description = "Clear the scren by sending CSI H (cursor to 0,0) and CSI 2 J (clear full screen)"_sv,
182 },
183 Capability {
184 .long_name = "Cursor Normal"_sv,
185 .short_name = "cnorm"_tsv,
186 // We currently don't support mode 12 to control the cursor blinking, but
187 // there's no harm in adding it now.
188 .value = "\\E[?12h\\E[?25h"_tsv,
189 .description = "Reset the cursor by enabling blinking (CSI ? 12 h) and showing the cursor (CSI ? 25 h)"_sv,
190 },
191 Capability {
192 .long_name = "Carriage return"_sv,
193 .short_name = "cr"_tsv,
194 .value = "\\r"_tsv,
195 .description = "Terminal recognizes \\r as carrigate return"_sv,
196 },
197 Capability {
198 .long_name = "Change scroll region"_sv,
199 .short_name = "csr"_tsv,
200 .value = "\\E[%i%p1%d;%p2%dr"_tsv, // Copied from ghostty/kitty
201 .description = "Set vertical scroll region via CSI b; t r"_sv,
202 },
203 Capability {
204 .long_name = "Paramaterized cursor back"_sv,
205 .short_name = "cub"_tsv,
206 .value = "\\E[%p1%dD"_tsv, // Copied from ghostty/kitty
207 .description = "Move cursor left via CSI Ps D"_sv,
208 },
209 Capability {
210 .long_name = "Cursor back"_sv,
211 .short_name = "cub1"_tsv,
212 .value = "^H"_tsv,
213 .description = "Move cursor left 1 via \\b (^H)"_sv,
214 },
215 Capability {
216 .long_name = "Paramaterized cursor down"_sv,
217 .short_name = "cud"_tsv,
218 .value = "\\E[%p1%dB"_tsv,
219 .description = "Move cursor down via CSI Ps B"_sv,
220 },
221 Capability {
222 .long_name = "Cursor down"_sv,
223 .short_name = "cud1"_tsv,
224 .value = "\\n"_tsv,
225 .description = "Move cursor down 1 via \\n"_sv,
226 },
227 Capability {
228 .long_name = "Paramaterized cursor right"_sv,
229 .short_name = "cuf"_tsv,
230 .value = "\\E[%p1%dC"_tsv,
231 .description = "Move cursor right via CSI Ps C"_sv,
232 },
233 Capability {
234 .long_name = "Cursor right"_sv,
235 .short_name = "cuf1"_tsv,
236 .value = "\\E[C"_tsv,
237 .description = "Move cursor right 1 via CSI C"_sv,
238 },
239 Capability {
240 .long_name = "Cursor address"_sv,
241 .short_name = "cup"_tsv,
242 .value = "\\E[%i%p1%d;%p2%dH"_tsv, // Copied from ghostty/kitty
243 .description = "Move cursor to r,c via CSI r; c H"_sv,
244 },
245 Capability {
246 .long_name = "Paramaterized cursor up"_sv,
247 .short_name = "cuu"_tsv,
248 .value = "\\E[%p1%dA"_tsv,
249 .description = "Move cursor up via CSI Ps A"_sv,
250 },
251 Capability {
252 .long_name = "Cursor up"_sv,
253 .short_name = "cuu1"_tsv,
254 .value = "\\E[A"_tsv,
255 .description = "Move cursor up 1 via CSI A"_sv,
256 },
257 Capability {
258 .long_name = "Cursor visible"_sv,
259 .short_name = "cvvis"_tsv,
260 // This is the same as cnorm except in a single CSI sequence.
261 .value = "\\E[?12;25h"_tsv, // copied from ghostty/kitty
262 .description = "Make cursor visible via CSI ? 12 ; 25 h"_sv,
263 },
264 Capability {
265 .long_name = "Delete characters"_sv,
266 .short_name = "dch"_tsv,
267 .value = "\\E[%p1%dP"_tsv,
268 .description = "Delete characters via CSI Ps P"_sv,
269 },
270 Capability {
271 .long_name = "Delete character"_sv,
272 .short_name = "dch1"_tsv,
273 .value = "\\E[P"_tsv,
274 .description = "Delete character via CSI P"_sv,
275 },
276 Capability {
277 .long_name = "Dim"_sv,
278 .short_name = "dim"_tsv,
279 .value = "\\E[2m"_tsv,
280 .description = "Dim the cell via SGR 2"_sv,
281 },
282 Capability {
283 .long_name = "Delete lines"_sv,
284 .short_name = "dl"_tsv,
285 .value = "\\E[%p1%dM"_tsv,
286 .description = "Delete lines via CSI Ps M"_sv,
287 },
288 Capability {
289 .long_name = "Delete line"_sv,
290 .short_name = "dl1"_tsv,
291 .value = "\\E[M"_tsv,
292 .description = "Delete line via CSI M"_sv,
293 },
294 Capability {
295 .long_name = "Disable status line"_sv,
296 .short_name = "dsl"_tsv,
297 .value = R"(\E]2;\E\\)"_tsv,
298 .description = "Disable window title via blank OSC 2"_sv,
299 // TODO: enable once we support OSC 1/2
300 .enabled = false,
301 },
302 Capability {
303 .long_name = "Erase characters"_sv,
304 .short_name = "ech"_tsv,
305 .value = "\\E[%p1%dX"_tsv,
306 .description = "Erase characters via CSI Ps X"_sv,
307 },
308 Capability {
309 .long_name = "Erase display"_sv,
310 .short_name = "ed"_tsv,
311 .value = "\\E[J"_tsv,
312 .description = "Erase to screen end via CSI J"_sv,
313 },
314 Capability {
315 .long_name = "Erase line"_sv,
316 .short_name = "el"_tsv,
317 .value = "\\E[K"_tsv,
318 .description = "Erase to line end via CSI K"_sv,
319 },
320 Capability {
321 .long_name = "Erase line beginning"_sv,
322 .short_name = "el1"_tsv,
323 .value = "\\E[1K"_tsv,
324 .description = "Erase to beginning of line end via CSI 1 K"_sv,
325 },
326 Capability {
327 .long_name = "Flash"_sv,
328 .short_name = "flash"_tsv,
329 .value = "\\E[?5h$<100/>\\E[?5l"_tsv, // Copied from ghostty/kitty
330 .description = "Flash screen via enabling/disabling video reverse mode (CSI ? 5 h/l), after 100 ms"_sv,
331 },
332 Capability {
333 .long_name = "From status line"_sv,
334 .short_name = "fsl"_tsv,
335 .value = "^G"_tsv,
336 .description = "Terminate OSC sequence via \\a (^G)"_sv,
337 // TODO: enable after supporting OSC 2
338 .enabled = false,
339 },
340 Capability {
341 .long_name = "Home"_sv,
342 .short_name = "home"_tsv,
343 .value = "\\E[H"_tsv,
344 .description = "Move cursor to home via CSI H"_sv,
345 },
346 Capability {
347 .long_name = "Horizontal position absolute"_sv,
348 .short_name = "hpa"_tsv,
349 .value = "\\E[%i%p1%dG"_tsv,
350 .description = "Set cursor col to n via CSI n G"_sv,
351 },
352 Capability {
353 .long_name = "Horizontal tab"_sv,
354 .short_name = "ht"_tsv,
355 .value = "^I"_tsv,
356 .description = "Terminal recognizes tab as \\t (^I)"_sv,
357 },
358 Capability {
359 .long_name = "Horizontal tab set"_sv,
360 .short_name = "hts"_tsv,
361 .value = "\\EH"_tsv,
362 .description = "Set horizontal tab via CI HTS (ESC H)"_sv,
363 },
364 Capability {
365 .long_name = "Insert characters"_sv,
366 .short_name = "ich"_tsv,
367 .value = "\\E[%p1%d@"_tsv,
368 .description = "Insert characters via CSI Ps @"_sv,
369 },
370 Capability {
371 .long_name = "Insert character"_sv,
372 .short_name = "ich1"_tsv,
373 .value = "\\E[@"_tsv,
374 .description = "Insert character via CSI @"_sv,
375 },
376 Capability {
377 .long_name = "Insert lines"_sv,
378 .short_name = "il"_tsv,
379 .value = "\\E[%p1%dL"_tsv,
380 .description = "Insert lines via CSI Ps L"_sv,
381 },
382 Capability {
383 .long_name = "Insert line"_sv,
384 .short_name = "il1"_tsv,
385 .value = "\\E[L"_tsv,
386 .description = "Insert line via CSI L"_sv,
387 },
388 Capability {
389 .long_name = "Index"_sv,
390 .short_name = "ind"_tsv,
391 .value = "\\n"_tsv,
392 .description = "Scroll text down via \\n (we auto-scroll when moving the cursor down via \\n)"_sv,
393 },
394 Capability {
395 .long_name = "Scroll up"_sv,
396 .short_name = "indn"_tsv,
397 .value = "\\E[%p1%dS"_tsv,
398 .description = "Scroll up via CSI Ps S"_sv,
399 },
400 Capability {
401 .long_name = "Initialize color"_sv,
402 .short_name = "initc"_tsv,
403 .value =
404 R"(\E]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\)"_tsv,
405 .description = "Initialize color value via OSC 4"_sv,
406 // TODO: enable once we support setting color palette via OSC 4
407 .enabled = false,
408 },
409 Capability {
410 .long_name = "Invisible"_sv,
411 .short_name = "invis"_tsv,
412 .value = "\\E[8m"_tsv,
413 .description = "Make cell invisible via CSI 8"_sv,
414 },
415
416// Key board related capabiltiies. It would be good to have this in sync with our parser/generator.
417#define KEY_CAP(short, v, name) \
418 Capability { \
419 .long_name = name ""_sv, \
420 .short_name = short ""_tsv, \
421 .value = v ""_tsv, \
422 .description = "Escape terminal sends when " #name " is pressed"_sv, \
423 },
424
425#define KEYS(M) \
426 M("kBEG", "\\E[1;2E", "Shift+Begin") \
427 M("kDC", "\\E[3;2~", "Shift+Delete") \
428 M("kEND", "\\E[1;2F", "Shift+End") \
429 M("kHOM", "\\E[1;2H", "Shift+Home") \
430 M("kIC", "\\E[2;2~", "Shift+Insert") \
431 M("kLFT", "\\E[1;2D", "Shift+Left") \
432 M("kNXT", "\\E[6;2~", "Shift+PageDown") \
433 M("kPRV", "\\E[5;2~", "Shift+PageUp") \
434 M("kRIT", "\\E[1;2C", "Shift+Right") \
435 M("kbeg", "\\EOE", "Begin") \
436 M("kbs", "^?", "Backspace") \
437 M("kcbt", "\\E[Z", "Shift+Tab") \
438 M("kcub1", "\\EOD", "Left") \
439 M("kcud1", "\\EOB", "Down") \
440 M("kcuf1", "\\EOC", "Right") \
441 M("kcuu1", "\\EOA", "Up") \
442 M("kdch1", "\\E[3~", "Delete") \
443 M("kend", "\\EOF", "End") \
444 M("kf1", "\\EOP", "F1") \
445 M("kf10", "\\E[21~", "F10") \
446 M("kf11", "\\E[23~", "F11") \
447 M("kf12", "\\E[24~", "F12") \
448 M("kf13", "\\E[1;2P", "Shift+F1") \
449 M("kf14", "\\E[1;2Q", "Shift+F2") \
450 M("kf15", "\\E[1;2R", "Shift+F3") \
451 M("kf16", "\\E[1;2S", "Shift+F4") \
452 M("kf17", "\\E[15;2~", "Shift+F5") \
453 M("kf18", "\\E[17;2~", "Shift+F6") \
454 M("kf19", "\\E[18;2~", "Shift+F7") \
455 M("kf2", "\\EOQ", "F2") \
456 M("kf20", "\\E[19;2~", "Shift+F8") \
457 M("kf21", "\\E[20;2~", "Shift+F9") \
458 M("kf22", "\\E[21;2~", "Shift+F10") \
459 M("kf23", "\\E[23;2~", "Shift+F11") \
460 M("kf24", "\\E[24;2~", "Shift+F12") \
461 M("kf25", "\\E[1;5P", "Control+F1") \
462 M("kf26", "\\E[1;5Q", "Control+F2") \
463 M("kf27", "\\E[1;5R", "Control+F3") \
464 M("kf28", "\\E[1;5S", "Control+F4") \
465 M("kf29", "\\E[15;5~", "Control+F5") \
466 M("kf3", "\\EOR", "F3") \
467 M("kf30", "\\E[17;5~", "Control+F6") \
468 M("kf31", "\\E[18;5~", "Control+F7") \
469 M("kf32", "\\E[19;5~", "Control+F8") \
470 M("kf33", "\\E[20;5~", "Control+F9") \
471 M("kf34", "\\E[21;5~", "Control+F10") \
472 M("kf35", "\\E[23;5~", "Control+F11") \
473 M("kf36", "\\E[24;5~", "Control+F12") \
474 M("kf37", "\\E[1;6P", "Control+Shift+F1") \
475 M("kf38", "\\E[1;6Q", "Control+Shift+F2") \
476 M("kf39", "\\E[1;6R", "Control+Shift+F3") \
477 M("kf4", "\\EOS", "F4") \
478 M("kf40", "\\E[1;6S", "Control+Shift+F4") \
479 M("kf41", "\\E[15;6~", "Control+Shift+F5") \
480 M("kf42", "\\E[17;6~", "Control+Shift+F6") \
481 M("kf43", "\\E[18;6~", "Control+Shift+F7") \
482 M("kf44", "\\E[19;6~", "Control+Shift+F8") \
483 M("kf45", "\\E[20;6~", "Control+Shift+F9") \
484 M("kf46", "\\E[21;6~", "Control+Shift+F10") \
485 M("kf47", "\\E[23;6~", "Control+Shift+F11") \
486 M("kf48", "\\E[24;6~", "Control+Shift+F12") \
487 M("kf49", "\\E[1;3P", "Alt+F1") \
488 M("kf5", "\\E[15~", "F5") \
489 M("kf50", "\\E[1;3Q", "Alt+F2") \
490 M("kf51", "\\E[1;3R", "Alt+F3") \
491 M("kf52", "\\E[1;3S", "Alt+F4") \
492 M("kf53", "\\E[15;3~", "Alt+F5") \
493 M("kf54", "\\E[17;3~", "Alt+F6") \
494 M("kf55", "\\E[18;3~", "Alt+F7") \
495 M("kf56", "\\E[19;3~", "Alt+F8") \
496 M("kf57", "\\E[20;3~", "Alt+F9") \
497 M("kf58", "\\E[21;3~", "Alt+F10") \
498 M("kf59", "\\E[23;3~", "Alt+F11") \
499 M("kf6", "\\E[17~", "F6") \
500 M("kf60", "\\E[24;3~", "Alt+F12") \
501 M("kf61", "\\E[1;4P", "Alt+Shift+F1") \
502 M("kf62", "\\E[1;4Q", "Alt+Shift+F2") \
503 M("kf63", "\\E[1;4R", "Alt+Shift+F3") \
504 M("kf64", "\\E[1;4S", "Alt+Shift+F4") \
505 M("kf7", "\\E[18~", "F7") \
506 M("kf8", "\\E[19~", "F8") \
507 M("kf9", "\\E[20~", "F9") \
508 M("khome", "\\EOH", "Home") \
509 M("kich1", "\\E[2~", "Insert") \
510 M("kind", "\\E[1;2B", "Shift+Down") \
511 M("kmous", "\\E[M", "Mouse") \
512 M("knp", "\\E[6~", "PageDown") \
513 M("kpp", "\\E[5~", "PageUp") \
514 M("kri", "\\E[1;2A", "Shift+Up")
515
517 //
518
519 Capability {
520 .long_name = "Original colors"_sv,
521 .short_name = "oc"_tsv,
522 .value = "\\E]104\\007"_tsv,
523 .description = "Reset color palette via OSC 104"_sv,
524 // TODO: enable once we support OSC 104 to set the palette
525 .enabled = false,
526 },
527 Capability {
528 .long_name = "Original pair"_sv,
529 .short_name = "op"_tsv,
530 .value = "\\E[39;49m"_tsv,
531 .description = "Reset grahics rendition fg/bg via CSI 39;49 m"_sv,
532 },
533 Capability {
534 .long_name = "Restore cursor"_sv,
535 .short_name = "rc"_tsv,
536 .value = "\\E8"_tsv,
537 .description = "Reset cursor via ESC 8 (DECRC)"_sv,
538 },
539 Capability {
540 .long_name = "Repeat character"_sv,
541 .short_name = "rep"_tsv,
542 .value = "%p1%c\\E[%p2%{1}%-%db"_tsv, // Copied from ghostty/kitty
543 .description = "Repeat character via CSI Ps b"_sv,
544 },
545 Capability {
546 .long_name = "Reverse video"_sv,
547 .short_name = "rev"_tsv,
548 .value = "\\E[7m"_tsv,
549 .description = "Invert cell via SGR 7"_sv,
550 },
551 Capability {
552 .long_name = "Reverse index"_sv,
553 .short_name = "ri"_tsv,
554 .value = "\\EM"_tsv,
555 .description = "Reverse index (scroll down) via C1 RI (ESC M)"_sv,
556 },
557 Capability {
558 .long_name = "Scroll down"_sv,
559 .short_name = "rin"_tsv,
560 .value = "\\E[%p1%dT"_tsv,
561 .description = "Scroll down via CSI Ps T"_sv,
562 },
563 Capability {
564 .long_name = "Italic"_sv,
565 .short_name = "ritm"_tsv,
566 .value = "\\E[23m"_tsv,
567 .description = "Italicize cell via SGR 23"_sv,
568 },
569 Capability {
570 .long_name = "End alternate character set"_sv,
571 .short_name = "rmacs"_tsv,
572 .value = "\\E(B"_tsv,
573 .description = "End altnerate character set via ESC ( B"_sv,
574 // TODO: enable once box drawing charset is supported
575 .enabled = false,
576 },
577 Capability {
578 .long_name = "Reset automatic margins"_sv,
579 .short_name = "rmam"_tsv,
580 .value = "\\E[?7l"_tsv,
581 .description = "Disable auto-wrap via CSI ? 7 l"_sv,
582 },
583 Capability {
584 .long_name = "Reset alternate screen"_sv,
585 .short_name = "rmcup"_tsv,
586 .value = "\\E[?1049l"_tsv,
587 .description = "Leave alternate screen mode via CSI ? 1049 l"_sv,
588 },
589 Capability {
590 .long_name = "Exit insert mode"_sv,
591 .short_name = "rmir"_tsv,
592 .value = "\\E[4l"_tsv,
593 .description = "Leave insert mode via CSI 4 l"_sv,
594 // TODO: enable once insert mode is supported
595 .enabled = false,
596 },
597 Capability {
598 .long_name = "Exit keyboard transmit mode"_sv,
599 .short_name = "rmkx"_tsv,
600 .value = "\\E[?1l\\E>"_tsv,
601 // We don't yet support alternate keypad mode, but its safe to put the sequence in.
602 .description = "Reset keyboard modes via CSI ? 1 l (cursor keys) and ESC > (alternate keypad mode)"_sv,
603 },
604 Capability {
605 .long_name = "Exit standout mode"_sv,
606 .short_name = "rmso"_tsv,
607 .value = "\\E[27m"_tsv,
608 .description = "Exit standout mode via SGR 27 (clears inverted graphics rendition)"_sv,
609 },
610 Capability {
611 .long_name = "Exit underline"_sv,
612 .short_name = "rmul"_tsv,
613 .value = "\\E[24m"_tsv,
614 .description = "Exit underline via SGR 24"_sv,
615 },
616 Capability {
617 .long_name = "Reset string"_sv,
618 .short_name = "rs1"_tsv,
619 // We don't yet support ESC c (RIS), but its safe to include.
620 .value = R"(\E]\E\\\Ec)"_tsv, // Copied from ghostty/kitty
621 .description = "Reset via empty OSC sequence followed by ESC c (full reset)"_sv,
622 },
623 Capability {
624 .long_name = "Set cursor"_sv,
625 .short_name = "sc"_tsv,
626 .value = "\\E7"_tsv,
627 .description = "Save the cursor via ESC 7"_sv,
628 },
629 Capability {
630 .long_name = "Set background color"_sv,
631 .short_name = "setab"_tsv,
632 .value = "\\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m"_tsv, // Copied from ghostty/kitty
633 .description = "Set the graphics background via CSI 48"_sv,
634 },
635 Capability {
636 .long_name = "Set foreground color"_sv,
637 .short_name = "setaf"_tsv,
638 .value = "\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"_tsv, // Copied from ghostty/kitty
639 .description = "Set the graphics foregroup via CSI 38"_sv,
640 },
641 Capability {
642 .long_name = "Set graphics rendition"_sv,
643 .short_name = "sgr"_tsv,
644 // TODO: since we don't yet support box drawing characters I removed the first conditional.
645 // .value =
646 // "%?%p9%t\\E(0%e\\E(B%;\\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m"_sv,
647 // Copied from xterm
648 .value = "\\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m"_tsv,
649 .description = "Set the graphics rendition via CSI m, and charset via ESC ( C"_sv,
650
651 },
652 Capability {
653 .long_name = "Reset graphics rendition"_sv,
654 .short_name = "sgr0"_tsv,
656 // TODO: since we don't yet support box drawing characters I removed the first conditional.
657 .value = "\\E[m"_tsv,
658 .description = "Reset the graphics rendition via CSI m and charset via ESC ( B"_sv,
659
660 },
661 Capability {
662 .long_name = "Set italics"_sv,
663 .short_name = "sitm"_tsv,
664 .value = "\\E[3m"_tsv,
665 .description = "Set italics via SGR 3"_sv,
666 },
667 Capability {
668 .long_name = "Enter alternate charset"_sv,
669 .short_name = "smacs"_tsv,
670 .value = "\\E(0"_tsv,
671 .description = "Enter box drawing charset via ESC ( 0"_sv,
672 // TODO: enable once we support box drawing charset
673 .enabled = false,
674 },
675 Capability {
676 .long_name = "Set automatic margins"_sv,
677 .short_name = "smam"_tsv,
678 .value = "\\E[?7h"_tsv,
679 .description = "Enable auto-wrap via CSI ? 7 h"_sv,
680 },
681 Capability {
682 .long_name = "Set alternate screen"_sv,
683 .short_name = "smcup"_tsv,
684 .value = "\\E[?1049h"_tsv,
685 .description = "Enter alternate screen mode via CSI ? 1049 h"_sv,
686 },
687 Capability {
688 .long_name = "Enter insert mode"_sv,
689 .short_name = "smir"_tsv,
690 .value = "\\E[4h"_tsv,
691 .description = "Enter insert mode via CSI 4 h"_sv,
692 // TODO: enable once insert mode is supported
693 .enabled = false,
694 },
695 Capability {
696 .long_name = "Enter keyboard transmit mode"_sv,
697 .short_name = "smkx"_tsv,
698 .value = "\\E[?1h\\E="_tsv,
699 // We don't yet support alternate keypad mode, but its safe to put the sequence in.
700 .description = "Enter keyboard modes via CSI ? 1 h (cursor keys) and ESC = (alternate keypad mode)"_sv,
701 },
702 Capability {
703 .long_name = "Enter standout mode"_sv,
704 .short_name = "smso"_tsv,
705 .value = "\\E[7m"_tsv,
706 .description = "Enter standout mode via SGR 7 (inverted graphics rendition)"_sv,
707 },
708 Capability {
709 .long_name = "Enter underline"_sv,
710 .short_name = "smul"_tsv,
711 .value = "\\E[4m"_tsv,
712 .description = "Enter underline via SGR 4"_sv,
713 },
714 Capability {
715 .long_name = "Clear all tabs"_sv,
716 .short_name = "tbc"_tsv,
717 .value = "\\E[3g"_tsv,
718 .description = "Clear all tabstops via CSI 3 g"_sv,
719 },
720 Capability {
721 .long_name = "Move to status line"_sv,
722 .short_name = "tsl"_tsv,
723 .value = "\\E]2;"_tsv,
724 .description = "Enter status line (window title) via OSC 2"_sv,
725 // TODO: enable after supporting OSC 1/2
726 .enabled = false,
727 },
728 Capability {
729 .long_name = "User string 6"_sv,
730 .short_name = "u6"_tsv,
731 .value = "\\E[%i%d;%dR"_tsv, // Copied from ghostty/kitty
732 .description = "String format of cursor position reports CSI Ps ; Ps R"_sv,
733 },
734 Capability {
735 .long_name = "User string 7"_sv,
736 .short_name = "u7"_tsv,
737 .value = "\\E[6n"_tsv, // Copied from ghostty/kitty
738 .description = "Device status report (cursor position) via CSI 6 n"_sv,
739 },
740 Capability {
741 .long_name = "User string 8"_sv,
742 .short_name = "u8"_tsv,
743 .value = "\\E[?%[;0123456789]c"_tsv, // Copied from ghostty/kitty
744 .description = "String format of primary device attributes response - CSI ? Ps c"_sv,
745 },
746 Capability {
747 .long_name = "User string 9"_sv,
748 .short_name = "u9"_tsv,
749 .value = "\\E[c"_tsv, // Copied from ghostty/kitty
750 .description = "Device primary attributes (DA1) via CSI c"_sv,
751 },
752 Capability {
753 .long_name = "Vertical position absolute"_sv,
754 .short_name = "vpa"_tsv,
755 .value = "\\E[%i%p1%dd"_tsv,
756 .description = "Set cursor vertical position via CSI Ps d"_sv,
757 },
758 Capability {
759 .long_name = "Leave bracketed paste"_sv,
760 .short_name = "BD"_tsv,
761 .value = "\\E[?2004l"_tsv,
762 .description = "Leave bracketed paste via CSI ? 2004 l"_sv,
763 },
764 Capability {
765 .long_name = "Enter bracketed paste"_sv,
766 .short_name = "BE"_tsv,
767 .value = "\\E[?2004h"_tsv,
768 .description = "Enter bracketed paste via CSI ? 2004 h"_sv,
769 },
770 Capability {
771 .long_name = "Reset horizontal margins"_sv,
772 .short_name = "Clmg"_tsv,
773 .value = "\\E[s"_tsv,
774 .description = "Reset horizontal margins via CSI s"_sv,
775 // TODO: enable with support for horizontal margins
776 .enabled = false,
777 },
778 Capability {
779 .long_name = "Set horizontal margins"_sv,
780 .short_name = "Cmg"_tsv,
781 .value = "\\E[%i%p1%d;%p2%ds"_tsv,
782 .description = "Set horizontal margins via CSI Ps ; Ps s"_sv,
783 // TODO: enable with support for horizontal margins
784 .enabled = false,
785 },
786 Capability {
787 .long_name = "Reset cursor color"_sv,
788 .short_name = "Cr"_tsv,
789 .value = "\\E]112\\007"_tsv, // Copied from kitty
790 .description = "Reset cursor palette color via OSC 112"_sv,
791 // TODO: enable after support dynamic palette (OSC 12+112)
792 .enabled = false,
793 },
794 Capability {
795 .long_name = "Set cursor color"_sv,
796 .short_name = "Cs"_tsv,
797 .value = "\\E]12;%p1%s\\007"_tsv, // Copied from kitty
798 .description = "Set cursor palette color via OSC 12"_sv,
799 // TODO: enable after support dynamic palette (OSC 12+112)
800 .enabled = false,
801 },
802 Capability {
803 .long_name = "Disable horizontal margins"_sv,
804 .short_name = "Dsmg"_tsv,
805 .value = "\\E[?69l"_tsv,
806 .description = "Disable horizontal margin mode via CSI ? 69 l"_sv,
807 // TODO: enable with support for horizontal margins
808 .enabled = false,
809 },
810 Capability {
811 .long_name = "Clear with scroll back"_sv,
812 .short_name = "E3"_tsv,
813 .value = "\\E[3J"_tsv,
814 .description = "Clear screen including scroll back via CSI 3 J"_sv,
815 },
816 Capability {
817 .long_name = "Enable horizontal margins"_sv,
818 .short_name = "Enmg"_tsv,
819 .value = "\\E[?69h"_tsv,
820 .description = "Enable horizontal margin mode via CSI ? 69 h"_sv,
821 // TODO: enable with support for horizontal margins
822 .enabled = false,
823 },
824 Capability {
825 .long_name = "Save clipboard"_sv,
826 .short_name = "Ms"_tsv,
827 .value = "\\E]52;%p1%s;%p2%s\\007"_tsv, // Copied from ghostty/kitty
828 .description = "Set clipboard via OSC 52"_sv,
829 },
830 Capability {
831 .long_name = "Bracketed paste end"_sv,
832 .short_name = "PE"_tsv,
833 .value = "\\E[201~"_tsv,
834 .description = "Terminal uses CSI 201 ~ to end a bracketed paste"_sv,
835 },
836 Capability {
837 .long_name = "Bracketed paste start"_sv,
838 .short_name = "PS"_tsv,
839 .value = "\\E[200~"_tsv,
840 .description = "Terminal uses CSI 200 ~ to start a bracketed paste"_sv,
841 },
842 Capability {
843 .long_name = "Report version"_sv,
844 .short_name = "RV"_tsv,
845 .value = "\\E[>c"_tsv,
846 .description = "Request secondary device attributes via CSI > c"_sv,
847 },
848 Capability {
849 .long_name = "Reset cursor style"_sv,
850 .short_name = "Se"_tsv,
851 .value = "\\E[2 q"_tsv,
852 .description = "Reset cursor style via CSI 2 SP q (steady block cursor)"_sv,
853 },
854 Capability {
855 .long_name = "Set underline color"_sv,
856 .short_name = "Setulc"_tsv,
857 .value = "\\E[58:2:%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d%;m"_tsv, // Copied from ghostty/kitty
858 .description = "Set underline color via SGR 58"_sv,
859 },
860 Capability {
861 .long_name = "Set extended underline"_sv,
862 .short_name = "Smulx"_tsv,
863 .value = "\\E[4:%p1%dm"_tsv, // Copied from ghostty/kitty
864 .description = "Set extended unline mode via SGR 4:Ps"_sv,
865 },
866 Capability {
867 .long_name = "Set cursor style"_sv,
868 .short_name = "Ss"_tsv,
869 .value = "\\E[%p1%d q"_tsv,
870 .description = "Set cursor style via CSI Ps SP q"_sv,
871 },
872 Capability {
873 .long_name = "Synchronized output"_sv,
874 .short_name = "Sync"_tsv,
875 .value = "\\E[?2026%?%p1%{1}%-%tl%eh%;"_tsv, // Copied from ghostty (kitty uses a DCS sequence)
876 .description = "Toggle synchronized output via CSI ? 2026 h/l"_sv,
877 },
878 Capability {
879 .long_name = "Extended mouse"_sv,
880 .short_name = "XM"_tsv,
881 .value = "\\E[?1006;1000%?%p1%{1}%=%th%el%;"_tsv, // Copied from ghostty
882 .description = "Toggle SGR mouse mode via CSI ? 1006 ; 1000 h/l"_sv,
883 },
884 Capability {
885 .long_name = "Extended version"_sv,
886 .short_name = "XR"_tsv,
887 .value = "\\E[>0q"_tsv, // Copied from ghostty
888 .description = "Request XTVERSION via CSI > 0 q"_sv,
889 // TODO: enable after supporting XTVERSION
890 .enabled = false,
891 },
892 Capability {
893 .long_name = "Reset focus reports"_sv,
894 .short_name = "fd"_tsv,
895 .value = "\\E[?1004l"_tsv,
896 .description = "Reset focus reports via CSI ? 1004 l"_sv,
897 },
898 Capability {
899 .long_name = "Set focus reports"_sv,
900 .short_name = "fe"_tsv,
901 .value = "\\E[?1004h"_tsv,
902 .description = "Set focus reports via CSI ? 1004 h"_sv,
903 },
904
905#define KEYS2(M) \
906 M("kBEG3", "\\E[1;3E", "Alt+Begin") \
907 M("kBEG4", "\\E[1;4E", "Alt+Shift+Begin") \
908 M("kBEG5", "\\E[1;5E", "Control+Begin") \
909 M("kBEG6", "\\E[1;6E", "Control+Shift+Begin") \
910 M("kBEG7", "\\E[1;7E", "Control+Alt+Begin") \
911 M("kDC3", "\\E[3;3~", "Alt+Delete") \
912 M("kDC4", "\\E[3;4~", "Alt+Shift+Delete") \
913 M("kDC5", "\\E[3;5~", "Control+Delete") \
914 M("kDC6", "\\E[3;6~", "Control+Shift+Delete") \
915 M("kDC7", "\\E[3;7~", "Control+Alt+Delete") \
916 M("kDN", "\\E[1;2B", "Shift+Down") \
917 M("kDN3", "\\E[1;3B", "Alt+Down") \
918 M("kDN4", "\\E[1;4B", "Alt+Shift+Down") \
919 M("kDN5", "\\E[1;5B", "Control+Down") \
920 M("kDN6", "\\E[1;6B", "Control+Shift+Down") \
921 M("kDN7", "\\E[1;7B", "Control+Alt+Down") \
922 M("kEND3", "\\E[1;3F", "Alt+End") \
923 M("kEND4", "\\E[1;4F", "Alt+Shift+End") \
924 M("kEND5", "\\E[1;5F", "Control+End") \
925 M("kEND6", "\\E[1;6F", "Control+Shift+End") \
926 M("kEND7", "\\E[1;7F", "Control+Alt+End") \
927 M("kHOM3", "\\E[1;3H", "Alt+Home") \
928 M("kHOM4", "\\E[1;4H", "Alt+Shift+Home") \
929 M("kHOM5", "\\E[1;5H", "Control+Home") \
930 M("kHOM6", "\\E[1;6H", "Control+Shift+Home") \
931 M("kHOM7", "\\E[1;7H", "Control+Alt+Home") \
932 M("kIC3", "\\E[2;3~", "Alt+Insert") \
933 M("kIC4", "\\E[2;4~", "Alt+Shift+Insert") \
934 M("kIC5", "\\E[2;5~", "Control+Insert") \
935 M("kIC6", "\\E[2;6~", "Control+Shift+Insert") \
936 M("kIC7", "\\E[2;7~", "Control+Alt+Insert") \
937 M("kLFT3", "\\E[1;3D", "Alt+Left") \
938 M("kLFT4", "\\E[1;4D", "Alt+Shift+Left") \
939 M("kLFT5", "\\E[1;5D", "Control+Left") \
940 M("kLFT6", "\\E[1;6D", "Control+Shift+Left") \
941 M("kLFT7", "\\E[1;7D", "Control+Alt+Left") \
942 M("kNXT3", "\\E[6;3~", "Alt+PageDown") \
943 M("kNXT4", "\\E[6;4~", "Alt+Shift+PageDown") \
944 M("kNXT5", "\\E[6;5~", "Control+PageDown") \
945 M("kNXT6", "\\E[6;6~", "Control+Shift+PageDown") \
946 M("kNXT7", "\\E[6;7~", "Control+Alt+PageDown") \
947 M("kPRV3", "\\E[5;3~", "Alt+PageUp") \
948 M("kPRV4", "\\E[5;4~", "Alt+Shift+PageUp") \
949 M("kPRV5", "\\E[5;5~", "Control+PageUp") \
950 M("kPRV6", "\\E[5;6~", "Control+Shift+PageUp") \
951 M("kPRV7", "\\E[5;7~", "Control+Alt+PageUp") \
952 M("kRIT3", "\\E[1;3C", "Alt+Right") \
953 M("kRIT4", "\\E[1;4C", "Alt+Shift+Right") \
954 M("kRIT5", "\\E[1;5C", "Control+Right") \
955 M("kRIT6", "\\E[1;6C", "Control+Shift+Right") \
956 M("kRIT7", "\\E[1;7C", "Control+Alt+Right") \
957 M("kUP", "\\E[1;2A", "Shift+Up") \
958 M("kUP3", "\\E[1;3A", "Alt+Up") \
959 M("kUP4", "\\E[1;4A", "Alt+Shift+Up") \
960 M("kUP5", "\\E[1;5A", "Control+Up") \
961 M("kUP6", "\\E[1;6A", "Control+Shift+Up") \
962 M("kUP7", "\\E[1;7A", "Control+Alt+Up")
963
965 //
966
967 Capability {
968 .long_name = "Focus in"_sv,
969 .short_name = "kxIN"_tsv,
970 .value = "\\E[I"_tsv,
971 .description = "Report send by terminal when gaining focus - CSI I"_sv,
972 },
973 Capability {
974 .long_name = "Focus out"_sv,
975 .short_name = "kxOUT"_tsv,
976 .value = "\\E[O"_tsv,
977 .description = "Report send by terminal when losing focus - CSI o"_sv,
978 },
979 Capability {
980 .long_name = "Reset strikethrough"_sv,
981 .short_name = "rmxx"_tsv,
982 .value = "\\E[29m"_tsv,
983 .description = "Reset strikethrough cell via SGR 29"_sv,
984 },
985 Capability {
986 .long_name = "Report version response"_sv,
987 .short_name = "rv"_tsv,
988 // NOTE: this value looks wrong, as the response should include a '<' after the CSI. However,
989 // both ghostty and xterm leave it off. Probably no one uses this string.
990 .value = R"(\E\\[[0-9]+;[0-9]+;[0-9]+c)"_tsv, // Copied from ghostty
991 .description = "String format of device secondary attirbutes response - CSI < Ps ; Ps ; Ps c"_sv,
992 },
993 Capability {
994 .long_name = "Set RGB background"_sv,
995 .short_name = "setrgbb"_tsv,
996 .value = "\\E[48:2:%p1%d:%p2%d:%p3%dm"_tsv, // Copied from ghostty/kitty
997 .description = "Set RGB background via SGR 48"_sv,
998 },
999 Capability {
1000 .long_name = "Set RGB foreground"_sv,
1001 .short_name = "setrgbf"_tsv,
1002 .value = "\\E[38:2:%p1%d:%p2%d:%p3%dm"_tsv, // Copied from ghostty/kitty
1003 .description = "Set RGB foreground via SGR 38"_sv,
1004 },
1005 Capability {
1006 .long_name = "Strikethrough"_sv,
1007 .short_name = "smxx"_tsv,
1008 .value = "\\E[9m"_tsv,
1009 .description = "Set strikethrough cell via SGR 9"_sv,
1010 },
1011 Capability {
1012 .long_name = "Extended mouse report"_sv,
1013 .short_name = "xm"_tsv,
1014 .value = "\\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;"_tsv, // Copied from ghostty
1015 .description = "Format of extended mouse reports - CSI Ps ; Ps ; Ps M/m"_sv,
1016 },
1017 Capability {
1018 .long_name = "Extended version report"_sv,
1019 .short_name = "xr"_tsv,
1020 .value = R"(\EP>\|[ -~]+a\E\\)"_tsv, // Copied from ghostty
1021 .description = "Format of XTVERSION response - DCS > version ST"_sv,
1022 // TODO: enable after supporting XTVERSION
1023 .enabled = false,
1024 },
1025};
1026
1027constexpr auto ttx_terminfo = Terminfo {
1028 .names = ttx_names,
1029 .capabilities = ttx_capabilities,
1030};
1031}
#define KEY_CAP(short, v, name)
#define KEYS(M)
#define KEYS2(M)
Definition capability.h:8
constexpr auto ttx_names
Definition capabilities.h:6
constexpr auto ttx_terminfo
Definition capabilities.h:1027
constexpr auto ttx_capabilities
Definition capabilities.h:20
Represents a Termcap capability.
Definition capability.h:10
Represents a terminfo entry.
Definition capability.h:30