Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== termbox [[toc:]] [[http://call-cc.org/|Chicken Scheme]] bindings for the library [[https://github.com/nsf/termbox|termbox]]. The API attempts to match the original library as closely as possible, with some slight scheme conveniences. This is done to maximize compatiblity and performance, but can appear a bit too "low-level". It is expected that you will write higher level abstractions, see the examples section. The [[https://raw.githubusercontent.com/nsf/termbox/v1.1.2/src/termbox.h | original header]] may provide helpful information as well. === API <procedure> (termbox-init) -> Integer</procedure> <procedure> (termbox-shutdown)</procedure> Initializes the termbox library and returns 0 if succeeded. The init function should be called before any other functions. Shutdown must be called before exiting, otherwise the terminal may be left in an unusable state. <procedure> (termbox-width) -> integer</procedure> <procedure> (termbox-height) -> integer</procedure> Returns the size of the internal back buffer (which is the same as terminal's window size in characters). <procedure> (termbox-clear) </procedure> Clears the internal back buffer using default color or the color/attributes set by '''termbox-set-clear''' function. <procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure> Specifies the values that will be applied when calling '''termbox-clear'''. <procedure> (termbox-present) </procedure> Synchronizes the internal back buffer with the terminal. In other words, presents changes to the terminal. <procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure> Changes cell's parameters in the internal back buffer at the specified position. <procedure> (termbox-set-cursor [x integer] [y integer])</procedure> Sets the position of the cursor. Upper-left character is (0, 0). Cursor is hidden by default. <procedure> (termbox-hide-cursor)</procedure> Hides the cursor. Cursor can be shown again by calling termbox-set-cursor. <procedure> (termbox-poll-event) -> list </procedure> Wait for an event forever and fill the 'event' structure with it, when the event is available. See below for event structure. <procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure> Wait for an event up to 'timeout' milliseconds and return the event when available. An event is a list containing the following: (TYPE MOD KEY CHAR W H X Y). <procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure> Copy data from vectors into the internal buffer. The char-buffer is the character codes for the characters. <procedure> (termbox-blit [x integer] [y integer] [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure> Copy data from vectors into a part of the internal buffer at a specific location. The char-buffer is the character codes for the characters. <procedure> (termbox-select-input-mode [mode integer]) </procedure> Sets the termbox input mode. Termbox has two input modes: 1. Esc input mode. When ESC sequence is in the buffer and it doesn't match any known ESC sequence => ESC means '''tb/key/esc'''. 2. Alt input mode. When ESC sequence is in the buffer and it doesn't match any known sequence => ESC enables '''tb/mod/alt''' modifier for the next keyboard event. You can also apply '''tb/input/mouse''' via bitwise OR operation to either of the modes (e.g. '''tb/input/esc''' | tb/input/mouse). If none of the main two modes were set, but the mouse mode was, tb/input/esc mode is used. If for some reason you've decided to use '''(tb/input/esc | tb/input/alt)''' combination, it will behave as if only '''tb/input/esc''' was selected. If 'mode' is tb/input/current, it returns the current input mode. Default termbox input mode is '''tb/input/esc'''. <procedure> (termbox-select-output-mode [mode integer]) </procedure> Sets the termbox output mode. Termbox has three output options: 1. '''tb/output/normal''' => [1..8] This mode provides 8 different colors: black, red, green, yellow, blue, magenta, cyan, white Shortcut: '''tb/color/black''', '''tb/color/red''', ... Attributes: '''tb/attrib/bold, '''tb/attrib/underline''', '''tb/attrib/reverse''' Example usage: (tb-change-cell x y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red) 2. '''tb/output/256''' => [0..256] In this mode you can leverage the 256 terminal mode: * 0x00 - 0x07: the 8 colors as in tb/output/normal * 0x08 - 0x0f: tb/color/_* | tb/attrib/bold * 0x10 - 0xe7: 216 different colors * 0xe8 - 0xff: 24 different shades of grey Example usage: (tb-change-cell x y #\@ 184 240) (tb-change-cell x y #\@ #xb8 #xf0) 3. '''tb/output/216''' => [0..216] This mode supports the 3rd range of the 256 mode only. But you don't need to provide an offset. 4. '''tb/output/grayscale''' => [0..23] This mode supports the 4th range of the 256 mode only. But you dont need to provide an offset. If 'mode' is tb/output/current, it returns the current output mode. Default termbox output mode is tb/output/normal ==== Constants Modifiers <constant> tb/mod/alt </constant> <constant> tb/mod/motion </constant> Colors <constant> tb/color/default </constant> <constant> tb/color/black </constant> <constant> tb/color/red </constant> <constant> tb/color/green </constant> <constant> tb/color/yellow </constant> <constant> tb/color/blue </constant> <constant> tb/color/magenta </constant> <constant> tb/color/cyan </constant> <constant> tb/color/white </constant> Attributes <constant> tb/attrib/bold </constant> <constant> tb/attrib/underline </constant> <constant> tb/attrib/reverse </constant> === Examples Convert string to character buffer: (list->u32vector (map char->integer (string-list "hello world"))) === Author [[https://justinmeiners.github.io/|Justin Meiners]] === Source Repository [[https://github.com/justinmeiners/chicken-termbox|termbox]] === License [[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 5 by 4?