ex_ncurses
Ncurses NIF for Elixir
What It Does
ExNcurses is a NIF that let's you create text-based user interfaces and games. It connects Elixir to the ncurses library. Not all of ncurses is available, but quite a bit is including the ability to receive key presses as they happen.
Usage
For usage, you can look at the code in the examples directory or check out the
QuickieSynth sample project (@elixirsips) where we show a version using
ExNcurses.
Installation
The package is available on hex.pm and can
be installed by adding ex_ncurses to your list of dependencies in mix.exs:
def deps do
[
{:ex_ncurses, "~> 0.1"}
]
endCompiling
You will need to install the ncurses library and C header files first. Do this
however is appropriate for your system.
Then the project can be compiled with
mix deps.get
mix compileRun the examples
To run any of the examples, start them by invoking the run_example.sh script:
./run_example.sh demoFAQ
Why isn't anything being drawn to the screen
Try calling ExNcurses.refresh/0 or ExNcurses.wrefresh/1 if you're working in
a window.
Hold up, x and y are swapped everywhere
That's the ncurses way. Everything is row and then column, so y comes first. The upper left is (0, 0).
What happened to the Elixir console
It's still there. It won't receive any input between calls to
ExNcurses.initscr/0 and ExNcurses.endwin/0. I'm still on the fence with what
to do with the console. It could be redirected, output could be thrown away,
etc. At the moment, you'll likely want to turn on the Elixir console logger so
that it doesn't interfere with the display.