LTUI基于 Lua 的跨平臺字符終端 UI 界面庫
簡介
LTUI是一個基于lua的跨平臺字符終端UI界面庫。
此框架源于xmake中圖形化菜單配置的需求,類似linux kernel的menuconf去配置編譯參數(shù),因此基于curses和lua實(shí)現(xiàn)了一整套跨平臺的字符終端ui庫。 而樣式風(fēng)格基本上完全參照的kconfig-frontends,當(dāng)然用戶也可以自己定制不同的ui風(fēng)格。
安裝
$ luarocks install ltui
編譯
我們需要先安裝跨平臺構(gòu)建工具:xmake
$ xmake
運(yùn)行測試
你需要先安裝lua或者luajit程序去加載運(yùn)行測試程序:
$ xmake run test dialog $ xmake run test window $ xmake run test desktop $ xmake run test inputdialog $ xmake run test mconfdialog
或者
$ lua tests\dialog.lua $ lua tests\window.lua $ lua tests\desktop.lua $ lua tests\inputdialog.lua $ lua tests\mconfdialog.lua
或者
$ luajit tests\dialog.lua $ luajit tests\window.lua $ luajit tests\desktop.lua $ luajit tests\inputdialog.lua $ luajit tests\mconfdialog.lua
例子
應(yīng)用程序
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()
標(biāo)簽
local lab = label:new("title", rect {0, 0, 12, 1}, "hello ltui!"):textattr_set("white")
按鈕
local btn = button:new("yes", rect {0, 1, 7, 2}, "< Yes >"):textattr_set("white")
輸入框
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
組件
| 視圖 | 對話框 | 其他 |
|---|---|---|
| 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 |
快照
菜單配置
輸入框
文本區(qū)域
如果你想了解更多,請參考:
評論
圖片
表情
