LTUI is a cross-platform character terminal UI library based on LuA.
This framework is derived from the requirements of graphical menu configuration in Xmake, similar to the Linux Kernel menuconf to configure compilation parameters, so based on Curses and Lua to achieve a set of cross-platform character terminal UI library. The styles are largely based on Kconfig-Frontends, and users can customize their own UI styles.
In addition, LTUI is fully cross-platform, and the Terminal terminal on Windows is also fully supported. On Windows, LTUI uses PDcurses for window rendering.
- Github
Update the content
In previous versions, however, the layout does not automatically adjust to the size of the terminal window. If the window becomes larger, the entire view will remain the same size. In the current v1.7 version, I did a partial refactoring to support window Resize and adaptive adjustment of all views layout.
Previous version:
What the new version looks like:
Install and use
$ luarocks install ltui
Copy the code
To run the built-in tests, you need to install lua or Luajit to load and run the tests in the LTUI repository:
$ lua tests/dialog.lua
$ lua tests/window.lua
$ lua tests/desktop.lua
$ lua tests/inputdialog.lua
$ lua tests/mconfdialog.lua
Copy the code
or
$ luajit tests/dialog.lua
$ luajit tests/window.lua
$ luajit tests/desktop.lua
$ luajit tests/inputdialog.lua
$ luajit tests/mconfdialog.lua
Copy the code
The source code to compile
Luarocks is usually ready to use as long as it is installed. If you want to debug locally, you can also run the tests directly after compiling the source code. First we need to install the cross-platform build tool: Xmake
$ xmake
Copy the code
Xmake will automatically download lua, ncurses and other related dependencies. Then we will directly load the relevant test program through xmake run.
$ xmake run test dialog
$ xmake run test window
$ xmake run test desktop
$ xmake run test inputdialog
$ xmake run test mconfdialog
Copy the code
The application
local ltui = require("ltui")
local application = ltui.application
local event = ltui.event
local rect = ltui.rect
local window = ltui.window
local demo = application()
function demo:init(a)
application.init(self, "demo")
self:background_set("blue")
self:insert(window:new("window.main", rect {1.1, self:width() - 1, self:height() - 1}, "main window".true))
end
demo:run()
Copy the code
The label
local lab = label:new("title", rect {0.0.12.1}, "hello ltui!"):textattr_set("white")
Copy the code
button
local btn = button:new("yes", rect {0.1.7.2}, "< Yes >"):textattr_set("white")
Copy the code
Input box
function demo:init(a)
-...
local dialog_input = inputdialog:new("dialog.input", rect {0.0.50.8})
dialog_input:text():text_set("please input text:")
dialog_input:button_add("no"."< No >".function (v) dialog_input:quit() end)
dialog_input:button_add("yes"."< Yes >".function (v) dialog_input:quit() end)
self:insert(dialog_input, {centerx = true, centery = true})
end
Copy the code
component
view | dialog | other |
---|---|---|
view | dialog | event |
panel | boxdialog | action |
label | textdialog | canvas |
button | inputdialog | curses |
border | mconfdialog | program |
window | choicedialog | application |
menubar | point | |
menuconf | rect | |
textedit | object | |
textarea | ||
statusbar | ||
choicebox | ||
desktop |
Configuration menu
Input box
The text area
The Windows platform