Simple Erlang/macOS port of ex_termbox. Uses the NIF code from that project to expose termbox functionality to Erlang. Lazy port-compiler-only build requires termbox installed via brew.
$ rebar3 compile
$ rebar3 shell
- Ensure
etbx
app is started in your release, create agen_server
to act as your TUI manager and have it calletbx_event:subscribe/1
- It'll receive
#etbx_event
records for every keyboard event ashandle_info/2
messages, and you can useetbx_core
functions likeput_cell/1
(to send#etbx_cell
records containing#etbx_position
children),clear/0
andpresent/0
- Various constants (
colors
,attributes
etc) are defined inetbx_constants
- When you're done listening to keyboard events and want to drop back to the erlang shell, call
etbx_event:unsubscribe/1
- If
etbx_event
terminates the termbox session (which by default it does on receiving 3xctrl-c
within 500ms) you'll receive ahandle_info/2
messageetbx_shutdown
at which point you can decide what to do
Example etbx_core:put_cell/1
call:
etbx_core:put_cell( #etbx_cell{
position = #etbx_position{
x = X,
y = Y
},
ch = Char,
fg = maps:get( yellow, etbx_constants:colors() ),
bg = maps:get( default, etbx_constants:colors() )
} ),
etbx_core:present().