lib/Term/Fabulous/Termbox.xs

filter: Statementstmt 86.5% 282 / 326 Branchbran 46.9% 31 / 66 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 79.8% 313 / 392 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/termbox2.c ↑ Summary blib/lib/Term/Fabulous/Enum/WebColor.pm »
1 /*
2 * Termbox.xs - the XS surface of Term::Fabulous::Termbox.
3 *
4 * A thin layer over termbox2 (compiled in src/termbox2.c): every function
5 * keeps its C name and status code. Characters cross the boundary as Perl
6 * strings, which this file decodes into codepoints; events come back as a
7 * list the Perl side copies into a Term::Fabulous::Termbox::Event.
8 */
9 #define PERL_NO_GET_CONTEXT
10 #include "EXTERN.h"
11 #include "perl.h"
12 #include "XSUB.h"
13  
14 #include "tf_termbox.h"
15  
16 /*
17 * The UTF-8 bytes of a string, or a croak when the string carries the UTF8
18 * flag over bytes that are not well-formed UTF-8 (Encode::_utf8_on, a
19 * ":utf8" read layer). Decoding such bytes would let the codepoint count and
20 * the bytes consumed disagree.
21 */
22 66 static const U8 *well_formed_utf8(pTHX_ SV *text, const char *function, STRLEN *length) {
23 66 const U8 *bytes = (const U8 *)SvPVutf8(text, *length);
24  
25 66 ▶ if (!is_utf8_string(bytes, *length)) croak("Term::Fabulous::Termbox: %s needs well-formed UTF-8", function);
Branch: 1 branch
BranchTrueFalseTotal
if (!is_utf8_string(bytes, *length)) croak("Term::Fabulous::Termbox: %s needs well-formed UTF-8", function); 4 62 66
26 62 return bytes;
27 }
28  
29 /*
30 * True when the decoder consumed no bytes: 0, or (STRLEN)-1 for a
31 * malformation with utf8 warnings enabled. A decode loop that went on would
32 * stall or walk backwards.
33 */
34 69 static bool decoder_stalled(STRLEN consumed) {
35 69 ▶ return consumed == 0 || consumed == (STRLEN)-1;
Branch: 2 branches
BranchTrueFalseTotal
return consumed == 0 || consumed == (STRLEN)-1; 69 0 69
return consumed == 0 || consumed == (STRLEN)-1; 0 69 69
36 }
37  
38 /*
39 * The first codepoint of a one-character string. An integer that was
40 * never a string is taken as the codepoint itself, so the C form of the
41 * call stays reachable.
42 */
43 5 static uint32_t first_codepoint(pTHX_ SV *glyph, const char *function) {
44 STRLEN length;
45 STRLEN consumed;
46 const U8 *bytes;
47 uint32_t codepoint;
48  
49 5 ▶ if (SvIOK(glyph) && !SvPOK(glyph)) return (uint32_t)SvUV(glyph);
Branch: 2 branches
BranchTrueFalseTotal
if (SvIOK(glyph) && !SvPOK(glyph)) return (uint32_t)SvUV(glyph); 1 4 5
if (SvIOK(glyph) && !SvPOK(glyph)) return (uint32_t)SvUV(glyph); 1 0 1
50  
51 4 bytes = well_formed_utf8(aTHX_ glyph, function, &length);
52 2 ▶ if (length == 0) croak("Term::Fabulous::Termbox: %s needs a non-empty character", function);
Branch: 1 branch
BranchTrueFalseTotal
if (length == 0) croak("Term::Fabulous::Termbox: %s needs a non-empty character", function); 1 1 2
53 1 codepoint = (uint32_t)utf8_to_uvchr_buf(bytes, bytes + length, &consumed);
54 1 ▶ if (decoder_stalled(consumed)) croak("Term::Fabulous::Termbox: %s needs well-formed UTF-8", function);
Branch: 1 branch
BranchTrueFalseTotal
if (decoder_stalled(consumed)) croak("Term::Fabulous::Termbox: %s needs well-formed UTF-8", function); 0 1 1
55 1 return codepoint;
56 }
57  
58 /*
59 * Every codepoint of a string, in an array the caller releases with
60 * Safefree. Returns the number of codepoints. The array has room for one
61 * codepoint per byte, an upper bound the loop cannot pass because every
62 * step consumes at least one byte.
63 */
64 62 static size_t decode_codepoints(pTHX_ SV *text, const char *function, uint32_t **codepoints) {
65 STRLEN length;
66 62 const U8 *bytes = well_formed_utf8(aTHX_ text, function, &length);
67 60 const U8 *end = bytes + length;
68 60 size_t count = 0;
69  
70 60 ▶ if (length == 0) croak("Term::Fabulous::Termbox: %s needs a non-empty string", function);
Branch: 1 branch
BranchTrueFalseTotal
if (length == 0) croak("Term::Fabulous::Termbox: %s needs a non-empty string", function); 1 59 60
71  
72 59 ▶ Newx(*codepoints, length, uint32_t);
Branch: 1 branch
BranchTrueFalseTotal
Newx(*codepoints, length, uint32_t); 0 59 59
73 127 ▶ while (bytes < end) {
Branch: 1 branch
BranchTrueFalseTotal
while (bytes < end) { 68 59 127
74 STRLEN consumed;
75 68 (*codepoints)[count++] = (uint32_t)utf8_to_uvchr_buf(bytes, end, &consumed);
76 68 ▶ if (decoder_stalled(consumed)) {
Branch: 1 branch
BranchTrueFalseTotal
if (decoder_stalled(consumed)) { 0 68 68
77 0 Safefree(*codepoints);
78 0 croak("Term::Fabulous::Termbox: %s needs well-formed UTF-8", function);
79 }
80 68 bytes += consumed;
81 }
82 59 return count;
83 }
84  
85 /* The text of a cell: its grapheme cluster when it has one, else its codepoint. */
86 0 static SV *cell_text(pTHX_ const struct tb_cell *cell) {
87 0 ▶ const uint32_t *codepoints = cell->nech > 0 ? cell->ech : &cell->ch;
Branch: 1 branch
BranchTrueFalseTotal
const uint32_t *codepoints = cell->nech > 0 ? cell->ech : &cell->ch; 0 0 0
88 0 ▶ size_t count = cell->nech > 0 ? cell->nech : 1;
Branch: 1 branch
BranchTrueFalseTotal
size_t count = cell->nech > 0 ? cell->nech : 1; 0 0 0
89 0 SV *text = newSVpvs("");
90 U8 buffer[UTF8_MAXBYTES + 1];
91 size_t i;
92  
93 0 SvUTF8_on(text);
94 0 ▶ for (i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < count; i++) { 0 0 0
95 0 U8 *end = uvchr_to_utf8(buffer, codepoints[i]);
96 0 sv_catpvn(text, (const char *)buffer, end - buffer);
97 }
98 0 return text;
99 }
100  
101 17 static void scalar_ref_or_croak(pTHX_ SV *ref, const char *function, const char *what) {
102 17 ▶ if (SvROK(ref) && SvTYPE(SvRV(ref)) < SVt_PVAV) return;
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ref) && SvTYPE(SvRV(ref)) < SVt_PVAV) return; 14 3 17
if (SvROK(ref) && SvTYPE(SvRV(ref)) < SVt_PVAV) return; 14 0 14
103 3 croak("Term::Fabulous::Termbox: %s needs a scalar reference for the %s", function, what);
104 }
105  
106 /* Installs a constant sub and records its name under an export tag. */
107 2640 static void export_constant(pTHX_ HV *stash, HV *tags, const char *tag, const char *name, SV *value) {
108 2640 SV **members = hv_fetch(tags, tag, (I32)strlen(tag), 1);
109 2640 ▶ if (!SvROK(*members)) sv_setsv(*members, sv_2mortal(newRV_noinc((SV *)newAV())));
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(*members)) sv_setsv(*members, sv_2mortal(newRV_noinc((SV *)newAV()))); 48 2592 2640
110 2640 newCONSTSUB(stash, name, value);
111 2640 av_push((AV *)SvRV(*members), newSVpv(name, 0));
112 2640 }
113  
114 /* (status, name => value, ...) for one filled struct tb_event. */
115 #define PUSH_EVENT_FIELD(field) STMT_START { \
116 mPUSHp(#field, sizeof(#field) - 1); \
117 mPUSHi(event.field); \
118 } STMT_END
119  
120 #define PUSH_EVENT(status) \
121 STMT_START { \
122 EXTEND(SP, 17); \
123 mPUSHi(status); \
124 if ((status) == TB_OK) { \
125 PUSH_EVENT_FIELD(type); \
126 PUSH_EVENT_FIELD(mod); \
127 PUSH_EVENT_FIELD(key); \
128 PUSH_EVENT_FIELD(ch); \
129 PUSH_EVENT_FIELD(w); \
130 PUSH_EVENT_FIELD(h); \
131 PUSH_EVENT_FIELD(x); \
132 PUSH_EVENT_FIELD(y); \
133 } \
134 } STMT_END
135  
136 MODULE = Term::Fabulous::Termbox PACKAGE = Term::Fabulous::Termbox
137  
138 PROTOTYPES: DISABLE
139  
140 # --- Lifecycle --------------------------------------------------------
141  
142 int
143 tb_init()
144  
145 int
146 tb_init_file(const char *path)
147  
148 int
149 tb_init_fd(int ttyfd)
150  
151 int
152 tb_init_rwfd(int rfd, int wfd)
153  
154 int
155 tb_shutdown()
156  
157 int
158 tb_width()
159  
160 int
161 tb_height()
162  
163 int
164 tf_init_inline()
165  
166 int
167 tf_init_inline_rwfd(int rfd, int wfd)
168  
169 int
170 tb_set_input_mode(int mode)
171  
172 int
173 tb_set_output_mode(int mode)
174  
175 # --- Drawing ----------------------------------------------------------
176  
177 int
178 tb_clear()
179  
180 int
181 tb_set_clear_attrs(uintattr_t fg, uintattr_t bg)
182  
183 int
184 tb_present()
185  
186 int
187 tb_invalidate()
188  
189 int
190 tb_set_cursor(int cx, int cy)
191  
192 int
193 tb_hide_cursor()
194  
195 int
196 tb_set_cell(int x, int y, SV *glyph, uintattr_t fg, uintattr_t bg)
197 CODE:
198 4 RETVAL = tb_set_cell(x, y, first_codepoint(aTHX_ glyph, "tb_set_cell"), fg, bg);
199 OUTPUT:
200 RETVAL
201  
202 int
203 tb_set_cell_ex(int x, int y, SV *cluster, uintattr_t fg, uintattr_t bg)
204 PREINIT:
205 uint32_t *codepoints;
206 size_t count;
207 CODE:
208 1 count = decode_codepoints(aTHX_ cluster, "tb_set_cell_ex", &codepoints);
209 0 RETVAL = tb_set_cell_ex(x, y, codepoints, count, fg, bg);
210 0 Safefree(codepoints);
211 OUTPUT:
212 RETVAL
213  
214 int
215 tb_extend_cell(int x, int y, SV *glyph)
216 CODE:
217 1 RETVAL = tb_extend_cell(x, y, first_codepoint(aTHX_ glyph, "tb_extend_cell"));
218 OUTPUT:
219 RETVAL
220  
221 void
222 tb_get_cell(int x, int y, int back)
223 PREINIT:
224 struct tb_cell *cell;
225 int status;
226 PPCODE:
227 0 status = tb_get_cell(x, y, back, &cell);
228 0 ▶ EXTEND(SP, 4);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 4); 0 0 0
229 0 mPUSHi(status);
230 0 ▶ if (status == TB_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (status == TB_OK) { 0 0 0
231 0 mPUSHs(cell_text(aTHX_ cell));
232 0 mPUSHu(cell->fg);
233 0 mPUSHu(cell->bg);
234 }
235  
236 int
237 tb_print(int x, int y, uintattr_t fg, uintattr_t bg, SV *text)
238 CODE:
239 0 RETVAL = tb_print(x, y, fg, bg, SvPVutf8_nolen(text));
240 OUTPUT:
241 RETVAL
242  
243 int
244 tf_reset_attrs()
245  
246 int
247 tf_flush()
248  
249 int
250 tf_cells_differ(int x, int y, int width, int height, SV *differ_ref)
251 PREINIT:
252 0 ▶ int differ = 0;
Branch: 1 branch
BranchTrueFalseTotal
int differ = 0; 0 0 0
253 CODE:
254 0 scalar_ref_or_croak(aTHX_ differ_ref, "tf_cells_differ", "answer");
255 0 RETVAL = tf_cells_differ(x, y, width, height, &differ);
256 0 ▶ if (RETVAL == TB_OK) sv_setiv(SvRV(differ_ref), differ);
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == TB_OK) sv_setiv(SvRV(differ_ref), differ); 0 0 0
257 OUTPUT:
258 RETVAL
259  
260 int
261 tf_invalidate_cells(int x, int y, int width, int height)
262  
263 int
264 tb_send(SV *bytes)
265 PREINIT:
266 STRLEN length;
267 const char *buffer;
268 SV *copy;
269 CODE:
270 /* Bytes go out as they are; only a string with a character above
271 * 0xFF has no byte form and is sent UTF-8 encoded. */
272 0 copy = sv_mortalcopy(bytes);
273 0 ▶ if (!sv_utf8_downgrade(copy, TRUE)) sv_utf8_encode(copy);
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_downgrade(copy, TRUE)) sv_utf8_encode(copy); 0 0 0
274 0 buffer = SvPV(copy, length);
275 0 RETVAL = tb_send(buffer, length);
276 OUTPUT:
277 RETVAL
278  
279 # --- Events -----------------------------------------------------------
280  
281 void
282 _peek_event(int timeout_ms)
283 PREINIT:
284 struct tb_event event;
285 int status;
286 PPCODE:
287 67 Zero(&event, 1, struct tb_event);
288 67 status = tb_peek_event(&event, timeout_ms);
289 67 ▶ PUSH_EVENT(status);
Branch: 2 branches
BranchTrueFalseTotal
PUSH_EVENT(status); 0 67 67
PUSH_EVENT(status); 35 32 67
290  
291 void
292 _poll_event()
293 PREINIT:
294 struct tb_event event;
295 int status;
296 PPCODE:
297 0 Zero(&event, 1, struct tb_event);
298 0 status = tb_poll_event(&event);
299 0 ▶ PUSH_EVENT(status);
Branch: 2 branches
BranchTrueFalseTotal
PUSH_EVENT(status); 0 0 0
PUSH_EVENT(status); 0 0 0
300  
301 int
302 tf_install_input_parser()
303  
304 int
305 tf_cursor_position(int timeout_ms, SV *x_ref, SV *y_ref)
306 PREINIT:
307 0 int x = 0;
308 0 ▶ int y = 0;
Branch: 1 branch
BranchTrueFalseTotal
int y = 0; 0 0 0
309 CODE:
310 0 scalar_ref_or_croak(aTHX_ x_ref, "tf_cursor_position", "column");
311 0 scalar_ref_or_croak(aTHX_ y_ref, "tf_cursor_position", "row");
312 0 RETVAL = tf_cursor_position(timeout_ms, &x, &y);
313 0 ▶ if (RETVAL == TB_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == TB_OK) { 0 0 0
314 0 sv_setiv(SvRV(x_ref), x);
315 0 sv_setiv(SvRV(y_ref), y);
316 }
317 OUTPUT:
318 RETVAL
319  
320 int
321 tf_kitty_keyboard_query(int timeout_ms, SV *supported_ref)
322 PREINIT:
323 5 ▶ int supported = 0;
Branch: 1 branch
BranchTrueFalseTotal
int supported = 0; 5 0 5
324 CODE:
325 5 scalar_ref_or_croak(aTHX_ supported_ref, "tf_kitty_keyboard_query", "answer");
326 4 RETVAL = tf_kitty_keyboard_query(timeout_ms, &supported);
327 4 ▶ if (RETVAL == TB_OK) sv_setiv(SvRV(supported_ref), supported);
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == TB_OK) sv_setiv(SvRV(supported_ref), supported); 2 2 4
328 OUTPUT:
329 RETVAL
330  
331 int
332 tf_sixel_query(int timeout_ms, SV *supported_ref, SV *cell_width_ref, SV *cell_height_ref)
333 PREINIT:
334 4 int supported = 0;
335 4 int cell_width = 0;
336 4 ▶ int cell_height = 0;
Branch: 1 branch
BranchTrueFalseTotal
int cell_height = 0; 4 0 4
337 CODE:
338 4 scalar_ref_or_croak(aTHX_ supported_ref, "tf_sixel_query", "answer");
339 4 scalar_ref_or_croak(aTHX_ cell_width_ref, "tf_sixel_query", "cell width");
340 3 scalar_ref_or_croak(aTHX_ cell_height_ref, "tf_sixel_query", "cell height");
341 3 RETVAL = tf_sixel_query(timeout_ms, &supported, &cell_width, &cell_height);
342 3 ▶ if (RETVAL == TB_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == TB_OK) { 2 1 3
343 2 sv_setiv(SvRV(supported_ref), supported);
344 2 sv_setiv(SvRV(cell_width_ref), cell_width);
345 2 sv_setiv(SvRV(cell_height_ref), cell_height);
346 }
347 OUTPUT:
348 RETVAL
349  
350 int
351 tf_input_ended(int fd)
352  
353 int
354 tb_get_fds(SV *tty_ref, SV *resize_ref)
355 PREINIT:
356 1 int ttyfd = -1;
357 1 ▶ int resizefd = -1;
Branch: 1 branch
BranchTrueFalseTotal
int resizefd = -1; 1 0 1
358 CODE:
359 1 scalar_ref_or_croak(aTHX_ tty_ref, "tb_get_fds", "tty descriptor");
360 0 scalar_ref_or_croak(aTHX_ resize_ref, "tb_get_fds", "resize descriptor");
361 0 RETVAL = tb_get_fds(&ttyfd, &resizefd);
362 0 sv_setiv(SvRV(tty_ref), ttyfd);
363 0 sv_setiv(SvRV(resize_ref), resizefd);
364 OUTPUT:
365 RETVAL
366  
367 # --- Widths -----------------------------------------------------------
368  
369 int
370 tb_iswprint(uint32_t ch)
371  
372 int
373 tb_wcwidth(uint32_t ch)
374  
375 int
376 tb_cluster_width(SV *cluster)
377 PREINIT:
378 uint32_t *codepoints;
379 size_t count;
380 CODE:
381 61 count = decode_codepoints(aTHX_ cluster, "tb_cluster_width", &codepoints);
382 59 RETVAL = tf_cluster_width(codepoints, count);
383 59 Safefree(codepoints);
384 OUTPUT:
385 RETVAL
386  
387 # --- Diagnostics ------------------------------------------------------
388  
389 int
390 tb_last_errno()
391  
392 const char *
393 tb_strerror(int err)
394  
395 int
396 tb_has_truecolor()
397  
398 int
399 tb_has_egc()
400  
401 int
402 tb_attr_width()
403  
404 const char *
405 tb_version()
406  
407 BOOT:
408 {
409 12 HV *stash = gv_stashpvs("Term::Fabulous::Termbox", GV_ADD);
410 12 HV *tags = get_hv("Term::Fabulous::Termbox::EXPORT_TAGS", GV_ADD);
411 #define EXPORT_IV(tag, name) export_constant(aTHX_ stash, tags, tag, #name, newSViv((IV)(name)))
412 #define EXPORT_UV(tag, name) export_constant(aTHX_ stash, tags, tag, #name, newSVuv((UV)(name)))
413 /* Keys of the ASCII control range, with their aliases. */
414 12 EXPORT_IV("keys", TB_KEY_CTRL_TILDE);
415 12 EXPORT_IV("keys", TB_KEY_CTRL_2);
416 12 EXPORT_IV("keys", TB_KEY_CTRL_A);
417 12 EXPORT_IV("keys", TB_KEY_CTRL_B);
418 12 EXPORT_IV("keys", TB_KEY_CTRL_C);
419 12 EXPORT_IV("keys", TB_KEY_CTRL_D);
420 12 EXPORT_IV("keys", TB_KEY_CTRL_E);
421 12 EXPORT_IV("keys", TB_KEY_CTRL_F);
422 12 EXPORT_IV("keys", TB_KEY_CTRL_G);
423 12 EXPORT_IV("keys", TB_KEY_BACKSPACE);
424 12 EXPORT_IV("keys", TB_KEY_CTRL_H);
425 12 EXPORT_IV("keys", TB_KEY_TAB);
426 12 EXPORT_IV("keys", TB_KEY_CTRL_I);
427 12 EXPORT_IV("keys", TB_KEY_CTRL_J);
428 12 EXPORT_IV("keys", TB_KEY_CTRL_K);
429 12 EXPORT_IV("keys", TB_KEY_CTRL_L);
430 12 EXPORT_IV("keys", TB_KEY_ENTER);
431 12 EXPORT_IV("keys", TB_KEY_CTRL_M);
432 12 EXPORT_IV("keys", TB_KEY_CTRL_N);
433 12 EXPORT_IV("keys", TB_KEY_CTRL_O);
434 12 EXPORT_IV("keys", TB_KEY_CTRL_P);
435 12 EXPORT_IV("keys", TB_KEY_CTRL_Q);
436 12 EXPORT_IV("keys", TB_KEY_CTRL_R);
437 12 EXPORT_IV("keys", TB_KEY_CTRL_S);
438 12 EXPORT_IV("keys", TB_KEY_CTRL_T);
439 12 EXPORT_IV("keys", TB_KEY_CTRL_U);
440 12 EXPORT_IV("keys", TB_KEY_CTRL_V);
441 12 EXPORT_IV("keys", TB_KEY_CTRL_W);
442 12 EXPORT_IV("keys", TB_KEY_CTRL_X);
443 12 EXPORT_IV("keys", TB_KEY_CTRL_Y);
444 12 EXPORT_IV("keys", TB_KEY_CTRL_Z);
445 12 EXPORT_IV("keys", TB_KEY_ESC);
446 12 EXPORT_IV("keys", TB_KEY_CTRL_LSQ_BRACKET);
447 12 EXPORT_IV("keys", TB_KEY_CTRL_3);
448 12 EXPORT_IV("keys", TB_KEY_CTRL_4);
449 12 EXPORT_IV("keys", TB_KEY_CTRL_BACKSLASH);
450 12 EXPORT_IV("keys", TB_KEY_CTRL_5);
451 12 EXPORT_IV("keys", TB_KEY_CTRL_RSQ_BRACKET);
452 12 EXPORT_IV("keys", TB_KEY_CTRL_6);
453 12 EXPORT_IV("keys", TB_KEY_CTRL_7);
454 12 EXPORT_IV("keys", TB_KEY_CTRL_SLASH);
455 12 EXPORT_IV("keys", TB_KEY_CTRL_UNDERSCORE);
456 12 EXPORT_IV("keys", TB_KEY_SPACE);
457 12 EXPORT_IV("keys", TB_KEY_BACKSPACE2);
458 12 EXPORT_IV("keys", TB_KEY_CTRL_8);
459 /* Terminal-dependent keys. */
460 12 EXPORT_IV("keys", TB_KEY_F1);
461 12 EXPORT_IV("keys", TB_KEY_F2);
462 12 EXPORT_IV("keys", TB_KEY_F3);
463 12 EXPORT_IV("keys", TB_KEY_F4);
464 12 EXPORT_IV("keys", TB_KEY_F5);
465 12 EXPORT_IV("keys", TB_KEY_F6);
466 12 EXPORT_IV("keys", TB_KEY_F7);
467 12 EXPORT_IV("keys", TB_KEY_F8);
468 12 EXPORT_IV("keys", TB_KEY_F9);
469 12 EXPORT_IV("keys", TB_KEY_F10);
470 12 EXPORT_IV("keys", TB_KEY_F11);
471 12 EXPORT_IV("keys", TB_KEY_F12);
472 12 EXPORT_IV("keys", TB_KEY_INSERT);
473 12 EXPORT_IV("keys", TB_KEY_DELETE);
474 12 EXPORT_IV("keys", TB_KEY_HOME);
475 12 EXPORT_IV("keys", TB_KEY_END);
476 12 EXPORT_IV("keys", TB_KEY_PGUP);
477 12 EXPORT_IV("keys", TB_KEY_PGDN);
478 12 EXPORT_IV("keys", TB_KEY_ARROW_UP);
479 12 EXPORT_IV("keys", TB_KEY_ARROW_DOWN);
480 12 EXPORT_IV("keys", TB_KEY_ARROW_LEFT);
481 12 EXPORT_IV("keys", TB_KEY_ARROW_RIGHT);
482 12 EXPORT_IV("keys", TB_KEY_BACK_TAB);
483 12 EXPORT_IV("keys", TB_KEY_MOUSE_LEFT);
484 12 EXPORT_IV("keys", TB_KEY_MOUSE_RIGHT);
485 12 EXPORT_IV("keys", TB_KEY_MOUSE_MIDDLE);
486 12 EXPORT_IV("keys", TB_KEY_MOUSE_RELEASE);
487 12 EXPORT_IV("keys", TB_KEY_MOUSE_WHEEL_UP);
488 12 EXPORT_IV("keys", TB_KEY_MOUSE_WHEEL_DOWN);
489 /* Term::Fabulous additions, see tf_termbox.h. */
490 12 EXPORT_IV("keys", TF_KEY_MOUSE_MOVE);
491 12 EXPORT_IV("keys", TF_KEY_MOUSE_WHEEL_LEFT);
492 12 EXPORT_IV("keys", TF_KEY_MOUSE_WHEEL_RIGHT);
493 /* Keys only the kitty keyboard protocol reports, see tf_termbox.h. */
494 12 EXPORT_IV("keys", TF_KEY_CAPS_LOCK);
495 12 EXPORT_IV("keys", TF_KEY_SCROLL_LOCK);
496 12 EXPORT_IV("keys", TF_KEY_NUM_LOCK);
497 12 EXPORT_IV("keys", TF_KEY_PRINT_SCREEN);
498 12 EXPORT_IV("keys", TF_KEY_PAUSE);
499 12 EXPORT_IV("keys", TF_KEY_MENU);
500 12 EXPORT_IV("keys", TF_KEY_F13);
501 12 EXPORT_IV("keys", TF_KEY_F14);
502 12 EXPORT_IV("keys", TF_KEY_F15);
503 12 EXPORT_IV("keys", TF_KEY_F16);
504 12 EXPORT_IV("keys", TF_KEY_F17);
505 12 EXPORT_IV("keys", TF_KEY_F18);
506 12 EXPORT_IV("keys", TF_KEY_F19);
507 12 EXPORT_IV("keys", TF_KEY_F20);
508 12 EXPORT_IV("keys", TF_KEY_F21);
509 12 EXPORT_IV("keys", TF_KEY_F22);
510 12 EXPORT_IV("keys", TF_KEY_F23);
511 12 EXPORT_IV("keys", TF_KEY_F24);
512 12 EXPORT_IV("keys", TF_KEY_F25);
513 12 EXPORT_IV("keys", TF_KEY_F26);
514 12 EXPORT_IV("keys", TF_KEY_F27);
515 12 EXPORT_IV("keys", TF_KEY_F28);
516 12 EXPORT_IV("keys", TF_KEY_F29);
517 12 EXPORT_IV("keys", TF_KEY_F30);
518 12 EXPORT_IV("keys", TF_KEY_F31);
519 12 EXPORT_IV("keys", TF_KEY_F32);
520 12 EXPORT_IV("keys", TF_KEY_F33);
521 12 EXPORT_IV("keys", TF_KEY_F34);
522 12 EXPORT_IV("keys", TF_KEY_F35);
523 12 EXPORT_IV("keys", TF_KEY_KP_0);
524 12 EXPORT_IV("keys", TF_KEY_KP_1);
525 12 EXPORT_IV("keys", TF_KEY_KP_2);
526 12 EXPORT_IV("keys", TF_KEY_KP_3);
527 12 EXPORT_IV("keys", TF_KEY_KP_4);
528 12 EXPORT_IV("keys", TF_KEY_KP_5);
529 12 EXPORT_IV("keys", TF_KEY_KP_6);
530 12 EXPORT_IV("keys", TF_KEY_KP_7);
531 12 EXPORT_IV("keys", TF_KEY_KP_8);
532 12 EXPORT_IV("keys", TF_KEY_KP_9);
533 12 EXPORT_IV("keys", TF_KEY_KP_DECIMAL);
534 12 EXPORT_IV("keys", TF_KEY_KP_DIVIDE);
535 12 EXPORT_IV("keys", TF_KEY_KP_MULTIPLY);
536 12 EXPORT_IV("keys", TF_KEY_KP_SUBTRACT);
537 12 EXPORT_IV("keys", TF_KEY_KP_ADD);
538 12 EXPORT_IV("keys", TF_KEY_KP_ENTER);
539 12 EXPORT_IV("keys", TF_KEY_KP_EQUAL);
540 12 EXPORT_IV("keys", TF_KEY_KP_SEPARATOR);
541 12 EXPORT_IV("keys", TF_KEY_KP_LEFT);
542 12 EXPORT_IV("keys", TF_KEY_KP_RIGHT);
543 12 EXPORT_IV("keys", TF_KEY_KP_UP);
544 12 EXPORT_IV("keys", TF_KEY_KP_DOWN);
545 12 EXPORT_IV("keys", TF_KEY_KP_PAGE_UP);
546 12 EXPORT_IV("keys", TF_KEY_KP_PAGE_DOWN);
547 12 EXPORT_IV("keys", TF_KEY_KP_HOME);
548 12 EXPORT_IV("keys", TF_KEY_KP_END);
549 12 EXPORT_IV("keys", TF_KEY_KP_INSERT);
550 12 EXPORT_IV("keys", TF_KEY_KP_DELETE);
551 12 EXPORT_IV("keys", TF_KEY_KP_BEGIN);
552 12 EXPORT_IV("keys", TF_KEY_MEDIA_PLAY);
553 12 EXPORT_IV("keys", TF_KEY_MEDIA_PAUSE);
554 12 EXPORT_IV("keys", TF_KEY_MEDIA_PLAY_PAUSE);
555 12 EXPORT_IV("keys", TF_KEY_MEDIA_REVERSE);
556 12 EXPORT_IV("keys", TF_KEY_MEDIA_STOP);
557 12 EXPORT_IV("keys", TF_KEY_MEDIA_FAST_FORWARD);
558 12 EXPORT_IV("keys", TF_KEY_MEDIA_REWIND);
559 12 EXPORT_IV("keys", TF_KEY_MEDIA_TRACK_NEXT);
560 12 EXPORT_IV("keys", TF_KEY_MEDIA_TRACK_PREVIOUS);
561 12 EXPORT_IV("keys", TF_KEY_MEDIA_RECORD);
562 12 EXPORT_IV("keys", TF_KEY_LOWER_VOLUME);
563 12 EXPORT_IV("keys", TF_KEY_RAISE_VOLUME);
564 12 EXPORT_IV("keys", TF_KEY_MUTE_VOLUME);
565 /* Colors and style bits. */
566 12 EXPORT_UV("colors", TB_DEFAULT);
567 12 EXPORT_UV("colors", TB_BLACK);
568 12 EXPORT_UV("colors", TB_RED);
569 12 EXPORT_UV("colors", TB_GREEN);
570 12 EXPORT_UV("colors", TB_YELLOW);
571 12 EXPORT_UV("colors", TB_BLUE);
572 12 EXPORT_UV("colors", TB_MAGENTA);
573 12 EXPORT_UV("colors", TB_CYAN);
574 12 EXPORT_UV("colors", TB_WHITE);
575 12 EXPORT_UV("colors", TB_BOLD);
576 12 EXPORT_UV("colors", TB_UNDERLINE);
577 12 EXPORT_UV("colors", TB_REVERSE);
578 12 EXPORT_UV("colors", TB_ITALIC);
579 12 EXPORT_UV("colors", TB_BLINK);
580 12 EXPORT_UV("colors", TB_HI_BLACK);
581 12 EXPORT_UV("colors", TB_BRIGHT);
582 12 EXPORT_UV("colors", TB_DIM);
583 12 EXPORT_UV("colors", TB_STRIKEOUT);
584 12 EXPORT_UV("colors", TB_UNDERLINE_2);
585 12 EXPORT_UV("colors", TB_OVERLINE);
586 12 EXPORT_UV("colors", TB_INVISIBLE);
587 /* Deprecated upstream aliases, kept for code written against Termbox.pm. */
588 12 EXPORT_UV("colors", TB_TRUECOLOR_BOLD);
589 12 EXPORT_UV("colors", TB_TRUECOLOR_UNDERLINE);
590 12 EXPORT_UV("colors", TB_TRUECOLOR_REVERSE);
591 12 EXPORT_UV("colors", TB_TRUECOLOR_ITALIC);
592 12 EXPORT_UV("colors", TB_TRUECOLOR_BLINK);
593 12 EXPORT_UV("colors", TB_TRUECOLOR_BLACK);
594 /* Event types, modifiers, input and output modes. */
595 12 EXPORT_IV("event", TB_EVENT_KEY);
596 12 EXPORT_IV("event", TB_EVENT_RESIZE);
597 12 EXPORT_IV("event", TB_EVENT_MOUSE);
598 12 EXPORT_IV("event", TB_MOD_ALT);
599 12 EXPORT_IV("event", TB_MOD_CTRL);
600 12 EXPORT_IV("event", TB_MOD_SHIFT);
601 12 EXPORT_IV("event", TB_MOD_MOTION);
602 12 EXPORT_IV("event", TF_MOD_SUPER);
603 12 EXPORT_IV("event", TF_MOD_HYPER);
604 12 EXPORT_IV("event", TF_MOD_META);
605 12 EXPORT_IV("event", TB_INPUT_CURRENT);
606 12 EXPORT_IV("event", TB_INPUT_ESC);
607 12 EXPORT_IV("event", TB_INPUT_ALT);
608 12 EXPORT_IV("event", TB_INPUT_MOUSE);
609 12 EXPORT_IV("event", TB_OUTPUT_CURRENT);
610 12 EXPORT_IV("event", TB_OUTPUT_NORMAL);
611 12 EXPORT_IV("event", TB_OUTPUT_256);
612 12 EXPORT_IV("event", TB_OUTPUT_216);
613 12 EXPORT_IV("event", TB_OUTPUT_GRAYSCALE);
614 12 EXPORT_IV("event", TB_OUTPUT_TRUECOLOR);
615 /* Status codes. */
616 12 EXPORT_IV("return", TB_OK);
617 12 EXPORT_IV("return", TB_ERR);
618 12 EXPORT_IV("return", TB_ERR_NEED_MORE);
619 12 EXPORT_IV("return", TB_ERR_INIT_ALREADY);
620 12 EXPORT_IV("return", TB_ERR_INIT_OPEN);
621 12 EXPORT_IV("return", TB_ERR_MEM);
622 12 EXPORT_IV("return", TB_ERR_NO_EVENT);
623 12 EXPORT_IV("return", TB_ERR_NO_TERM);
624 12 EXPORT_IV("return", TB_ERR_NOT_INIT);
625 12 EXPORT_IV("return", TB_ERR_OUT_OF_BOUNDS);
626 12 EXPORT_IV("return", TB_ERR_READ);
627 12 EXPORT_IV("return", TB_ERR_RESIZE_IOCTL);
628 12 EXPORT_IV("return", TB_ERR_RESIZE_PIPE);
629 12 EXPORT_IV("return", TB_ERR_RESIZE_SIGACTION);
630 12 EXPORT_IV("return", TB_ERR_POLL);
631 12 EXPORT_IV("return", TB_ERR_TCGETATTR);
632 12 EXPORT_IV("return", TB_ERR_TCSETATTR);
633 12 EXPORT_IV("return", TB_ERR_UNSUPPORTED_TERM);
634 12 EXPORT_IV("return", TB_ERR_RESIZE_WRITE);
635 12 EXPORT_IV("return", TB_ERR_RESIZE_POLL);
636 12 EXPORT_IV("return", TB_ERR_RESIZE_READ);
637 12 EXPORT_IV("return", TB_ERR_RESIZE_SSCANF);
638 12 EXPORT_IV("return", TB_ERR_CAP_COLLISION);
639 12 EXPORT_IV("return", TB_ERR_SELECT);
640 12 EXPORT_IV("return", TB_ERR_RESIZE_SELECT);
641 #undef EXPORT_IV
642 #undef EXPORT_UV
643 }
« src/termbox2.c ↑ Summary blib/lib/Term/Fabulous/Enum/WebColor.pm »