line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Termbox 0.12 { |
2
|
2
|
|
|
2
|
|
104504
|
use 5.020; |
|
2
|
|
|
|
|
16
|
|
3
|
2
|
|
|
2
|
|
1392
|
use strictures 2; |
|
2
|
|
|
|
|
3339
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
476
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
5
|
|
|
|
|
|
|
# |
6
|
2
|
|
|
2
|
|
994
|
use File::ShareDir qw[dist_dir]; |
|
2
|
|
|
|
|
54805
|
|
|
2
|
|
|
|
|
112
|
|
7
|
2
|
|
|
2
|
|
855
|
use File::Spec::Functions qw[catdir canonpath]; |
|
2
|
|
|
|
|
1644
|
|
|
2
|
|
|
|
|
124
|
|
8
|
|
|
|
|
|
|
# |
9
|
2
|
|
|
2
|
|
1007
|
use FFI::CheckLib; |
|
2
|
|
|
|
|
14429
|
|
|
2
|
|
|
|
|
153
|
|
10
|
2
|
|
|
2
|
|
1466
|
use FFI::Platypus 2.00; |
|
2
|
|
|
|
|
14021
|
|
|
2
|
|
|
|
|
68
|
|
11
|
2
|
|
|
2
|
|
924
|
use FFI::Platypus::Memory qw( malloc free ); |
|
2
|
|
|
|
|
26680
|
|
|
2
|
|
|
|
|
318
|
|
12
|
|
|
|
|
|
|
$ENV{FFI_PLATYPUS_DLERROR} = 1; |
13
|
|
|
|
|
|
|
my $ffi = FFI::Platypus->new( |
14
|
|
|
|
|
|
|
api => 2, |
15
|
|
|
|
|
|
|
lang => 'CPP', |
16
|
|
|
|
|
|
|
lib => find_lib_or_exit( |
17
|
|
|
|
|
|
|
lib => 'termbox', |
18
|
|
|
|
|
|
|
recursive => 1, |
19
|
|
|
|
|
|
|
libpath => [ qw[ . ./share/lib], canonpath( catdir( dist_dir(__PACKAGE__), 'lib' ) ) ] |
20
|
|
|
|
|
|
|
) |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
# |
23
|
2
|
|
|
2
|
|
15
|
use base qw[Exporter]; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
160
|
|
24
|
2
|
|
|
2
|
|
12
|
use vars qw[@EXPORT_OK @EXPORT %EXPORT_TAGS]; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
540
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
$EXPORT_TAGS{api} = [ |
27
|
|
|
|
|
|
|
qw[ |
28
|
|
|
|
|
|
|
tb_init tb_init_file tb_init_fd tb_shutdown |
29
|
|
|
|
|
|
|
tb_width tb_height |
30
|
|
|
|
|
|
|
tb_clear tb_set_clear_attributes |
31
|
|
|
|
|
|
|
tb_present |
32
|
|
|
|
|
|
|
tb_set_cursor |
33
|
|
|
|
|
|
|
tb_put_cell tb_change_cell |
34
|
|
|
|
|
|
|
tb_cell_buffer |
35
|
|
|
|
|
|
|
tb_select_input_mode |
36
|
|
|
|
|
|
|
tb_select_output_mode |
37
|
|
|
|
|
|
|
tb_peek_event |
38
|
|
|
|
|
|
|
tb_poll_event |
39
|
|
|
|
|
|
|
] |
40
|
|
|
|
|
|
|
]; |
41
|
|
|
|
|
|
|
use constant { |
42
|
2
|
|
|
|
|
1371
|
TB_KEY_F1 => ( 0xFFFF - 0 ), |
43
|
|
|
|
|
|
|
TB_KEY_F2 => ( 0xFFFF - 1 ), |
44
|
|
|
|
|
|
|
TB_KEY_F3 => ( 0xFFFF - 2 ), |
45
|
|
|
|
|
|
|
TB_KEY_F4 => ( 0xFFFF - 3 ), |
46
|
|
|
|
|
|
|
TB_KEY_F5 => ( 0xFFFF - 4 ), |
47
|
|
|
|
|
|
|
TB_KEY_F6 => ( 0xFFFF - 5 ), |
48
|
|
|
|
|
|
|
TB_KEY_F7 => ( 0xFFFF - 6 ), |
49
|
|
|
|
|
|
|
TB_KEY_F8 => ( 0xFFFF - 7 ), |
50
|
|
|
|
|
|
|
TB_KEY_F9 => ( 0xFFFF - 8 ), |
51
|
|
|
|
|
|
|
TB_KEY_F10 => ( 0xFFFF - 9 ), |
52
|
|
|
|
|
|
|
TB_KEY_F11 => ( 0xFFFF - 10 ), |
53
|
|
|
|
|
|
|
TB_KEY_F12 => ( 0xFFFF - 11 ), |
54
|
|
|
|
|
|
|
TB_KEY_INSERT => ( 0xFFFF - 12 ), |
55
|
|
|
|
|
|
|
TB_KEY_DELETE => ( 0xFFFF - 13 ), |
56
|
|
|
|
|
|
|
TB_KEY_HOME => ( 0xFFFF - 14 ), |
57
|
|
|
|
|
|
|
TB_KEY_END => ( 0xFFFF - 15 ), |
58
|
|
|
|
|
|
|
TB_KEY_PGUP => ( 0xFFFF - 16 ), |
59
|
|
|
|
|
|
|
TB_KEY_PGDN => ( 0xFFFF - 17 ), |
60
|
|
|
|
|
|
|
TB_KEY_ARROW_UP => ( 0xFFFF - 18 ), |
61
|
|
|
|
|
|
|
TB_KEY_ARROW_DOWN => ( 0xFFFF - 19 ), |
62
|
|
|
|
|
|
|
TB_KEY_ARROW_LEFT => ( 0xFFFF - 20 ), |
63
|
|
|
|
|
|
|
TB_KEY_ARROW_RIGHT => ( 0xFFFF - 21 ), |
64
|
|
|
|
|
|
|
TB_KEY_MOUSE_LEFT => ( 0xFFFF - 22 ), |
65
|
|
|
|
|
|
|
TB_KEY_MOUSE_RIGHT => ( 0xFFFF - 23 ), |
66
|
|
|
|
|
|
|
TB_KEY_MOUSE_MIDDLE => ( 0xFFFF - 24 ), |
67
|
|
|
|
|
|
|
TB_KEY_MOUSE_RELEASE => ( 0xFFFF - 25 ), |
68
|
|
|
|
|
|
|
TB_KEY_MOUSE_WHEEL_UP => ( 0xFFFF - 26 ), |
69
|
|
|
|
|
|
|
TB_KEY_MOUSE_WHEEL_DOWN => ( 0xFFFF - 27 ), |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# These are all ASCII code points below SPACE character and a BACKSPACE key. |
72
|
|
|
|
|
|
|
TB_KEY_CTRL_TILDE => 0x00, |
73
|
|
|
|
|
|
|
TB_KEY_CTRL_2 => 0x00, # clash with 'CTRL_TILDE' |
74
|
|
|
|
|
|
|
TB_KEY_CTRL_A => 0x01, |
75
|
|
|
|
|
|
|
TB_KEY_CTRL_B => 0x02, |
76
|
|
|
|
|
|
|
TB_KEY_CTRL_C => 0x03, |
77
|
|
|
|
|
|
|
TB_KEY_CTRL_D => 0x04, |
78
|
|
|
|
|
|
|
TB_KEY_CTRL_E => 0x05, |
79
|
|
|
|
|
|
|
TB_KEY_CTRL_F => 0x06, |
80
|
|
|
|
|
|
|
TB_KEY_CTRL_G => 0x07, |
81
|
|
|
|
|
|
|
TB_KEY_BACKSPACE => 0x08, |
82
|
|
|
|
|
|
|
TB_KEY_CTRL_H => 0x08, # clash with 'CTRL_BACKSPACE' |
83
|
|
|
|
|
|
|
TB_KEY_TAB => 0x09, |
84
|
|
|
|
|
|
|
TB_KEY_CTRL_I => 0x09, # clash with 'TAB' |
85
|
|
|
|
|
|
|
TB_KEY_CTRL_J => 0x0A, |
86
|
|
|
|
|
|
|
TB_KEY_CTRL_K => 0x0B, |
87
|
|
|
|
|
|
|
TB_KEY_CTRL_L => 0x0C, |
88
|
|
|
|
|
|
|
TB_KEY_ENTER => 0x0D, |
89
|
|
|
|
|
|
|
TB_KEY_CTRL_M => 0x0D, # clash with 'ENTER' |
90
|
|
|
|
|
|
|
TB_KEY_CTRL_N => 0x0E, |
91
|
|
|
|
|
|
|
TB_KEY_CTRL_O => 0x0F, |
92
|
|
|
|
|
|
|
TB_KEY_CTRL_P => 0x10, |
93
|
|
|
|
|
|
|
TB_KEY_CTRL_Q => 0x11, |
94
|
|
|
|
|
|
|
TB_KEY_CTRL_R => 0x12, |
95
|
|
|
|
|
|
|
TB_KEY_CTRL_S => 0x13, |
96
|
|
|
|
|
|
|
TB_KEY_CTRL_T => 0x14, |
97
|
|
|
|
|
|
|
TB_KEY_CTRL_U => 0x15, |
98
|
|
|
|
|
|
|
TB_KEY_CTRL_V => 0x16, |
99
|
|
|
|
|
|
|
TB_KEY_CTRL_W => 0x17, |
100
|
|
|
|
|
|
|
TB_KEY_CTRL_X => 0x18, |
101
|
|
|
|
|
|
|
TB_KEY_CTRL_Y => 0x19, |
102
|
|
|
|
|
|
|
TB_KEY_CTRL_Z => 0x1A, |
103
|
|
|
|
|
|
|
TB_KEY_ESC => 0x1B, |
104
|
|
|
|
|
|
|
TB_KEY_CTRL_LSQ_BRACKET => 0x1B, # clash with 'ESC' |
105
|
|
|
|
|
|
|
TB_KEY_CTRL_3 => 0x1B, # clash with 'ESC' |
106
|
|
|
|
|
|
|
TB_KEY_CTRL_4 => 0x1C, |
107
|
|
|
|
|
|
|
TB_KEY_CTRL_BACKSLASH => 0x1C, # clash with 'CTRL_4' |
108
|
|
|
|
|
|
|
TB_KEY_CTRL_5 => 0x1D, |
109
|
|
|
|
|
|
|
TB_KEY_CTRL_RSQ_BRACKET => 0x1D, # clash with 'CTRL_5' |
110
|
|
|
|
|
|
|
TB_KEY_CTRL_6 => 0x1E, |
111
|
|
|
|
|
|
|
TB_KEY_CTRL_7 => 0x1F, |
112
|
|
|
|
|
|
|
TB_KEY_CTRL_SLASH => 0x1F, # clash with 'CTRL_7' |
113
|
|
|
|
|
|
|
TB_KEY_CTRL_UNDERSCORE => 0x1F, # clash with 'CTRL_7' |
114
|
|
|
|
|
|
|
TB_KEY_SPACE => 0x20, |
115
|
|
|
|
|
|
|
TB_KEY_BACKSPACE2 => 0x7F, |
116
|
|
|
|
|
|
|
TB_KEY_CTRL_8 => 0x7F # clash with 'BACKSPACE2' |
117
|
2
|
|
|
2
|
|
14
|
}; |
|
2
|
|
|
|
|
3
|
|
118
|
|
|
|
|
|
|
$EXPORT_TAGS{keys} = [ |
119
|
|
|
|
|
|
|
qw[ |
120
|
|
|
|
|
|
|
TB_KEY_F1 |
121
|
|
|
|
|
|
|
TB_KEY_F2 |
122
|
|
|
|
|
|
|
TB_KEY_F3 |
123
|
|
|
|
|
|
|
TB_KEY_F4 |
124
|
|
|
|
|
|
|
TB_KEY_F5 |
125
|
|
|
|
|
|
|
TB_KEY_F6 |
126
|
|
|
|
|
|
|
TB_KEY_F7 |
127
|
|
|
|
|
|
|
TB_KEY_F8 |
128
|
|
|
|
|
|
|
TB_KEY_F9 |
129
|
|
|
|
|
|
|
TB_KEY_F10 |
130
|
|
|
|
|
|
|
TB_KEY_F11 |
131
|
|
|
|
|
|
|
TB_KEY_F12 |
132
|
|
|
|
|
|
|
TB_KEY_INSERT |
133
|
|
|
|
|
|
|
TB_KEY_DELETE |
134
|
|
|
|
|
|
|
TB_KEY_HOME |
135
|
|
|
|
|
|
|
TB_KEY_END |
136
|
|
|
|
|
|
|
TB_KEY_PGUP |
137
|
|
|
|
|
|
|
TB_KEY_PGDN |
138
|
|
|
|
|
|
|
TB_KEY_ARROW_UP |
139
|
|
|
|
|
|
|
TB_KEY_ARROW_DOWN |
140
|
|
|
|
|
|
|
TB_KEY_ARROW_LEFT |
141
|
|
|
|
|
|
|
TB_KEY_ARROW_RIGHT |
142
|
|
|
|
|
|
|
TB_KEY_MOUSE_LEFT |
143
|
|
|
|
|
|
|
TB_KEY_MOUSE_RIGHT |
144
|
|
|
|
|
|
|
TB_KEY_MOUSE_MIDDLE |
145
|
|
|
|
|
|
|
TB_KEY_MOUSE_RELEASE |
146
|
|
|
|
|
|
|
TB_KEY_MOUSE_WHEEL_UP |
147
|
|
|
|
|
|
|
TB_KEY_MOUSE_WHEEL_DOWN |
148
|
|
|
|
|
|
|
TB_KEY_CTRL_TILDE |
149
|
|
|
|
|
|
|
TB_KEY_CTRL_2 |
150
|
|
|
|
|
|
|
TB_KEY_CTRL_A |
151
|
|
|
|
|
|
|
TB_KEY_CTRL_B |
152
|
|
|
|
|
|
|
TB_KEY_CTRL_C |
153
|
|
|
|
|
|
|
TB_KEY_CTRL_D |
154
|
|
|
|
|
|
|
TB_KEY_CTRL_E |
155
|
|
|
|
|
|
|
TB_KEY_CTRL_F |
156
|
|
|
|
|
|
|
TB_KEY_CTRL_G |
157
|
|
|
|
|
|
|
TB_KEY_BACKSPACE |
158
|
|
|
|
|
|
|
TB_KEY_CTRL_H |
159
|
|
|
|
|
|
|
TB_KEY_TAB |
160
|
|
|
|
|
|
|
TB_KEY_CTRL_I |
161
|
|
|
|
|
|
|
TB_KEY_CTRL_J |
162
|
|
|
|
|
|
|
TB_KEY_CTRL_K |
163
|
|
|
|
|
|
|
TB_KEY_CTRL_L |
164
|
|
|
|
|
|
|
TB_KEY_ENTER |
165
|
|
|
|
|
|
|
TB_KEY_CTRL_M |
166
|
|
|
|
|
|
|
TB_KEY_CTRL_N |
167
|
|
|
|
|
|
|
TB_KEY_CTRL_O |
168
|
|
|
|
|
|
|
TB_KEY_CTRL_P |
169
|
|
|
|
|
|
|
TB_KEY_CTRL_Q |
170
|
|
|
|
|
|
|
TB_KEY_CTRL_R |
171
|
|
|
|
|
|
|
TB_KEY_CTRL_S |
172
|
|
|
|
|
|
|
TB_KEY_CTRL_T |
173
|
|
|
|
|
|
|
TB_KEY_CTRL_U |
174
|
|
|
|
|
|
|
TB_KEY_CTRL_V |
175
|
|
|
|
|
|
|
TB_KEY_CTRL_W |
176
|
|
|
|
|
|
|
TB_KEY_CTRL_X |
177
|
|
|
|
|
|
|
TB_KEY_CTRL_Y |
178
|
|
|
|
|
|
|
TB_KEY_CTRL_Z |
179
|
|
|
|
|
|
|
TB_KEY_ESC |
180
|
|
|
|
|
|
|
TB_KEY_CTRL_LSQ_BRACKET |
181
|
|
|
|
|
|
|
TB_KEY_CTRL_3 |
182
|
|
|
|
|
|
|
TB_KEY_CTRL_4 |
183
|
|
|
|
|
|
|
TB_KEY_CTRL_BACKSLASH |
184
|
|
|
|
|
|
|
TB_KEY_CTRL_5 |
185
|
|
|
|
|
|
|
TB_KEY_CTRL_RSQ_BRACKET |
186
|
|
|
|
|
|
|
TB_KEY_CTRL_6 |
187
|
|
|
|
|
|
|
TB_KEY_CTRL_7 |
188
|
|
|
|
|
|
|
TB_KEY_CTRL_SLASH |
189
|
|
|
|
|
|
|
TB_KEY_CTRL_UNDERSCORE |
190
|
|
|
|
|
|
|
TB_KEY_SPACE |
191
|
|
|
|
|
|
|
TB_KEY_BACKSPACE2 |
192
|
|
|
|
|
|
|
TB_KEY_CTRL_8 |
193
|
|
|
|
|
|
|
] |
194
|
|
|
|
|
|
|
]; |
195
|
|
|
|
|
|
|
# |
196
|
2
|
|
|
2
|
|
17
|
use constant { TB_MOD_ALT => 0x01, TB_MOD_MOTION => 0x02 }; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
180
|
|
197
|
|
|
|
|
|
|
$EXPORT_TAGS{modifier} = [ |
198
|
|
|
|
|
|
|
qw[ |
199
|
|
|
|
|
|
|
TB_MOD_ALT |
200
|
|
|
|
|
|
|
TB_MOD_MOTION |
201
|
|
|
|
|
|
|
] |
202
|
|
|
|
|
|
|
]; |
203
|
|
|
|
|
|
|
# |
204
|
|
|
|
|
|
|
use constant { |
205
|
2
|
|
|
|
|
251
|
TB_DEFAULT => 0x00, |
206
|
|
|
|
|
|
|
TB_BLACK => 0x01, |
207
|
|
|
|
|
|
|
TB_RED => 0x02, |
208
|
|
|
|
|
|
|
TB_GREEN => 0x03, |
209
|
|
|
|
|
|
|
TB_YELLOW => 0x04, |
210
|
|
|
|
|
|
|
TB_BLUE => 0x05, |
211
|
|
|
|
|
|
|
TB_MAGENTA => 0x06, |
212
|
|
|
|
|
|
|
TB_CYAN => 0x07, |
213
|
|
|
|
|
|
|
TB_WHITE => 0x08, |
214
|
2
|
|
|
2
|
|
13
|
}; |
|
2
|
|
|
|
|
3
|
|
215
|
|
|
|
|
|
|
$EXPORT_TAGS{color} = [ |
216
|
|
|
|
|
|
|
qw[ |
217
|
|
|
|
|
|
|
TB_DEFAULT |
218
|
|
|
|
|
|
|
TB_BLACK |
219
|
|
|
|
|
|
|
TB_RED |
220
|
|
|
|
|
|
|
TB_GREEN |
221
|
|
|
|
|
|
|
TB_YELLOW |
222
|
|
|
|
|
|
|
TB_BLUE |
223
|
|
|
|
|
|
|
TB_MAGENTA |
224
|
|
|
|
|
|
|
TB_CYAN |
225
|
|
|
|
|
|
|
TB_WHITE |
226
|
|
|
|
|
|
|
] |
227
|
|
|
|
|
|
|
]; |
228
|
|
|
|
|
|
|
# |
229
|
2
|
|
|
2
|
|
12
|
use constant { TB_BOLD => 0x0100, TB_UNDERLINE => 0x0200, TB_REVERSE => 0x0400 }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
181
|
|
230
|
|
|
|
|
|
|
$EXPORT_TAGS{font} = [ |
231
|
|
|
|
|
|
|
qw[ |
232
|
|
|
|
|
|
|
TB_BOLD |
233
|
|
|
|
|
|
|
TB_UNDERLINE |
234
|
|
|
|
|
|
|
TB_REVERSE |
235
|
|
|
|
|
|
|
] |
236
|
|
|
|
|
|
|
]; |
237
|
|
|
|
|
|
|
# |
238
|
2
|
|
|
2
|
|
12
|
use constant { TB_EVENT_KEY => 1, TB_EVENT_RESIZE => 2, TB_EVENT_MOUSE => 3 }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
181
|
|
239
|
|
|
|
|
|
|
$EXPORT_TAGS{event} = [ |
240
|
|
|
|
|
|
|
qw[ |
241
|
|
|
|
|
|
|
TB_EVENT_KEY |
242
|
|
|
|
|
|
|
TB_EVENT_RESIZE |
243
|
|
|
|
|
|
|
TB_EVENT_MOUSE |
244
|
|
|
|
|
|
|
] |
245
|
|
|
|
|
|
|
]; |
246
|
|
|
|
|
|
|
# |
247
|
|
|
|
|
|
|
use constant { |
248
|
2
|
|
|
|
|
259
|
TB_EUNSUPPORTED_TERMINAL => -1, |
249
|
|
|
|
|
|
|
TB_EFAILED_TO_OPEN_TTY => -2, |
250
|
|
|
|
|
|
|
TB_EPIPE_TRAP_ERROR => -3 |
251
|
2
|
|
|
2
|
|
12
|
}; |
|
2
|
|
|
|
|
36
|
|
252
|
|
|
|
|
|
|
$EXPORT_TAGS{error} = [ |
253
|
|
|
|
|
|
|
qw[ |
254
|
|
|
|
|
|
|
TB_EUNSUPPORTED_TERMINAL |
255
|
|
|
|
|
|
|
TB_EFAILED_TO_OPEN_TTY |
256
|
|
|
|
|
|
|
TB_EPIPE_TRAP_ERROR |
257
|
|
|
|
|
|
|
] |
258
|
|
|
|
|
|
|
]; |
259
|
|
|
|
|
|
|
# |
260
|
2
|
|
|
2
|
|
12
|
use constant { TB_HIDE_CURSOR => -1 }; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
165
|
|
261
|
|
|
|
|
|
|
$EXPORT_TAGS{cursor} = [ |
262
|
|
|
|
|
|
|
qw[ |
263
|
|
|
|
|
|
|
TB_HIDE_CURSOR |
264
|
|
|
|
|
|
|
] |
265
|
|
|
|
|
|
|
]; |
266
|
|
|
|
|
|
|
# |
267
|
|
|
|
|
|
|
use constant { |
268
|
2
|
|
|
|
|
191
|
TB_INPUT_CURRENT => 0, |
269
|
|
|
|
|
|
|
TB_INPUT_ESC => 1, |
270
|
|
|
|
|
|
|
TB_INPUT_ALT => 2, |
271
|
|
|
|
|
|
|
TB_INPUT_MOUSE => => 4 |
272
|
2
|
|
|
2
|
|
15
|
}; |
|
2
|
|
|
|
|
3
|
|
273
|
|
|
|
|
|
|
$EXPORT_TAGS{input} = [ |
274
|
|
|
|
|
|
|
qw[ |
275
|
|
|
|
|
|
|
TB_INPUT_CURRENT |
276
|
|
|
|
|
|
|
TB_INPUT_ESC |
277
|
|
|
|
|
|
|
TB_INPUT_ALT |
278
|
|
|
|
|
|
|
TB_INPUT_MOUSE |
279
|
|
|
|
|
|
|
] |
280
|
|
|
|
|
|
|
]; |
281
|
|
|
|
|
|
|
use constant { |
282
|
2
|
|
|
|
|
257
|
TB_OUTPUT_CURRENT => 0, |
283
|
|
|
|
|
|
|
TB_OUTPUT_NORMAL => 1, |
284
|
|
|
|
|
|
|
TB_OUTPUT_256 => 2, |
285
|
|
|
|
|
|
|
TB_OUTPUT_216 => 3, |
286
|
|
|
|
|
|
|
TB_OUTPUT_GRAYSCALE => 4 |
287
|
2
|
|
|
2
|
|
19
|
}; |
|
2
|
|
|
|
|
6
|
|
288
|
|
|
|
|
|
|
$EXPORT_TAGS{output} = [ |
289
|
|
|
|
|
|
|
qw[ |
290
|
|
|
|
|
|
|
TB_OUTPUT_NORMAL |
291
|
|
|
|
|
|
|
TB_OUTPUT_256 |
292
|
|
|
|
|
|
|
TB_OUTPUT_216 |
293
|
|
|
|
|
|
|
TB_OUTPUT_GRAYSCALE |
294
|
|
|
|
|
|
|
] |
295
|
|
|
|
|
|
|
]; |
296
|
|
|
|
|
|
|
@EXPORT_OK = sort map { @$_ = sort @$_; @$_ } values %EXPORT_TAGS; |
297
|
|
|
|
|
|
|
$EXPORT_TAGS{'all'} = \@EXPORT_OK; # When you want to import everything |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# |
300
|
2
|
|
|
2
|
|
822
|
use Termbox::Cell; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
301
|
|
|
|
|
|
|
$ffi->type('record(Termbox::Cell)'); |
302
|
|
|
|
|
|
|
# |
303
|
2
|
|
|
2
|
|
689
|
use Termbox::Event; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
576
|
|
304
|
|
|
|
|
|
|
$ffi->type('record(Termbox::Event)'); |
305
|
|
|
|
|
|
|
# |
306
|
|
|
|
|
|
|
$ffi->attach( tb_init => ['void'] => 'int' ); |
307
|
|
|
|
|
|
|
$ffi->attach( tb_init_file => ['string'] => 'int' ); |
308
|
|
|
|
|
|
|
$ffi->attach( tb_init_fd => ['int'] => 'int' ); |
309
|
|
|
|
|
|
|
$ffi->attach( tb_shutdown => ['void'] => 'void' ); |
310
|
|
|
|
|
|
|
# |
311
|
|
|
|
|
|
|
$ffi->attach( tb_width => ['void'] => 'int' ); |
312
|
|
|
|
|
|
|
$ffi->attach( tb_height => ['void'] => 'int' ); |
313
|
|
|
|
|
|
|
# |
314
|
|
|
|
|
|
|
$ffi->attach( tb_clear => ['void'] => 'void' ); |
315
|
|
|
|
|
|
|
$ffi->attach( tb_set_clear_attributes => [ 'uint16_t', 'uint16_t' ] => 'void' ); |
316
|
|
|
|
|
|
|
# |
317
|
|
|
|
|
|
|
$ffi->attach( tb_present => ['void'] => 'void' ); |
318
|
|
|
|
|
|
|
# |
319
|
|
|
|
|
|
|
$ffi->attach( tb_set_cursor => [ 'int', 'int' ] => 'void' ); |
320
|
|
|
|
|
|
|
# |
321
|
|
|
|
|
|
|
$ffi->attach( tb_put_cell => [ 'int', 'int', 'record(Termbox::Cell)*' ] => 'void' ); |
322
|
|
|
|
|
|
|
$ffi->attach( [ 'tb_change_cell' => '_tb_change_cell' ], |
323
|
|
|
|
|
|
|
[ 'int', 'int', 'uint32_t', 'uint16_t', 'uint16_t' ] => 'void' ); |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# The C API expects a char which doesn't so much work with Perl's representation of a character. |
326
|
|
|
|
|
|
|
sub tb_change_cell { |
327
|
0
|
0
|
|
0
|
1
|
|
_tb_change_cell( $_[0], $_[1], ( length $_[2] == 1 ? ord( $_[2] ) : $_[2] ), $_[3], $_[4] ); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
# |
330
|
|
|
|
|
|
|
$ffi->attach( tb_cell_buffer => ['void'] => 'record(Termbox::Cell)*' ); |
331
|
|
|
|
|
|
|
# |
332
|
|
|
|
|
|
|
$ffi->attach( tb_select_input_mode => ['int'] => 'int' ); |
333
|
|
|
|
|
|
|
# |
334
|
|
|
|
|
|
|
$ffi->attach( tb_select_output_mode => ['int'] => 'int' ); |
335
|
|
|
|
|
|
|
# |
336
|
|
|
|
|
|
|
$ffi->attach( tb_peek_event => [ 'record(Termbox::Event)*', 'int' ] => 'int' ); |
337
|
|
|
|
|
|
|
# |
338
|
|
|
|
|
|
|
$ffi->attach( tb_poll_event => ['record(Termbox::Event)*'] => 'int' ); |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# Utils: Not documented yet... might keep them private |
341
|
|
|
|
|
|
|
$ffi->attach( tb_utf8_char_length => ['char'] => 'int' ); |
342
|
|
|
|
|
|
|
$ffi->attach( tb_utf8_char_to_unicode => [ 'uint32_t *', 'string' ] => 'int' ); |
343
|
|
|
|
|
|
|
$ffi->attach( tb_utf8_unicode_to_char => [qw[string uint32_t]] => 'int' ); |
344
|
|
|
|
|
|
|
# |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
1; |
347
|
|
|
|
|
|
|
__END__ |