1
0
Fork
You've already forked lurses
0
lightweight, pure* Lua implementation of a curses-like library
lua
  • Lua 100%
2025年05月15日 21:38:49 +09:00
.gitignore Initial commit 2024年08月03日 22:09:28 +02:00
emojis.lua feat: added more emojis 2024年08月04日 08:59:43 +02:00
example.lua feat: added support for unicode 2024年08月04日 08:54:48 +02:00
LICENSE Initial commit 2024年08月03日 22:09:28 +02:00
lurses.lua feat: added support for unicode 2024年08月04日 08:54:48 +02:00
README.md docs: 📝 updated project description in README 2025年05月15日 21:38:49 +09:00

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

  1. Include the lurses library in your Lua project:
local lurses = require('lurses')
  1. Initialize the library:
lurses.init()
  1. Use lurses functions to manipulate the terminal:
lurses.write("Hello, Lurses!", 1, 1, lurses.COLOR_GREEN, lurses.COLOR_BLACK)
lurses.refresh()
  1. Create windows if needed:
local win = lurses.create_window(10, 20, 5, 5)
win:write("Window text", 1, 1)
  1. Handle user input:
local key = lurses.getch()
  1. Clean up when done:
lurses.close()

Main Functions

  • lurses.init(): Initialize the library and terminal
  • lurses.close(): Clean up and restore terminal settings
  • lurses.write(str, y, x, fg, bg): Write text to the screen buffer
  • lurses.move(y, x): Move the cursor
  • lurses.refresh(): Update the physical screen
  • lurses.getch(): Get a single keypress
  • lurses.clear(): Clear the entire screen
  • lurses.erase(): Erase the screen content
  • lurses.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.