LTUI is a lua-based cross-platform character terminal UI interface library.
This framework is derived from the requirement of graphical menu configuration in xmake , similar to the menuconf of linux kernel to configure compilation parameters, so based on curses and lua, a set of cross-platform character terminal ui library is implemented.
And the style style basically refers to kconfig-frontends completely, of course, users can also customize different ui styles by themselves.
In addition, LTUI is completely cross-platform, and the terminal terminal on windows is also fully supported. On windows, ltui will use pdcurses to draw windows.
update content
In the new version, we have improved the mouse support and realized click response to mouse events of all controls. Here we are very grateful for the contribution of @laelnasan .
In addition, we added a scrollbar component for scrolling support, and we also added scrolling support to choicebox and menuconf components.
Choicebox scrolling support
menuconf scrolling support
Install and use
$ luarocks install ltui
If you want to run the built-in test, you need to install the lua or luajit program to load and run the test program in the ltui source code repository:
$ lua tests/dialog.lua
$ lua tests/window.lua
$ lua tests/desktop.lua
$ lua tests/inputdialog.lua
$ lua tests/mconfdialog.lua
or
$ luajit tests/dialog.lua
$ luajit tests/window.lua
$ luajit tests/desktop.lua
$ luajit tests/inputdialog.lua
$ luajit tests/mconfdialog.lua
Source code compilation
Usually luarocks can be used as long as it is installed. If you want to debug locally, you can also run the test directly after the source code is compiled. First, we need to install the cross-platform build tool: xmake
$ xmake
xmake will automatically download lua, ncurses and other related dependencies, and then we can directly xmake run
load the related test programs:
$ xmake run test dialog
$ xmake run test window
$ xmake run test desktop
$ xmake run test inputdialog
$ xmake run test mconfdialog
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()
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()
label
local lab = label:new("title", rect {
0, 0, 12, 1}, "hello ltui!"):textattr_set("white")
Button
local btn = button:new("yes", rect {
0, 1, 7, 2}, "< Yes >"):textattr_set("white")
Input box
function demo:init()
-- ...
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
Component
view | Dialog box | other |
---|---|---|
view | dialog | event |
panel | boxdialog | action |
label | textdialog | canvas |
button | inputdialog | races |
border | mconfdialog | program |
window | choicedialog | application |
menubar | point | |
menuconf | rect | |
textedit | object | |
textarea | ||
statusbar | ||
choicebox | ||
scrollbar | ||
desktop |