Loading repository data…
Loading repository data…
DROOdotFOO / repository
BEAM wrappers (Erlang/Elixir/Gleam) for termbox2 terminal UI library
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
[0.3.1] Now supports Unicode terminal titles, new NIFs (
tb_set_title/1,tb_set_position/2), and improved error handling. See CHANGELOG for details.
A modern, cross-platform BEAM (Erlang/Elixir/Gleam) wrapper for the termbox2 terminal UI library.
Published on Hex.pm: https://hex.pm/packages/termbox2_nif
Note: The repository name was changed because the original "termbox2" name was already taken by the upstream C project. This package provides BEAM/Elixir/Erlang/Gleam bindings for termbox2, not the original C library itself.
NIF binary: built to
termbox2_nif/priv/. Wrappers use this automatically via the unified workflow.
makeAdd to your rebar.config:
{deps, [
{termbox2_nif, {path, "termbox2_nif"}}
]}.
Fetch and compile:
rebar3 get-deps
rebar3 compile
Add to your mix.exs:
def deps do
[
{:termbox2, path: "wrappers/elixir"}, {:termbox2_nif, "~> 0.3.0"}
]
end
Then run:
mix deps.get
See wrappers/elixir/README.md for full instructions.
See wrappers/gleam/README.md for full instructions.
Always use these commands from the project root for all development and CI.
make build # Build everything (C, Erlang, Elixir, Gleam)
make test # Run all tests (Erlang, Elixir, Gleam)
make clean-all # Clean all build artifacts and outputs
Or from a wrapper directory (Elixir or Gleam):
make build # Build (delegates to root)
make test # Test (delegates to root)
make clean # Clean wrapper build artifacts
These commands ensure the correct NIF/BEAM files are always in place. Do not manually copy or symlink NIF/BEAM files.
make build from the project root.erl_nif.h, ensure you have Erlang development headers installed.CFLAGS environment variable to include your Erlang include path.chmod +x rebar3 or run as a user with appropriate rights.xcode-select --install to install developer tools.build-essential or equivalent is installed.Install Erlang/OTP for Windows
Open MSYS2/MinGW shell
Run:
make build
The NIF will be built as a DLL and placed in the priv/ directory
%% Define default attributes (foreground/background)
-define(TB_DEFAULT, 0).
ok = termbox2_nif:tb_init(),
ok = termbox2_nif:tb_clear(),
Str = "Hello, termbox!",
X = 1, Y = 1,
Fg = ?TB_DEFAULT, Bg = ?TB_DEFAULT,
ok = termbox2_nif:tb_print(X, Y, Fg, Bg, Str),
%% New in 0.3.1: Set terminal title (Unicode supported)
ok = termbox2_nif:tb_set_title("测试Unicode标题"),
%% New in 0.3.1: Set terminal window position (with bounds checking)
ok = termbox2_nif:tb_set_position(100, 100),
ok = termbox2_nif:tb_present(),
{ok, _Type, _Mod, _KeyOrChar} = termbox2_nif:tb_poll_event(),
ok = termbox2_nif:tb_shutdown().
# In your mix.exs, add:
# {:termbox2, path: "wrappers/elixir"}, {:termbox2_nif, "~> 0.3.0"}
:ok = Termbox2.init()
:ok = Termbox2.set_cell(0, 0, ?A, :red, :default)
:ok = Termbox2.present()
:ok = Termbox2.shutdown()
import termbox2_gleam
import termbox2_gleam.{Red, Default, set_cell_friendly, print_friendly}
pub fn main() {
case termbox2_gleam.init() {
Ok(_) -> {
set_cell_friendly(0, 0, 65, Red, Default)
print_friendly(1, 1, Red, Default, "Hello, world!")
termbox2_gleam.present()
termbox2_gleam.shutdown()
}
Error(e) -> {
io.println("Failed to initialize termbox2: " <> e)
}
}
}