基于 Lua 的跨平台字符终端 UI 界面库 LTUI

码农软件 · 软件分类 · GUI开发框架 · 2019-08-07 16:11:27

软件介绍

简介

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

此框架源于xmake中图形化菜单配置的需求,类似linux kernel的menuconf去配置编译参数,因此基于curses和lua实现了一整套跨平台的字符终端ui库。 而样式风格基本上完全参照的kconfig-frontends,当然用户也可以自己定制不同的ui风格。

安装

$ luarocks install ltui

编译

我们需要先安装跨平台构建工具:xmake

$ xmake

运行测试

你需要先安装lua或者luajit程序去加载运行测试程序:

$ 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

例子

应用程序

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

标签

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

组件

视图对话框其他
viewdialogevent
panelboxdialogaction
labeltextdialogcanvas
buttoninputdialogcurses
bordermconfdialogprogram
windowchoicedialogapplication
menubar point
menuconf rect
textedit object
textarea  
statusbar  
choicebox  
desktop  

快照

菜单配置

输入框

文本区域

如果你想了解更多,请参考:

本文地址:https://www.codercto.com/soft/d/11853.html

算法谜题

算法谜题

Anany Levitin、Maria Levitin / 赵勇、徐章宁、高博 / 人民邮电出版社 / 2014-1-1

算法是计算机科学领域最重要的基石之一。算法谜题,就是能够直接或间接地采用算法来加以解决的谜题。求解算法谜题是培养和锻炼算法思维能力一种最有效和最有乐趣的途径。 本书是一本经典算法谜题的合集。本书包括了一些古已有之的谜题,数学和计算机科学有一部分知识就发源于此。本书中还有一些较新的谜题,其中有一部分谜题被用作知名IT企业的面试题。全书可分为4个部分,分别是概览、谜题、提示和答案。概览介绍了算法......一起来看看 《算法谜题》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具