1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
This module provides bindings for termbox2.
Some changes to the API have been made to enable using this library in a
more Hare-idiomatic style. In particular:
- The tb_ and TB_ prefixes have been removed, as the namespace termbox2::
is used instead. We recommend importing this library as tb, so that one
can write e.g. tb::init(), keeping it similar to the original tb_init().
- Functions return a value that can be either a valid result (e.g. int,
void, str...) or an int-backed error [[termbox2::err]]. The error codes
are consistent with the original library and can be interpreted with
[[termbox2::strerror]]. Some additional codes for binding-related errors
are provided.
- Similarly to the previous point, some functions that use to return
multiple values by taking pointer parameters now simply return a tuple,
see for example [[termbox2::get_fds]].
- The tb_event type has changed into a tagged union of 3 types,
see [[termbox2::event]].
- The four tb_print* functions have been replaced by a single
[[termbox2::print]] function that uses Hare-style string formatting.
Similarly, tb_send and tb_sendf have replaced by only one function
[[termbox2::send]].
- The constants provided by ther termbox2 API, such as those for key codes,
colors and attributes, have been split into various structures, such as
[[termbox2::KEY]], [[termbox2::COLOR]] and [[termbox2::ATTRIBUTE]].
Some functionality has been outright removed. If you are interested in
having any of the following available in these bindings, don't hesitate
to send a patch or a feature request to sebastiano@tronto.net:
- The tb_get_cell function is not available. This function makes it
possible to navigate through cells via pointer arithmetic, but since
the Hare [[termbox2::cell]] type does not have the same size as the
original tb_cell, this would not translate cleanly.
- The tb_iswprint, tb_wcwidth and tb_utf8_* have functions have been
removed. Use the Hare standard libary functions [[encoding::utf8::]]
and [[strings::]] instead.
- The tb_last_errno function has been removed.
- The TB_CAP_* code constants have been removed.
Links:
- Main repository: https://git.tronto.net/hare-termbox2
- termbox2: https://github.com/termbox/termbox2
|