A simple Lua wrapper for curses. Attempts to expose an API which is more Lua-esque than just the base curses one.
These instructions will help you get luacurses up and running for development and testing purposes.
In order to build luacurses, you will need the following:
- C compiler
- Make or CMake
- Lua 5.4 and the associated headers
- Curses and the associated headers (Ncurses is recommended)
-
Clone or download the repository:
$ git clone https://github.com/billylegota/luacurses.git $ cd luacurses -
Build using Make:
$ make
-
Alternatively, you can build using CMake:
$ mkdir build $ cd build $ cmake .. $ make
Copy luacurses.so and curses.lua to the same directory as your Lua executable or to your Lua libraries directory.
luacurses exposes a small subset of the curses API, focusing on essential and useful methods. The available methods are:
Screen:init()- Initializes the screen.Screen:read(n, blocking)- Readsncharacters. Ifblockingis set tofalse, it can return less thanncharacters ornil.Screen:readline(blocking)- Reads a line. Ifblockingis set tofalse, it can returnnil.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.
- Lua 5.4 - Lua language.
- Ncurses - The flavor of curses used in testing this wrapper (although any curses library should work).
To contribute, fork the repository, make your changes, and create a pull request.
This project is licensed under the MIT License - see LICENSE.md for details.