ex_ncurses v0.3.1 ExNcurses
ExNcurses lets Elixir programs create text-based user interfaces using ncurses.
Aside from keyboard input, ExNcurses looks almost like a straight translation of the C-based
ncurses API. ExNcurses sends key events via messages. See listen/0
for this.
Ncurses documentation can be found at:
- The ncurses project page
- opengroup.org
- [] for ncurses documentation.
Link to this section Summary
Functions
Turn off the bit-masked attribute values pass in on the current screen
Turn on the bit-masked attribute values pass in on the current screen
Draw a border around the current window
Clear the screen
Return the number of visible columns
Set the cursor mode
Delete a window w
. This cleans up all memory resources associated with it. The application
must delete subwindows before deleteing the main window
Stop using ncurses and clean the terminal back up
Poll for a key press
Poll for a string
Return the cursor’s column
Return the cursor’s row
Return whether the display supports color
Initialize a foreground/background color pair
Initialize ncurses on a terminal. This should be called before any of the other functions
Enable the terminal’s keypad to capture function keys as single characters
Return the number of visible lines
Listen for events
Move the cursor for the current window to (y, x) relative to the window’s orgin
Move the cursor to the new location
Create a new window with number of nlines, number columns, starting y position, and starting x position
Print the specified string and advance the cursor.
Unlike the ncurses printw, this version doesn’t support format
specification. It is really the same as addstr/1
Refresh the display. This needs to be called after any of the print or addstr functions to render their changes
Enable scrolling on stdscr
Set a scrollable region on the stdscr
Enable the use of colors
Stop listening for events
Add a string to a window win
. This function will advance the cursor position,
perform special character processing, and perform wrapping
Draw a wborder around a specific window
Move the cursor associated with the specified window to (y, x) relative to the window’s orgin
Link to this section Types
color_name() :: :black | :red | :green | :yellow | :blue | :magenta | :cyan | :white
Link to this section Functions
Turn off the bit-masked attribute values pass in on the current screen.
Turn on the bit-masked attribute values pass in on the current screen.
Draw a border around the current window.
Clear the screen
Return the number of visible columns
Set the cursor mode
- 0 = Invisible
- 1 = Terminal-specific normal mode
- 2 = Terminal-specific high visibility mode
Delete a window w
. This cleans up all memory resources associated with it. The application
must delete subwindows before deleteing the main window.
Stop using ncurses and clean the terminal back up.
Poll for a key press.
See listen/0
for a better way of getting keyboard input.
Poll for a string.
Return the cursor’s column.
Return the cursor’s row.
Return whether the display supports color
Initialize a foreground/background color pair
Initialize ncurses on a terminal. This should be called before any of the other functions.
By default, ncurses uses the current terminal. If you’re debugging or want to
have IEx available while in ncurses-mode you can also have it use a different
window. One way of doing this is to open up another terminal session. At the
prompt, run tty
. Then pass the path that it returns to this function.
Currently input doesn’t work in this mode.
TODO: Return stdscr (a window)
Enable the terminal’s keypad to capture function keys as single characters.
Return the number of visible lines
Listen for events.
Events will be sent as messages of the form:
{ex_ncurses, :key, key}
Move the cursor for the current window to (y, x) relative to the window’s orgin.
mvaddstr(non_neg_integer(), non_neg_integer(), String.t()) :: :ok
mvcur( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: :ok
Move the cursor to the new location.
mvprintw(non_neg_integer(), non_neg_integer(), String.t()) :: :ok
newwin( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: window()
Create a new window with number of nlines, number columns, starting y position, and starting x position.
Print the specified string and advance the cursor.
Unlike the ncurses printw, this version doesn’t support format
specification. It is really the same as addstr/1
.
Refresh the display. This needs to be called after any of the print or addstr functions to render their changes.
Enable scrolling on stdscr
.
Set a scrollable region on the stdscr
Enable the use of colors.
Stop listening for events
Add a string to a window win
. This function will advance the cursor position,
perform special character processing, and perform wrapping.
Draw a wborder around a specific window.
Move the cursor associated with the specified window to (y, x) relative to the window’s orgin.