日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

lua运行外部程序_LTUI v2.2 发布, 一个基于lua的跨平台字符终端UI界面库

發布時間:2023/12/19 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lua运行外部程序_LTUI v2.2 发布, 一个基于lua的跨平台字符终端UI界面库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

LTUI是一個基于lua的跨平臺字符終端UI界面庫。

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

另外,LTUI是完全跨平臺的,windows上的terminal終端也是完全支持的,在windows上ltui會采用pdcurses來進行窗口繪制。

  • Github

更新內容

新版本中,我們主要增加了對鼠標事件的支持,除了 curses/ncurses,我們還對 windows 上 pdcurses 也做了支持,這里我們非常感謝 @laelnasan 貢獻。

另外我們新增一個 tests/events.lua 測試用例,專門用來測試各種輸入事件。

$ xmake run test events

我們可以通過這個測試例子,獲取并顯示用戶的所有鼠標輸入事件。

我們可以在自定義的view上,重寫on_event來獲取所有事件輸入,包括所有的鼠標輸入事件:

local demo = application()function demo:init()application.init(self, "demo")self:background_set("black") endfunction demo:on_event(e)if e.type == "btn_code" thenprint(e.btn_name, e.x, e.y)endapplication.on_event(self, e) enddemo:run()

安裝使用

$ luarocks install ltui

如果要運行自帶的測試,你需要先安裝lua或者luajit程序去加載運行ltui源碼倉庫中的測試程序:

$ 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安裝好后就可以使用,如果想要本地調試,也可以源碼編譯后直接運行測試,首先我們需要先安裝跨平臺構建工具:xmake

$ xmake

xmake會自動下載lua, ncurses等相關依賴,然后我們直接通過xmake run加載相關測試程序即可:

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

應用程序

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)) enddemo:run()

標簽

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

組件

菜單配置

輸入框

文本區域

Windows

Termux

總結

以上是生活随笔為你收集整理的lua运行外部程序_LTUI v2.2 发布, 一个基于lua的跨平台字符终端UI界面库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。