LTUI v2.4 发布, 一个基于lua的跨平台字符终端UI界面库

ltui是一个基于lua的跨平台字符终端ui界面库。

该框架最初源于xmake中图形化菜单配置的需求,类似于Linux内核的menuconfig,用于配置编译参数。因此,我们基于curses和Lua实现了一整套跨平台的字符终端UI库。其样式风格基本完全参照了kconfig-frontends,当然用户也可以自行定制不同的UI风格。

此外,LTUI是完全跨平台的,Windows上的Terminal终端也完全支持。在Windows上,LTUI会采用PDCurses进行窗口绘制。

在GitHub上的新版本更新中,我们改进了对鼠标的支持,实现了对所有控件的鼠标事件点击响应,这里我们非常感谢@laelnasan的贡献。

此外,我们还新增了一个scrollbar组件,用于支持滚动,并且我们还对choicebox和menuconf组件增加了滚动支持。

choicebox滚动支持 LTUI v2.4 发布, 一个基于lua的跨平台字符终端UI界面库menuconf滚动支持 LTUI v2.4 发布, 一个基于lua的跨平台字符终端UI界面库

安装和使用要安装LTUI,可以使用以下命令:

$ 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:

$ 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

应用程序示例以下是一个简单的LTUI应用程序示例:

local ltui        = require("ltui")local application = ltui.applicationlocal event       = ltui.eventlocal rect        = ltui.rectlocal 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()

标签示例以下是一个标签的示例代码:

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}, ""):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", "", function (v) dialog_input:quit() end)dialog_input:button_add("yes", "", function (v) dialog_input:quit() end)self:insert(dialog_input, {centerx = true, centery = true})end

以上就是LTUI v2.4 发布, 一个基于lua的跨平台字符终端UI界面库的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/167573.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
王者荣耀国际服充值教程
上一篇 2026年8月27日 19:23:59
红米note10怎么开启5g_红米note10开启5g的方法
下一篇 2026年8月27日 19:28:08

相关推荐

发表回复

登录后才能评论
关注微信