激情六月丁香婷婷|亚洲色图AV二区|丝袜AV日韩AV|久草视频在线分类|伊人九九精品视频|国产精品一级电影|久草视频在线99|在线看的av网址|伊人99精品无码|午夜无码视频在线

高校合作1:010-59833514 ?咨詢電話:400-810-1418 服務(wù)與監(jiān)督電話:400-810-1418轉(zhuǎn)接2

LTUI v1.7 發(fā)布,一個(gè)基于 Lua 的跨平臺(tái)字符終端 UI 界面庫(kù)

發(fā)布時(shí)間:2024-01-04 19:55:11 瀏覽量:165次

簡(jiǎn)介

LTUI是一個(gè)基于lua的跨平臺(tái)字符終端UI界面庫(kù)。

此框架源于xmake中圖形化菜單配置的需求,類似linux kernel的menuconf去配置編譯參數(shù),因此基于curses和lua實(shí)現(xiàn)了一整套跨平臺(tái)的字符終端ui庫(kù)。 而樣式風(fēng)格基本上完全參照的kconfig-frontends,當(dāng)然用戶也可以自己定制不同的ui風(fēng)格。

另外,LTUI是完全跨平臺(tái)的,windows上的terminal終端也是完全支持的,在windows上ltui會(huì)采用pdcurses來進(jìn)行窗口繪制。

  • Github

更新內(nèi)容

然而之前的版本,并不支持布局隨終端窗口的大小調(diào)整,來自動(dòng)調(diào)整布局,如果窗口變大,那邊整個(gè)視圖還是會(huì)保留原有的大小。 而在當(dāng)前v1.7版本中,我進(jìn)行了局部重構(gòu),來支持窗口Resize,以及所有views布局的自適應(yīng)調(diào)整。

之前的版本:

新版本的效果:

安裝使用

$ luarocks install ltui

如果要運(yùn)行自帶的測(cè)試,你需要先安裝lua或者luajit程序去加載運(yùn)行l(wèi)tui源碼倉(cāng)庫(kù)中的測(cè)試程序:

$ 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

源碼編譯

通常只要luarocks安裝好后就可以使用,如果想要本地調(diào)試,也可以源碼編譯后直接運(yùn)行測(cè)試,首先我們需要先安裝跨平臺(tái)構(gòu)建工具:xmake

$ xmake

xmake會(huì)自動(dòng)下載lua, ncurses等相關(guān)依賴,然后我們直接通過xmake run加載相關(guān)測(cè)試程序即可:

$ xmake run test dialog
$ xmake run test window
$ xmake run test desktop
$ xmake run test inputdialog
$ xmake run test mconfdialog

應(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

組件

菜單配置

輸入框

文本區(qū)域

Windows平臺(tái)

熱門課程推薦

熱門資訊

請(qǐng)綁定手機(jī)號(hào)

x

同學(xué)您好!

您已成功報(bào)名0元試學(xué)活動(dòng),老師會(huì)在第一時(shí)間與您取得聯(lián)系,請(qǐng)保持電話暢通!
確定