a modern tui library written in zig
1// Queries
2pub const primary_device_attrs = "\x1b[c";
3pub const tertiary_device_attrs = "\x1b[=c";
4pub const device_status_report = "\x1b[5n";
5pub const xtversion = "\x1b[>0q";
6pub const decrqm_focus = "\x1b[?1004$p";
7pub const decrqm_sgr_pixels = "\x1b[?1016$p";
8pub const decrqm_sync = "\x1b[?2026$p";
9pub const decrqm_unicode = "\x1b[?2027$p";
10pub const decrqm_color_scheme = "\x1b[?2031$p";
11pub const csi_u_query = "\x1b[?u";
12pub const kitty_graphics_query = "\x1b_Gi=1,a=q\x1b\\";
13pub const sixel_geometry_query = "\x1b[?2;1;0S";
14pub const cursor_position_request = "\x1b[6n";
15pub const explicit_width_query = "\x1b]66;w=1; \x1b\\";
16pub const scaled_text_query = "\x1b]66;s=2; \x1b\\";
17pub const multi_cursor_query = "\x1b[> q";
18
19// mouse. We try for button motion and any motion. terminals will enable the
20// last one we tried (any motion). This was added because zellij doesn't
21// support any motion currently
22// See: https://github.com/zellij-org/zellij/issues/1679
23pub const mouse_set = "\x1b[?1002;1003;1004;1006h";
24pub const mouse_set_pixels = "\x1b[?1002;1003;1004;1016h";
25pub const mouse_reset = "\x1b[?1002;1003;1004;1006;1016l";
26
27// in-band window size reports
28pub const in_band_resize_set = "\x1b[?2048h";
29pub const in_band_resize_reset = "\x1b[?2048l";
30
31// sync
32pub const sync_set = "\x1b[?2026h";
33pub const sync_reset = "\x1b[?2026l";
34
35// unicode
36pub const unicode_set = "\x1b[?2027h";
37pub const unicode_reset = "\x1b[?2027l";
38pub const explicit_width = "\x1b]66;w={d};{s}\x1b\\";
39
40// text sizing
41pub const scaled_text = "\x1b]66;s={d}:w={d};{s}\x1b\\";
42pub const scaled_text_with_fractions = "\x1b]66;s={d}:w={d}:n={d}:d={d}:v={d};{s}\x1b\\";
43
44// bracketed paste
45pub const bp_set = "\x1b[?2004h";
46pub const bp_reset = "\x1b[?2004l";
47
48// color scheme updates
49pub const color_scheme_request = "\x1b[?996n";
50pub const color_scheme_set = "\x1b[?2031h";
51pub const color_scheme_reset = "\x1b[?2031l";
52
53// Key encoding
54pub const csi_u_push = "\x1b[>{d}u";
55pub const csi_u_pop = "\x1b[<u";
56
57// Cursor
58pub const home = "\x1b[H";
59pub const cup = "\x1b[{d};{d}H";
60pub const hide_cursor = "\x1b[?25l";
61pub const show_cursor = "\x1b[?25h";
62pub const cursor_shape = "\x1b[{d} q";
63pub const ri = "\x1bM";
64pub const ind = "\n";
65pub const cuf = "\x1b[{d}C";
66pub const cub = "\x1b[{d}D";
67
68// Erase
69pub const erase_below_cursor = "\x1b[J";
70
71// alt screen
72pub const smcup = "\x1b[?1049h";
73pub const rmcup = "\x1b[?1049l";
74
75// sgr reset all
76pub const sgr_reset = "\x1b[m";
77
78// colors
79pub const fg_base = "\x1b[3{d}m";
80pub const fg_bright = "\x1b[9{d}m";
81pub const bg_base = "\x1b[4{d}m";
82pub const bg_bright = "\x1b[10{d}m";
83
84pub const fg_reset = "\x1b[39m";
85pub const bg_reset = "\x1b[49m";
86pub const ul_reset = "\x1b[59m";
87pub const fg_indexed = "\x1b[38:5:{d}m";
88pub const bg_indexed = "\x1b[48:5:{d}m";
89pub const ul_indexed = "\x1b[58:5:{d}m";
90pub const fg_rgb = "\x1b[38:2:{d}:{d}:{d}m";
91pub const bg_rgb = "\x1b[48:2:{d}:{d}:{d}m";
92pub const ul_rgb = "\x1b[58:2:{d}:{d}:{d}m";
93pub const fg_indexed_legacy = "\x1b[38;5;{d}m";
94pub const bg_indexed_legacy = "\x1b[48;5;{d}m";
95pub const ul_indexed_legacy = "\x1b[58;5;{d}m";
96pub const fg_rgb_legacy = "\x1b[38;2;{d};{d};{d}m";
97pub const bg_rgb_legacy = "\x1b[48;2;{d};{d};{d}m";
98pub const ul_rgb_legacy = "\x1b[58;2;{d};{d};{d}m";
99pub const ul_rgb_conpty = "\x1b[58:2::{d}:{d}:{d}m";
100
101// Underlines
102pub const ul_off = "\x1b[24m"; // NOTE: this could be \x1b[4:0m but is not as widely supported
103pub const ul_single = "\x1b[4m";
104pub const ul_double = "\x1b[4:2m";
105pub const ul_curly = "\x1b[4:3m";
106pub const ul_dotted = "\x1b[4:4m";
107pub const ul_dashed = "\x1b[4:5m";
108
109// Attributes
110pub const bold_set = "\x1b[1m";
111pub const dim_set = "\x1b[2m";
112pub const italic_set = "\x1b[3m";
113pub const blink_set = "\x1b[5m";
114pub const reverse_set = "\x1b[7m";
115pub const invisible_set = "\x1b[8m";
116pub const strikethrough_set = "\x1b[9m";
117pub const bold_dim_reset = "\x1b[22m";
118pub const italic_reset = "\x1b[23m";
119pub const blink_reset = "\x1b[25m";
120pub const reverse_reset = "\x1b[27m";
121pub const invisible_reset = "\x1b[28m";
122pub const strikethrough_reset = "\x1b[29m";
123
124// OSC sequences
125pub const osc2_set_title = "\x1b]2;{s}\x1b\\";
126pub const osc7 = "\x1b]7;{f}\x1b\\";
127pub const osc8 = "\x1b]8;{s};{s}\x1b\\";
128pub const osc8_clear = "\x1b]8;;\x1b\\";
129pub const osc9_notify = "\x1b]9;{s}\x1b\\";
130pub const osc777_notify = "\x1b]777;notify;{s};{s}\x1b\\";
131pub const osc22_mouse_shape = "\x1b]22;{s}\x1b\\";
132pub const osc52_clipboard_copy = "\x1b]52;c;{s}\x1b\\";
133pub const osc52_clipboard_request = "\x1b]52;c;?\x1b\\";
134
135// Kitty graphics
136pub const kitty_graphics_clear = "\x1b_Ga=d\x1b\\";
137pub const kitty_graphics_preamble = "\x1b_Ga=p,i={d}";
138pub const kitty_graphics_closing = ",C=1\x1b\\";
139
140// Color control sequences
141pub const osc4_query = "\x1b]4;{d};?\x1b\\"; // color index {d}
142pub const osc4_reset = "\x1b]104\x1b\\"; // this resets _all_ color indexes
143pub const osc10_query = "\x1b]10;?\x1b\\"; // fg
144pub const osc10_set = "\x1b]10;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set default terminal fg
145pub const osc10_reset = "\x1b]110\x1b\\"; // reset fg to terminal default
146pub const osc11_query = "\x1b]11;?\x1b\\"; // bg
147pub const osc11_set = "\x1b]11;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set default terminal bg
148pub const osc11_reset = "\x1b]111\x1b\\"; // reset bg to terminal default
149pub const osc12_query = "\x1b]12;?\x1b\\"; // cursor color
150pub const osc12_set = "\x1b]12;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set terminal cursor color
151pub const osc12_reset = "\x1b]112\x1b\\"; // reset cursor to terminal default