1 /*
2  * For compatibility / long-time legacy reasons, the keysym field of a
3  * TRANSLATED input event in shmif corresponds to the SDL1.2 list of keysyms.
4  *
5  * Avoid using these directly/exclusively and instead use the more abstract
6  * label facility for registering custom inputs, though the inputs themselves
7  * may refer to symbol + modifier as part of the default binding.
8  *
9  * For actual input, the utf8 field should provide a unicode codepoint
10  * corresponding to the current desired symbol.
11  */
12 #ifndef TUIK_SYMS
13 #define TUIK_SYMS
14 
15 /*
16  * The rest are just renamed / remapped arcan_tui_ calls from libtsm-
17  * (which hides inside the tui_context) selected based on what the tsm/pty
18  * management required assuming that it is good enough.
19  */
20 enum tui_context_flags {
21 	TUI_INSERT_MODE = 1,
22 	TUI_AUTO_WRAP = 2,
23 /*
24  * Relative origin, row/col are set to take margin values into account
25  */
26 	TUI_REL_ORIGIN = 4,
27 
28 /* Inverse the colors of the entire screen */
29 	TUI_INVERSE = 8,
30 
31 /* Disable drawing the cursor */
32 	TUI_HIDE_CURSOR = 16,
33 
34 	TUI_FIXED_POS = 32,
35 
36 /* Alternate screen does not have scrolling or scrollback behavior */
37 	TUI_ALTERNATE = 64,
38 
39 /* Prefer local mouse handler than default mouse to clipboard */
40 	TUI_MOUSE = 128,
41 
42 /* Same as TUI_MOUSE, but don't permit ctrl modifier to toggle */
43 	TUI_MOUSE_FULL = 256,
44 };
45 
46 #define TUI_HAS_ATTR(X, Y) (!!((X).aflags & (Y)))
47 
48 enum tui_attr_flags {
49 	TUI_ATTR_BOLD = 1,
50 	TUI_ATTR_UNDERLINE = 2,
51 	TUI_ATTR_UNDERLINE_ALT = 4,
52 	TUI_ATTR_ITALIC = 8,
53 	TUI_ATTR_INVERSE = 16,
54 	TUI_ATTR_PROTECT = 32,
55 	TUI_ATTR_BLINK = 64,
56 	TUI_ATTR_STRIKETHROUGH = 128,
57 	TUI_ATTR_SHAPE_BREAK = 256,
58 	TUI_ATTR_COLOR_INDEXED = 512,
59 	TUI_ATTR_BORDER_RIGHT = 1024,
60 	TUI_ATTR_BORDER_DOWN = 2048,
61 	TUI_ATTR_GLYPH_INDEXED = 4096
62 };
63 
64 /*
65  * positioning / drawing hints, BITMASK.
66  */
67 enum tui_wndhint_flags {
68 	TUI_WND_NORMAL = 0,
69 
70 /* BITMASK: window should be in focus for the rest of the group */
71 	TUI_WND_FOCUS = 1,
72 
73 /* window is not expected to be visible at all (minimize to tray, ...) */
74 	TUI_WND_HIDDEN = 2,
75 };
76 
77 enum tui_message_slots {
78 	TUI_MESSAGE_PROMPT = 0,
79 	TUI_MESSAGE_ALERT = 1,
80 	TUI_MESSAGE_NOTIFICATION = 2,
81 	TUI_MESSAGE_FAILURE = 3
82 };
83 
84 enum tui_progress_type {
85  TUI_PROGRESS_INTERNAL = 0,
86  TUI_PROGRESS_BCHUNK_IN,
87  TUI_PROGRESS_BCHUNK_OUT,
88  TUI_PROGRESS_STATE_IN,
89  TUI_PROGRESS_STATE_OUT
90 };
91 
92 /*
93  * used by the cli_command event handler
94  */
95 enum tui_cli {
96 	TUI_CLI_BEGIN = 0,
97 	TUI_CLI_EVAL = 1,
98 	TUI_CLI_COMMIT = 2,
99 	TUI_CLI_CANCEL = 3,
100 
101 /* replies */
102 	TUI_CLI_SUGGEST = 4,
103 	TUI_CLI_ACCEPT = 5,
104 	TUI_CLI_INVALID = 6,
105 	TUI_CLI_REPLACE = 7
106 };
107 
108 enum tui_handover_flags {
109 	TUI_DETACH_PROCESS = 1,
110 	TUI_DETACH_STDIN   = 2,
111 	TUI_DETACH_STDOUT  = 4,
112 	TUI_DETACH_STDERR  = 8
113 };
114 
115 /*
116  * These are only relevant when requesting a subwindow or when receiving one,
117  * the values of the different types are picked as to match the corresponding
118  * types in arcan_shmif.
119  */
120 enum tui_subwnd_type {
121 /* normal TUI window, because like a normal connection, except the lifespan
122  * is tied to that of it's allocation-parent */
123 	TUI_WND_TUI = 23,
124 
125 /* popup window, short lifespan, can be killed of parent-side as a 'cancel'
126  * operation and no- state or ability should be lost as an effect of doing so */
127 	TUI_WND_POPUP = 16,
128 
129 /* explicitly pushed by parents, when enabled, output a simplified, screen-
130  * reader friendly version of the active contents to render / consider */
131 	TUI_WND_ACCESSIBILITY = 19,
132 
133 /* explicitly pushed by parents, when enabled, output application-relevant
134  * debugging data */
135 	TUI_WND_DEBUG = 255,
136 
137 /*
138  * Special case, a connection primitive that can be forwarded to some other
139  * primitive, but with connection origin traced/bound to a preexisting tui
140  * connection. This is used internally for advanced features.
141  */
142 	TUI_WND_HANDOVER = 26
143 };
144 
145 /*
146  * For making lookups against the currently known color table, these are not
147  * strictly forced (outside cursor, bg, fg, ...) but rather intended as hints
148  * so that the client can match colors accordingly, or just work with the
149  * abstract groups.
150  *
151  * Flags:
152  * [R] : reference color, use for chosing custom colors, implied [D].
153  * [D] : foreground/background entry treated the same
154  * [B] : set_color and set_bgcolor will work on different values
155  *
156  * Even if the bgcolor isn't explicitly set (either by caller or via the
157  * display server), the elements that return a bgcolor will pick from the
158  * COL_BG group.
159  */
160 enum tui_color_group {
161 /* 0 / 1 are reserved slots,
162  *
163  * [hack] background color for slot 1 can be used to check if the built-in
164  *        default colorset is active or we have received a user override.
165  */
166 /* Primary and secondary colors are hints to a caller that have preset colors
167  * to chose from and want guidance on which ones to pick. */
168 	TUI_COL_PRIMARY = 2, /* [R] Reference base color */
169 	TUI_COL_SECONDARY,   /* [R] Reference alternate base color */
170 	TUI_COL_BG,          /* [R] Reference background */
171 	TUI_COL_TEXT,        /* [B] Default text */
172 	TUI_COL_CURSOR,      /* [D] Cursor in normal state */
173 	TUI_COL_ALTCURSOR,   /* [D] Cursor in special state (scrollback) */
174 	TUI_COL_HIGHLIGHT,   /* [B] Copy / Paste selection */
175 	TUI_COL_LABEL,       /* [B] Meta- text such as prompts */
176 	TUI_COL_WARNING,     /* [B] Warnings, things to notice but not act on */
177 	TUI_COL_ERROR,       /* [B] Indicate a problem that should be acted upon */
178 	TUI_COL_ALERT,       /* [B] Grab attention */
179 	TUI_COL_REFERENCE,   /* [B] External reference / link (e.g. url) */
180 	TUI_COL_INACTIVE,    /* [B] Possible highlight/label but not in use due to
181 													    some state dependent reason */
182 	TUI_COL_UI,          /* [B] internal UI elements / bars / ... */
183 /*
184  * The range in between is used to allow mapping the legacy terminal color
185  * slots for terminal emulator class clients.
186  */
187 	TUI_COL_TBASE,
188 	TUI_COL_LIMIT = 36
189 };
190 
191 enum tui_cursors {
192 	CURSOR_BLOCK = 0,
193 	CURSOR_HALFBLOCK,
194 	CURSOR_FRAME,
195 	CURSOR_VLINE,
196 	CURSOR_ULINE,
197 	CURSOR_END
198 };
199 
200 /* bitmap derived from shmif_event, repeated here for namespace purity */
201 enum tuim_syms {
202 	TUIM_NONE   = 0x0000,
203 	TUIM_LSHIFT = 0x0001,
204 	TUIM_RSHIFT = 0x0002,
205 	TUIM_SHIFT  = 0x0003,
206 	TUIM_LCTRL  = 0x0040,
207 	TUIM_RCTRL  = 0x0080,
208 	TUIM_CTRL   = 0x00c0,
209 	TUIM_LALT   = 0x0100,
210 	TUIM_RALT   = 0x0200,
211 	TUIM_ALT    = 0x0300,
212 	TUIM_LMETA  = 0x0400,
213 	TUIM_RMETA  = 0x0800,
214 	TUIM_META   = 0x0c00,
215 	TUIM_REPEAT = 0x8000,
216 };
217 
218 enum tuibtn_syms {
219 	TUIBTN_LEFT = 1,
220 	TUIBTN_RIGHT = 2,
221 	TUIBTN_MIDDLE = 3,
222 	TUIBTN_WHEEL_UP = 4,
223 	TUIBTN_WHEEL_DOWN = 5
224 };
225 
226 /*
227  * Derived from the symtable used by SDL1.2, these should ideally rarely
228  * be used and instead favor the label facility for announcing supported
229  * abstract inputs.
230  */
231 enum tuik_syms {
232 	TUIK_UNKNOWN = 0,
233 	TUIK_FIRST = 0,
234 	TUIK_BACKSPACE = 8,
235 	TUIK_TAB = 9,
236 	TUIK_CLEAR = 12,
237 	TUIK_RETURN = 13,
238 	TUIK_PAUSE = 19,
239 	TUIK_ESCAPE = 27,
240 	TUIK_SPACE = 32,
241 	TUIK_EXCLAIM = 33,
242 	TUIK_QUOTEDBL = 34,
243 	TUIK_HASH = 35,
244 	TUIK_DOLLAR = 36,
245 	TUIK_0 = 48,
246 	TUIK_1 = 49,
247 	TUIK_2 = 50,
248 	TUIK_3 = 51,
249 	TUIK_4 = 52,
250 	TUIK_5 = 53,
251 	TUIK_6 = 54,
252 	TUIK_7 = 55,
253 	TUIK_8 = 56,
254 	TUIK_9 = 57,
255 	TUIK_MINUS = 20,
256 	TUIK_EQUALS = 21,
257 	TUIK_A = 97,
258   TUIK_B = 98,
259 	TUIK_C = 99,
260 	TUIK_D = 100,
261 	TUIK_E = 101,
262 	TUIK_F = 102,
263 	TUIK_G = 103,
264 	TUIK_H = 104,
265 	TUIK_I = 105,
266 	TUIK_J = 106,
267 	TUIK_K = 107,
268 	TUIK_L = 108,
269 	TUIK_M = 109,
270 	TUIK_N = 110,
271 	TUIK_O = 111,
272 	TUIK_P = 112,
273 	TUIK_Q = 113,
274 	TUIK_R = 114,
275 	TUIK_S = 115,
276 	TUIK_T = 116,
277 	TUIK_U = 117,
278 	TUIK_V = 118,
279 	TUIK_W = 119,
280 	TUIK_X = 120,
281 	TUIK_Y = 121,
282 	TUIK_Z = 122,
283 	TUIK_LESS = 60, /* 102nd key, right of lshift */
284 	TUIK_KP_LEFTBRACE = 91,
285 	TUIK_KP_RIGHTBRACE = 93,
286 	TUIK_KP_ENTER = 271,
287 	TUIK_LCTRL = 306,
288 	TUIK_SEMICOLON = 59,
289 	TUIK_APOSTROPHE = 48,
290 	TUIK_GRAVE = 49,
291 	TUIK_LSHIFT = 304,
292 	TUIK_BACKSLASH = 92,
293 	TUIK_COMMA = 44,
294 	TUIK_PERIOD = 46,
295 	TUIK_SLASH = 61,
296 	TUIK_RSHIFT = 303,
297 	TUIK_KP_MULTIPLY = 268,
298 	TUIK_LALT = 308,
299 	TUIK_CAPSLOCK = 301,
300 	TUIK_F1 = 282,
301 	TUIK_F2 = 283,
302 	TUIK_F3 = 284,
303 	TUIK_F4 = 285,
304 	TUIK_F5 = 286,
305 	TUIK_F6 = 287,
306 	TUIK_F7 = 288,
307 	TUIK_F8 = 289,
308 	TUIK_F9 = 290,
309 	TUIK_F10 = 291,
310 	TUIK_NUMLOCKCLEAR = 300,
311 	TUIK_SCROLLLOCK = 302,
312 	TUIK_KP_0 = 256,
313 	TUIK_KP_1 = 257,
314 	TUIK_KP_2 = 258,
315 	TUIK_KP_3 = 259,
316 	TUIK_KP_4 = 260,
317 	TUIK_KP_5 = 261,
318 	TUIK_KP_6 = 262,
319 	TUIK_KP_7 = 263,
320 	TUIK_KP_8 = 264,
321 	TUIK_KP_9 = 265,
322 	TUIK_KP_MINUS = 269,
323 	TUIK_KP_PLUS = 270,
324 	TUIK_KP_PERIOD = 266,
325 	TUIK_INTERNATIONAL1,
326 	TUIK_INTERNATIONAL2,
327 	TUIK_F11 = 292,
328 	TUIK_F12 = 293,
329 	TUIK_INTERNATIONAL3,
330 	TUIK_INTERNATIONAL4,
331 	TUIK_INTERNATIONAL5,
332 	TUIK_INTERNATIONAL6,
333 	TUIK_INTERNATIONAL7,
334 	TUIK_INTERNATIONAL8,
335 	TUIK_INTERNATIONAL9,
336 	TUIK_RCTRL = 305,
337 	TUIK_KP_DIVIDE = 267,
338 	TUIK_SYSREQ = 317,
339 	TUIK_RALT = 307,
340 	TUIK_HOME = 278,
341 	TUIK_UP = 273,
342 	TUIK_PAGEUP = 280,
343 	TUIK_LEFT = 276,
344 	TUIK_RIGHT = 275,
345 	TUIK_END = 279,
346 	TUIK_DOWN = 274,
347 	TUIK_PAGEDOWN = 281,
348 	TUIK_INSERT = 277,
349 	TUIK_DELETE = 127,
350 	TUIK_LMETA = 310,
351 	TUIK_RMETA = 309,
352 	TUIK_COMPOSE = 314,
353 	TUIK_MUTE,
354 	TUIK_VOLUMEDOWN,
355 	TUIK_VOLUMEUP,
356 	TUIK_POWER,
357 	TUIK_KP_EQUALS,
358 	TUIK_KP_PLUSMINUS,
359 	TUIK_LANG1,
360 	TUIK_LANG2,
361 	TUIK_LANG3,
362 	TUIK_LGUI,
363 	TUIK_RGUI,
364 	TUIK_STOP,
365 	TUIK_AGAIN
366 };
367 
368 #endif
369