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
etbxapp is started in your release, create agen_serverto act as your TUI manager and have it calletbx_event:subscribe/1 - It'll receive
#etbx_eventrecords for every keyboard event ashandle_info/2messages, and you can useetbx_corefunctions likeput_cell/1(to send#etbx_cellrecords containing#etbx_positionchildren),clear/0andpresent/0 - Various constants (
colors,attributesetc) 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_eventterminates the termbox session (which by default it does on receiving 3xctrl-cwithin 500ms) you'll receive ahandle_info/2messageetbx_shutdownat 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().