source: project/wiki/eggref/5/termbox @ 38133

Last change on this file since 38133 was 38133, checked in by justinmeiners, 2 months ago

Started documenting termbox library.

File size: 18.1 KB
Line 
1== chicken-termbox
2[[toc:]]
3[[http://call-cc.org/|Chicken Scheme]] bindings for
4the library [[https://github.com/nsf/termbox|termbox]].
5
6
7=== Author
8
9[[https://justinmeiners.github.io/|Justin Meiners]]
10
11
12=== API
13
14<procedure> (termbox-init)</procedure>
15
16Initializes the termbox library.== chicken-termbox
17[[toc:]]
18[[http://call-cc.org/|Chicken Scheme]] bindings for
19the library [[https://github.com/nsf/termbox|termbox]].
20
21
22=== Author
23
24[[https://justinmeiners.github.io/|Justin Meiners]]
25
26
27=== API
28
29<procedure> (termbox-init)</procedure>
30
31Initializes the termbox library.
32This function should be called before any other functions.
33
34<procedure> (termbox-shutdown)</procedure>
35
36Shutdown termbox.
37
38
39<procedure> (termbox-width) -> integer</procedure>
40<procedure> (termbox-height) -> integer</procedure>
41
42Returns the size of the internal back buffer (which is the same as
43 terminal's window size in characters).
44
45
46<procedure> (termbox-clear) </procedure>
47
48Clears the internal back buffer using default color or the
49 color/attributes set by termbox-set-clear function.
50== chicken-termbox
51[[toc:]]
52[[http://call-cc.org/|Chicken Scheme]] bindings for
53the library [[https://github.com/nsf/termbox|termbox]].
54
55
56=== Author
57
58[[https://justinmeiners.github.io/|Justin Meiners]]
59
60
61=== API
62
63<procedure> (termbox-init)</procedure>
64
65Initializes the termbox library.
66This function should be called before any other functions.
67
68<procedure> (termbox-shutdown)</procedure>
69
70Shutdown termbox.
71
72
73<procedure> (termbox-width) -> integer</procedure>
74<procedure> (termbox-height) -> integer</procedure>
75
76Returns the size of the internal back buffer (which is the same as
77 terminal's window size in characters).
78
79
80<procedure> (termbox-clear) </procedure>
81
82Clears the internal back buffer using default color or the
83 color/attributes set by termbox-set-clear function.
84
85<procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
86
87Specifies the values that will be applied when calling termbox-clear.
88
89<procedure> (termbox-present) </procedure>
90
91Synchronizes the internal back buffer with the terminal.
92In other words, presents changes to the terminal.
93
94
95<procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure>
96
97Changes cell's parameters in the internal back buffer at the specified position.
98
99<procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
100
101Sets the position of the cursor. Upper-left character is (0, 0).
102Cursor is hidden by default.
103
104<procedure> (termbox-hide-cursor)</procedure>
105
106Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
107
108
109<procedure> (termbox-poll-event) -> list </procedure>
110
111Wait for an event forever and fill the 'event' structure with it, when the event is available. An event is a list containing the following: (TYPE MOD KEY CHAR W H X Y).
112
113
114<procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure>
115
116Wait for an event up to 'timeout' milliseconds and return the event when available.
117
118<procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
119
120Copy data from vectors into the internal buffer.
121The char-buffer is the character codes for the characters.
122
123<procedure> (termbox-blit [x integer] [y integer] [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
124
125Copy data from vectors into a part of the internal buffer at a specific location.
126The char-buffer is the character codes for the characters.
127
128<procedure> (termbox-select-input-mode [mode integer]) </procedure>
129
130Sets the termbox input mode. Termbox has two input modes:
1311. Esc input mode.
132When ESC sequence is in the buffer and it doesn't match any known
133ESC sequence => ESC means tb/key/esc.
134
1352. Alt input mode.
136When ESC sequence is in the buffer and it doesn't match any known
137sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
138
139You can also apply tb/input/mouse via bitwise OR operation to either of the
140modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
141were set, but the mouse mode was, tb/input/esc mode is used. If for some
142reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
143will behave as if only tb/input/esc was selected.
144 
145If 'mode' is tb/input/current, it returns the current input mode.
146Default termbox input mode is tb/input/esc.
147
148<procedure> (termbox-select-output-mode [mode integer]) </procedure>
149
150Sets the termbox output mode. Termbox has three output options:
1511. `tb/output/normal`  => [1..8]
152This mode provides 8 different colors:
153black, red, green, yellow, blue, magenta, cyan, white
154
155Shortcut: tb/color/black, tb/color/red, ...
156     Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
157
158     Example usage:
159         (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
160 
1612. tb/output/256      => [0..256]
162In this mode you can leverage the 256 terminal mode:
163* 0x00 - 0x07: the 8 colors as in tb/output/normal
164* 0x08 - 0x0f: tb/color/_* | tb/attrib/bold
165* 0x10 - 0xe7: 216 different colors
166* 0xe8 - 0xff: 24 different shades of grey
167
168Example usage:
169    tb_change_cell(x, y, '@', 184, 240);
170    tb_change_cell(x, y, '@', 0xb8, 0xf0);
171 
1723. tb/output/216 => [0..216]
173This mode supports the 3rd range of the 256 mode only.
174But you don't need to provide an offset.
175 
1764. tb/output/grayscale  => [0..23]
177This mode supports the 4th range of the 256 mode only.
178But you dont need to provide an offset.
179
180If 'mode' is tb/output/current, it returns the current output mode.
181Default termbox output mode is tb/output/normal
182
183===  License
184
185[[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
186
187
188
189<procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
190
191Specifies the values that will be applied when calling termbox-clear.
192
193<procedure> (termbox-present) </procedure>
194
195Synchronizes the internal back buffer with the terminal.
196In other words, presents changes to the terminal.
197
198
199<procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure>
200
201Changes cell's parameters in the internal back buffer at the specified position.
202
203<procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
204
205Sets the position of the cursor. Upper-left character is (0, 0).
206Cursor is hidden by default.
207
208<procedure> (termbox-hide-cursor)</procedure>
209
210Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
211
212
213<procedure> (termbox-poll-event) -> list </procedure>
214
215Wait for an event forever and fill the 'event' structure with it, when the event is available. An event is a list containing the following: (TYPE MOD KEY CHAR W H X Y).
216
217
218<procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure>
219
220Wait for an event up to 'timeout' milliseconds and return the event when available.
221
222<procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
223
224Copy data from vectors into the internal buffer.
225The char-buffer is the character codes for the characters.
226
227<procedure> (termbox-blit [x integer] [y integer] [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
228
229Copy data from vectors into a part of the internal buffer at a specific location.
230The char-buffer is the character codes for the characters.
231
232<procedure> (termbox-select-input-mode [mode integer]) </procedure>
233
234Sets the termbox input mode. Termbox has two input modes:
2351. Esc input mode.
236When ESC sequence is in the buffer and it doesn't match any known
237ESC sequence => ESC means tb/key/esc.
238
2392. Alt input mode.
240When ESC sequence is in the buffer and it doesn't match any known
241sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
242
243You can also apply tb/input/mouse via bitwise OR operation to either of the
244modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
245were set, but the mouse mode was, tb/input/esc mode is used. If for some
246reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
247will behave as if only tb/input/esc was selected.
248 
249If 'mode' is tb/input/current, it returns the current input mode.
250Default termbox input mode is tb/input/esc.
251
252<procedure> (termbox-select-output-mode [mode integer]) </procedure>
253
254Sets the termbox output mode. Termbox has three output options:
2551. `tb/output/normal`  => [1..8]
256This mode provides 8 different colors:
257black, red, green, yellow, blue, magenta, cyan, white
258
259Shortcut: tb/color/black, tb/color/red, ...
260     Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
261
262     Example usage:
263         (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
264 
2652. tb/output/256      => [0..256]
266In this mode you can leverage the 256 terminal mode:
267* 0x00 - 0x07: the 8 colors as in tb/output/normal
268* 0x08 - 0x0f: tb/color/_* | tb/attrib/bold
269* 0x10 - 0xe7: 216 different colors
270* 0xe8 - 0xff: 24 different shades of grey
271
272Example usage:
273    tb_change_cell(x, y, '@', 184, 240);
274    tb_change_cell(x, y, '@', 0xb8, 0xf0);
275 
2763. tb/output/216 => [0..216]
277This mode supports the 3rd range of the 256 mode only.
278But you don't need to provide an offset.
279 
2804. tb/output/grayscale  => [0..23]
281This mode supports the 4th range of the 256 mode only.
282But you dont need to provide an offset.
283
284If 'mode' is tb/output/current, it returns the current output mode.
285Default termbox output mode is tb/output/normal
286
287===  License
288
289[[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
290
291
292This function should be called before any other functions.
293
294<procedure> (termbox-shutdown)</procedure>
295
296Shutdown termbox.
297
298
299<procedure> (termbox-width) -> integer</procedure>
300<procedure> (termbox-height) -> integer</procedure>
301
302Returns the size of the internal back buffer (which is the same as
303 terminal's window size in characters).
304
305
306<procedure> (termbox-clear) </procedure>
307
308Clears the internal back buffer using default color or the
309 color/attributes set by termbox-set-clear function.
310== chicken-termbox
311[[toc:]]
312[[http://call-cc.org/|Chicken Scheme]] bindings for
313the library [[https://github.com/nsf/termbox|termbox]].
314
315
316=== Author
317
318[[https://justinmeiners.github.io/|Justin Meiners]]
319
320
321=== API
322
323<procedure> (termbox-init)</procedure>
324
325Initializes the termbox library.
326This function should be called before any other functions.
327
328<procedure> (termbox-shutdown)</procedure>
329
330Shutdown termbox.
331
332
333<procedure> (termbox-width) -> integer</procedure>
334<procedure> (termbox-height) -> integer</procedure>
335
336Returns the size of the internal back buffer (which is the same as
337 terminal's window size in characters).
338
339
340<procedure> (termbox-clear) </procedure>
341
342Clears the internal back buffer using default color or the
343 color/attributes set by termbox-set-clear function.
344
345<procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
346
347Specifies the values that will be applied when calling termbox-clear.
348
349<procedure> (termbox-present) </procedure>
350
351Synchronizes the internal back buffer with the terminal.
352In other words, presents changes to the terminal.
353
354
355<procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure>
356
357Changes cell's parameters in the internal back buffer at the specified position.
358
359<procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
360
361Sets the position of the cursor. Upper-left character is (0, 0).
362Cursor is hidden by default.
363
364<procedure> (termbox-hide-cursor)</procedure>
365
366Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
367
368
369<procedure> (termbox-poll-event) -> list </procedure>
370
371Wait for an event forever and fill the 'event' structure with it, when the event is available. An event is a list containing the following: (TYPE MOD KEY CHAR W H X Y).
372
373
374<procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure>
375
376Wait for an event up to 'timeout' milliseconds and return the event when available.
377
378<procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
379
380Copy data from vectors into the internal buffer.
381The char-buffer is the character codes for the characters.
382
383<procedure> (termbox-blit [x integer] [y integer] [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
384
385Copy data from vectors into a part of the internal buffer at a specific location.
386The char-buffer is the character codes for the characters.
387
388<procedure> (termbox-select-input-mode [mode integer]) </procedure>
389
390Sets the termbox input mode. Termbox has two input modes:
3911. Esc input mode.
392When ESC sequence is in the buffer and it doesn't match any known
393ESC sequence => ESC means tb/key/esc.
394
3952. Alt input mode.
396When ESC sequence is in the buffer and it doesn't match any known
397sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
398
399You can also apply tb/input/mouse via bitwise OR operation to either of the
400modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
401were set, but the mouse mode was, tb/input/esc mode is used. If for some
402reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
403will behave as if only tb/input/esc was selected.
404 
405If 'mode' is tb/input/current, it returns the current input mode.
406Default termbox input mode is tb/input/esc.
407
408<procedure> (termbox-select-output-mode [mode integer]) </procedure>
409
410Sets the termbox output mode. Termbox has three output options:
4111. `tb/output/normal`  => [1..8]
412This mode provides 8 different colors:
413black, red, green, yellow, blue, magenta, cyan, white
414
415Shortcut: tb/color/black, tb/color/red, ...
416     Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
417
418     Example usage:
419         (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
420 
4212. tb/output/256      => [0..256]
422In this mode you can leverage the 256 terminal mode:
423* 0x00 - 0x07: the 8 colors as in tb/output/normal
424* 0x08 - 0x0f: tb/color/_* | tb/attrib/bold
425* 0x10 - 0xe7: 216 different colors
426* 0xe8 - 0xff: 24 different shades of grey
427
428Example usage:
429    tb_change_cell(x, y, '@', 184, 240);
430    tb_change_cell(x, y, '@', 0xb8, 0xf0);
431 
4323. tb/output/216 => [0..216]
433This mode supports the 3rd range of the 256 mode only.
434But you don't need to provide an offset.
435 
4364. tb/output/grayscale  => [0..23]
437This mode supports the 4th range of the 256 mode only.
438But you dont need to provide an offset.
439
440If 'mode' is tb/output/current, it returns the current output mode.
441Default termbox output mode is tb/output/normal
442
443===  License
444
445[[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
446
447
448
449<procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
450
451Specifies the values that will be applied when calling termbox-clear.
452
453<procedure> (termbox-present) </procedure>
454
455Synchronizes the internal back buffer with the terminal.
456In other words, presents changes to the terminal.
457
458
459<procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure>
460
461Changes cell's parameters in the internal back buffer at the specified position.
462
463<procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
464
465Sets the position of the cursor. Upper-left character is (0, 0).
466Cursor is hidden by default.
467
468<procedure> (termbox-hide-cursor)</procedure>
469
470Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
471
472
473<procedure> (termbox-poll-event) -> list </procedure>
474
475Wait for an event forever and fill the 'event' structure with it, when the event is available. An event is a list containing the following: (TYPE MOD KEY CHAR W H X Y).
476
477
478<procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure>
479
480Wait for an event up to 'timeout' milliseconds and return the event when available.
481
482<procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
483
484Copy data from vectors into the internal buffer.
485The char-buffer is the character codes for the characters.
486
487<procedure> (termbox-blit [x integer] [y integer] [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
488
489Copy data from vectors into a part of the internal buffer at a specific location.
490The char-buffer is the character codes for the characters.
491
492<procedure> (termbox-select-input-mode [mode integer]) </procedure>
493
494Sets the termbox input mode. Termbox has two input modes:
4951. Esc input mode.
496When ESC sequence is in the buffer and it doesn't match any known
497ESC sequence => ESC means tb/key/esc.
498
4992. Alt input mode.
500When ESC sequence is in the buffer and it doesn't match any known
501sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
502
503You can also apply tb/input/mouse via bitwise OR operation to either of the
504modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
505were set, but the mouse mode was, tb/input/esc mode is used. If for some
506reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
507will behave as if only tb/input/esc was selected.
508 
509If 'mode' is tb/input/current, it returns the current input mode.
510Default termbox input mode is tb/input/esc.
511
512<procedure> (termbox-select-output-mode [mode integer]) </procedure>
513
514Sets the termbox output mode. Termbox has three output options:
5151. `tb/output/normal`  => [1..8]
516This mode provides 8 different colors:
517black, red, green, yellow, blue, magenta, cyan, white
518
519Shortcut: tb/color/black, tb/color/red, ...
520     Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
521
522     Example usage:
523         (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
524 
5252. tb/output/256      => [0..256]
526In this mode you can leverage the 256 terminal mode:
527* 0x00 - 0x07: the 8 colors as in tb/output/normal
528* 0x08 - 0x0f: tb/color/_* | tb/attrib/bold
529* 0x10 - 0xe7: 216 different colors
530* 0xe8 - 0xff: 24 different shades of grey
531
532Example usage:
533    tb_change_cell(x, y, '@', 184, 240);
534    tb_change_cell(x, y, '@', 0xb8, 0xf0);
535 
5363. tb/output/216 => [0..216]
537This mode supports the 3rd range of the 256 mode only.
538But you don't need to provide an offset.
539 
5404. tb/output/grayscale  => [0..23]
541This mode supports the 4th range of the 256 mode only.
542But you dont need to provide an offset.
543
544If 'mode' is tb/output/current, it returns the current output mode.
545Default termbox output mode is tb/output/normal
546
547===  License
548
549[[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
550
551
Note: See TracBrowser for help on using the repository browser.