lightweight, pure* Lua implementation of a curses-like library
| .gitignore | Initial commit | |
| emojis.lua | feat: ✨ added more emojis | |
| example.lua | feat: ✨ added support for unicode | |
| LICENSE | Initial commit | |
| lurses.lua | feat: ✨ added support for unicode | |
| README.md | docs: 📝 updated project description in README | |
Lurses
Inspired by the curses library but in 'pure' Lua. It provides basic terminal manipulation capabilities for creating text-based user interfaces.
Features
- Terminal initialization and cleanup
- Screen buffer management
- Color support (8 colors)
- Cursor movement
- Window creation
- Keyboard input handling (including special keys)
- Screen clearing and erasing
Usage
- Include the lurses library in your Lua project:
local lurses = require('lurses')
- Initialize the library:
lurses.init()
- Use lurses functions to manipulate the terminal:
lurses.write("Hello, Lurses!", 1, 1, lurses.COLOR_GREEN, lurses.COLOR_BLACK)
lurses.refresh()
- Create windows if needed:
local win = lurses.create_window(10, 20, 5, 5)
win:write("Window text", 1, 1)
- Handle user input:
local key = lurses.getch()
- Clean up when done:
lurses.close()
Main Functions
lurses.init(): Initialize the library and terminallurses.close(): Clean up and restore terminal settingslurses.write(str, y, x, fg, bg): Write text to the screen bufferlurses.move(y, x): Move the cursorlurses.refresh(): Update the physical screenlurses.getch(): Get a single keypresslurses.clear(): Clear the entire screenlurses.erase(): Erase the screen contentlurses.create_window(h, w, y, x): Create a new window
Example
An example is included in this repo. To run the example:
lua example.lua
Notes
- This library uses ANSI escape codes and may not work on all terminals.
- It's designed for Unix-like systems and may require modifications for Windows.
- The library sets the terminal to non-canonical mode for immediate input handling.
License
See LICENSE file.
Contributing
Contributions welcome.
Acknowledgements
This library is inspired by the ncurses library but implemented in pure Lua for simplicity and portability.