Changeset 38134 in project


Ignore:
Timestamp:
01/19/20 23:15:56 (3 months ago)
Author:
justinmeiners
Message:

corrected mispaste

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/termbox

    r38133 r38134  
    33[[http://call-cc.org/|Chicken Scheme]] bindings for
    44the library [[https://github.com/nsf/termbox|termbox]].
     5The API attempts to match the original library as closely as possible,
     6with some slight scheme conveniences.
     7This is done to maximize compatiblity and performance,
     8but can appear a bit too "low-level".
     9It is expected that you will write higher level abstractions,
     10see the examples section.
    511
    612
     
    1319
    1420<procedure> (termbox-init)</procedure>
    15 
    16 Initializes the termbox library.== chicken-termbox
    17 [[toc:]]
    18 [[http://call-cc.org/|Chicken Scheme]] bindings for
    19 the 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>
     21<procedure> (termbox-shutdown)</procedure>
    3022
    3123Initializes the termbox library.
    32 This function should be called before any other functions.
    33 
    34 <procedure> (termbox-shutdown)</procedure>
    35 
    36 Shutdown termbox.
     24The init function should be called before any other functions.
     25Shutdown must be called before exiting, otherwise the terminal
     26may be left in an unusable state.
    3727
    3828
     
    4030<procedure> (termbox-height) -> integer</procedure>
    4131
    42 Returns the size of the internal back buffer (which is the same as
    43  terminal's window size in characters).
    44 
     32Returns the size of the internal back buffer (which is the same as terminal's window size in characters).
    4533
    4634<procedure> (termbox-clear) </procedure>
    4735
    4836Clears 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
    53 the 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 
    65 Initializes the termbox library.
    66 This function should be called before any other functions.
    67 
    68 <procedure> (termbox-shutdown)</procedure>
    69 
    70 Shutdown termbox.
    71 
    72 
    73 <procedure> (termbox-width) -> integer</procedure>
    74 <procedure> (termbox-height) -> integer</procedure>
    75 
    76 Returns 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 
    82 Clears the internal back buffer using default color or the
    83  color/attributes set by termbox-set-clear function.
     37color/attributes set by termbox-set-clear function.
    8438
    8539<procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
     
    9145Synchronizes the internal back buffer with the terminal.
    9246In other words, presents changes to the terminal.
    93 
    9447
    9548<procedure> (termbox-change-cell [x integer] [y integer] [c char] [fg u16] [bg u16])</procedure>
     
    10659Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
    10760
    108 
    10961<procedure> (termbox-poll-event) -> list </procedure>
    11062
    111 Wait 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 
     63Wait for an event forever and fill the 'event' structure with it, when the event is available.
     64See below for event structure.
    11365
    11466<procedure> (termbox-peek-event [timeout-millis integer]) -> list </procedure>
    11567
    11668Wait for an event up to 'timeout' milliseconds and return the event when available.
     69An event is a list containing the following:
     70    (TYPE MOD KEY CHAR W H X Y).
    11771
    11872<procedure> (termbox-copy-buffer [char-buffer u32vector] [fg-buffer u32vector] [bg-vector u32vector]) </procedure>
     
    154108
    155109Shortcut: tb/color/black, tb/color/red, ...
    156      Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
     110Attributes: tb/attrib/bold, tb/attrib/underline, tb/attrib/reverse
    157111
    158      Example usage:
    159          (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
     112Example usage:
     113    (tb-change-cell x  y #\@ (bitwise-ior tb/color/black tb/attrib/bold) tb/color/red)
    160114 
    1611152. tb/output/256      => [0..256]
     
    167121
    168122Example usage:
    169     tb_change_cell(x, y, '@', 184, 240);
    170     tb_change_cell(x, y, '@', 0xb8, 0xf0);
    171  
     123    (tb-change-cell x  y #\@ 184 240)
     124    (tb-change-cell x  y #\@ 0xb8 0xf0)
     125
    1721263. tb/output/216 => [0..216]
    173127This mode supports the 3rd range of the 256 mode only.
    174128But you don't need to provide an offset.
    175  
     129
    1761304. tb/output/grayscale  => [0..23]
    177131This mode supports the 4th range of the 256 mode only.
     
    181135Default termbox output mode is tb/output/normal
    182136
    183 ===  License
    184137
    185 [[https://raw.githubusercontent.com/nsf/termbox/master/COPYING|MIT license]]
     138===  Examples
    186139
     140Convert string to character buffer:
    187141
    188 
    189 <procedure> (termbox-set-clear [fg u16] [bg u16] ) </procedure>
    190 
    191 Specifies the values that will be applied when calling termbox-clear.
    192 
    193 <procedure> (termbox-present) </procedure>
    194 
    195 Synchronizes the internal back buffer with the terminal.
    196 In 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 
    201 Changes cell's parameters in the internal back buffer at the specified position.
    202 
    203 <procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
    204 
    205 Sets the position of the cursor. Upper-left character is (0, 0).
    206 Cursor is hidden by default.
    207 
    208 <procedure> (termbox-hide-cursor)</procedure>
    209 
    210 Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
    211 
    212 
    213 <procedure> (termbox-poll-event) -> list </procedure>
    214 
    215 Wait 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 
    220 Wait 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 
    224 Copy data from vectors into the internal buffer.
    225 The 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 
    229 Copy data from vectors into a part of the internal buffer at a specific location.
    230 The char-buffer is the character codes for the characters.
    231 
    232 <procedure> (termbox-select-input-mode [mode integer]) </procedure>
    233 
    234 Sets the termbox input mode. Termbox has two input modes:
    235 1. Esc input mode.
    236 When ESC sequence is in the buffer and it doesn't match any known
    237 ESC sequence => ESC means tb/key/esc.
    238 
    239 2. Alt input mode.
    240 When ESC sequence is in the buffer and it doesn't match any known
    241 sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
    242 
    243 You can also apply tb/input/mouse via bitwise OR operation to either of the
    244 modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
    245 were set, but the mouse mode was, tb/input/esc mode is used. If for some
    246 reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
    247 will behave as if only tb/input/esc was selected.
    248  
    249 If 'mode' is tb/input/current, it returns the current input mode.
    250 Default termbox input mode is tb/input/esc.
    251 
    252 <procedure> (termbox-select-output-mode [mode integer]) </procedure>
    253 
    254 Sets the termbox output mode. Termbox has three output options:
    255 1. `tb/output/normal`  => [1..8]
    256 This mode provides 8 different colors:
    257 black, red, green, yellow, blue, magenta, cyan, white
    258 
    259 Shortcut: 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  
    265 2. tb/output/256      => [0..256]
    266 In 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 
    272 Example usage:
    273     tb_change_cell(x, y, '@', 184, 240);
    274     tb_change_cell(x, y, '@', 0xb8, 0xf0);
    275  
    276 3. tb/output/216 => [0..216]
    277 This mode supports the 3rd range of the 256 mode only.
    278 But you don't need to provide an offset.
    279  
    280 4. tb/output/grayscale  => [0..23]
    281 This mode supports the 4th range of the 256 mode only.
    282 But you dont need to provide an offset.
    283 
    284 If 'mode' is tb/output/current, it returns the current output mode.
    285 Default termbox output mode is tb/output/normal
     142    (list->u32vector (map char->integer (string-list "hello world")))
    286143
    287144===  License
     
    290147
    291148
    292 This function should be called before any other functions.
    293 
    294 <procedure> (termbox-shutdown)</procedure>
    295 
    296 Shutdown termbox.
    297 
    298 
    299 <procedure> (termbox-width) -> integer</procedure>
    300 <procedure> (termbox-height) -> integer</procedure>
    301 
    302 Returns 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 
    308 Clears 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
    313 the 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 
    325 Initializes the termbox library.
    326 This function should be called before any other functions.
    327 
    328 <procedure> (termbox-shutdown)</procedure>
    329 
    330 Shutdown termbox.
    331 
    332 
    333 <procedure> (termbox-width) -> integer</procedure>
    334 <procedure> (termbox-height) -> integer</procedure>
    335 
    336 Returns 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 
    342 Clears 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 
    347 Specifies the values that will be applied when calling termbox-clear.
    348 
    349 <procedure> (termbox-present) </procedure>
    350 
    351 Synchronizes the internal back buffer with the terminal.
    352 In 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 
    357 Changes cell's parameters in the internal back buffer at the specified position.
    358 
    359 <procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
    360 
    361 Sets the position of the cursor. Upper-left character is (0, 0).
    362 Cursor is hidden by default.
    363 
    364 <procedure> (termbox-hide-cursor)</procedure>
    365 
    366 Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
    367 
    368 
    369 <procedure> (termbox-poll-event) -> list </procedure>
    370 
    371 Wait 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 
    376 Wait 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 
    380 Copy data from vectors into the internal buffer.
    381 The 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 
    385 Copy data from vectors into a part of the internal buffer at a specific location.
    386 The char-buffer is the character codes for the characters.
    387 
    388 <procedure> (termbox-select-input-mode [mode integer]) </procedure>
    389 
    390 Sets the termbox input mode. Termbox has two input modes:
    391 1. Esc input mode.
    392 When ESC sequence is in the buffer and it doesn't match any known
    393 ESC sequence => ESC means tb/key/esc.
    394 
    395 2. Alt input mode.
    396 When ESC sequence is in the buffer and it doesn't match any known
    397 sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
    398 
    399 You can also apply tb/input/mouse via bitwise OR operation to either of the
    400 modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
    401 were set, but the mouse mode was, tb/input/esc mode is used. If for some
    402 reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
    403 will behave as if only tb/input/esc was selected.
    404  
    405 If 'mode' is tb/input/current, it returns the current input mode.
    406 Default termbox input mode is tb/input/esc.
    407 
    408 <procedure> (termbox-select-output-mode [mode integer]) </procedure>
    409 
    410 Sets the termbox output mode. Termbox has three output options:
    411 1. `tb/output/normal`  => [1..8]
    412 This mode provides 8 different colors:
    413 black, red, green, yellow, blue, magenta, cyan, white
    414 
    415 Shortcut: 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  
    421 2. tb/output/256      => [0..256]
    422 In 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 
    428 Example usage:
    429     tb_change_cell(x, y, '@', 184, 240);
    430     tb_change_cell(x, y, '@', 0xb8, 0xf0);
    431  
    432 3. tb/output/216 => [0..216]
    433 This mode supports the 3rd range of the 256 mode only.
    434 But you don't need to provide an offset.
    435  
    436 4. tb/output/grayscale  => [0..23]
    437 This mode supports the 4th range of the 256 mode only.
    438 But you dont need to provide an offset.
    439 
    440 If 'mode' is tb/output/current, it returns the current output mode.
    441 Default 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 
    451 Specifies the values that will be applied when calling termbox-clear.
    452 
    453 <procedure> (termbox-present) </procedure>
    454 
    455 Synchronizes the internal back buffer with the terminal.
    456 In 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 
    461 Changes cell's parameters in the internal back buffer at the specified position.
    462 
    463 <procedure> (termbox-set-cursor [x integer] [y integer])</procedure>
    464 
    465 Sets the position of the cursor. Upper-left character is (0, 0).
    466 Cursor is hidden by default.
    467 
    468 <procedure> (termbox-hide-cursor)</procedure>
    469 
    470 Hides the cursor. Cursor can be shown again by calling termbox-set-cursor.
    471 
    472 
    473 <procedure> (termbox-poll-event) -> list </procedure>
    474 
    475 Wait 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 
    480 Wait 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 
    484 Copy data from vectors into the internal buffer.
    485 The 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 
    489 Copy data from vectors into a part of the internal buffer at a specific location.
    490 The char-buffer is the character codes for the characters.
    491 
    492 <procedure> (termbox-select-input-mode [mode integer]) </procedure>
    493 
    494 Sets the termbox input mode. Termbox has two input modes:
    495 1. Esc input mode.
    496 When ESC sequence is in the buffer and it doesn't match any known
    497 ESC sequence => ESC means tb/key/esc.
    498 
    499 2. Alt input mode.
    500 When ESC sequence is in the buffer and it doesn't match any known
    501 sequence => ESC enables tb/mod/alt modifier for the next keyboard event.
    502 
    503 You can also apply tb/input/mouse via bitwise OR operation to either of the
    504 modes (e.g. tb/input/esc | tb/input/mouse). If none of the main two modes
    505 were set, but the mouse mode was, tb/input/esc mode is used. If for some
    506 reason you've decided to use (tb/input/esc | tb/input/alt) combination, it
    507 will behave as if only tb/input/esc was selected.
    508  
    509 If 'mode' is tb/input/current, it returns the current input mode.
    510 Default termbox input mode is tb/input/esc.
    511 
    512 <procedure> (termbox-select-output-mode [mode integer]) </procedure>
    513 
    514 Sets the termbox output mode. Termbox has three output options:
    515 1. `tb/output/normal`  => [1..8]
    516 This mode provides 8 different colors:
    517 black, red, green, yellow, blue, magenta, cyan, white
    518 
    519 Shortcut: 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  
    525 2. tb/output/256      => [0..256]
    526 In 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 
    532 Example usage:
    533     tb_change_cell(x, y, '@', 184, 240);
    534     tb_change_cell(x, y, '@', 0xb8, 0xf0);
    535  
    536 3. tb/output/216 => [0..216]
    537 This mode supports the 3rd range of the 256 mode only.
    538 But you don't need to provide an offset.
    539  
    540 4. tb/output/grayscale  => [0..23]
    541 This mode supports the 4th range of the 256 mode only.
    542 But you dont need to provide an offset.
    543 
    544 If 'mode' is tb/output/current, it returns the current output mode.
    545 Default 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 TracChangeset for help on using the changeset viewer.