aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md87
1 files changed, 87 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7620429
--- /dev/null
+++ b/README.md
@@ -0,0 +1,87 @@
1# Hare bindings for termbox2
2
3This repository contains [hare](https://harelang.org) bindings for the
4terminal I/O library [termbox2](https://github.com/termbox/termbox2).
5
6There are some differences between the Hare bindings and the original
7C code, for example the fact that the prefixes `tb_` and `TB_` have been
8replaced by the namespace `termbox2::`. See the haredoc documentation
9in `termbox2/README` for more information.
10
11## Using this library
12
13There are two ways to build termbox2 for this library. Both involve
14building termbox2 as a standalone library or object file, rather than
15including it as a header-only library as one could do in a C program.
16
17### Using the system's termbox2 (default)
18
19This method assumes that termbox2 is already installed as a library
20system-wide, for example by using your OS's package manager or by
21installing it from source using `make install_lib`.
22
23Once termbox2 is installed, you can run `make install`. This will
24copy the hare bindings to `/usr/local/src/hare/third-party/` so that
25you can include them in your Hare project as any other module. Do
26not forget to add the `-ltermbox2` option to build any program that
27uses this library.
28
29To uninstall the bindings, run `make uninstall`.
30
31You can also run `make demos` (or simply `make`) to build the demo
32programs contained in `demo/`, and then you can run them from the
33`build/` folder. For example, to run the `hjkl` demo you can run
34`make && ./build/demo/hjkl`.
35
36### Using a local termbox2
37
38This method is useful if you just want to experiment with termbox2
39programming in Hare, for example by running and modifying the demos
40in `demo/`, without installing anything system-wide.
41
42To do this, the original library is provided as a
43[git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
44in this repository. You can download it with:
45
46```
47git submodule init
48```
49
50(Alternative, you can place the source code for termbox2 in
51`vendor/termbox2`). Then you can build termbox2 locally with
52
53```
54make local
55```
56
57This will directly build all the demo programs from `demo/`, placing
58the resulting binaries in `build/demo`.
59
60Technical note: this will include the compiled termbox object file
61`termbox.o` directly in the compiled binaries.
62
63To build the demo programs using this method, run `make local-demos`.
64
65## Notes on build options
66
67The original termbox2 library offers several build options via `TB_OPT_*`
68constants. Two of them, `TB_OPT_ATTR_W` and `TB_OPT_EGC`, are relevant for
69the API.
70
71* `TB_OPT_ATTR_W` (in the Hare bindings: `termbox2::OPT_ATTR_W`) can be
72either `16`, `32` or `64`, and is used to enable more output attributer
73(e.g. truecolor). The termbox2 sources claim that the default value is
74`16`, but this is only true when including termbox2 as a header-only
75library. When building it as an external library, the default is `64`.
76Since these bindings are meant to be used with termbox2 compiled as an
77external library, we use `64` as default. The hare build tags `attrw16`
78and `attrw32` are offered if one wants to use a different value.
79
80* `TB_OPT_EGC` (in the Hare bindings: `termbox2::OPT_EGC`) can be set or
81not set (in the bindings: it is a boolean value, `true` for set, `false`
82for not set). Similarly to `TB_OPT_ATTR_W`, it is by default set when
83building termbox2 as an external library, unlike when including it as a
84header-only library. An `noegc` tag is available to disable this option.
85
86Note: the consistency of these two build options between the C library
87and the Hare bindings is checked and enforced in `termbox2::init()`.

Generated with cgit - Back to sebastiano.tronto.net