A simple Lua wrapper for (n)curses. Attempts to expose an API which is more Lua-esque than just the base (n)curses one.
These instructions will get you a copy of luacurses up and running on your local machine for development and testing purposes.
In order to build luacurses you will need the following:
- C compiler (GCC is recommended)
- Make
- Lua 3.5.2 (or later) and the associated headers
- (N)curses and the associated headers
Simply clone or download the repository and run make linux from the src/ directory.
Copy luacurses.so and put it in the same directory as your Lua executable (or with your other libraries).
Luacurses only exposes a small subset of the (n)curses API. This is because 1) it would be more work to do so and 2) the additional benefit of supporting the entire API is quite small as the (n)curses API contains a large number of redundant and obsolete methods (for compatibility reasons).
That being said, luacurses is a feature-rich and capable (n)curses wrapper and exposes the following methods:
Screen:init()- initializes the screen.Screen:read(n, blocking)- reads inncharacters. Ifblockingis set tofalse, can return less thanncharacters ornil.Screen:readline(blocking)- reads a line. Ifblockingis set tofalse, can return nil.Screen:iscolor()- returnstrueif the screen supports color;falseotherwise.Screen:getsize()- returns the size of the screen as a table in the format{0=x, 1=y}.Screen:getcursor()- returns the position of the cursor as a table in the format{0=x, 1=y}.Screen:setcursor(x, y)- sets the cursor position to{x, y}.Screen:write(string, fg, bg)- writes a string to the screen usingfgas the foreground color andbgas the background color.Screen:clear()- clears the screen.Screen:refresh()- updates the screen. Must be called to show any changes made to the screen, including moving the cursor.Screen:destroy()- closes the screen and returns the terminal to its original state.
GCC - C compiler.
Lua 3.5.4 - Lua language.
Ncurses - The flavor of curses used in testing this wrapper (although any curses library should work).
Simply fork the repository, make your changes, and make a pull request.
This project is licensed under the MIT License - see license.md for details.