diff --git a/README.md b/README.md index d4e28ea..6376826 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,18 @@ LTUI is a cross-platform terminal ui library based on Lua. +## Build + +We need install the cross-platform build utility [xmake](https://github.com/tboox/xmake) first. + +```console +$ xmake +``` + ## Examples +#### Window + ```lua -- requires local ltui = require("ltui") @@ -61,6 +71,42 @@ end demo:run() ``` +#### Input dialog + +```lua +-- requires +local ltui = require("ltui") +local label = ltui.label +local button = ltui.button +local application = ltui.application +local event = ltui.event +local rect = ltui.rect +local inputdialog = ltui.inputdialog + +-- the demo application +local demo = application() + +-- init demo +function demo:init() + + -- init name + application.init(self, "demo") + + -- init background + self:background_set("blue") + + -- init input dialog + 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 + +-- run demo +demo:run() +``` + ## Snapshot #### Menu configuation diff --git a/README_zh.md b/README_zh.md index d003cfc..b2a5939 100644 --- a/README_zh.md +++ b/README_zh.md @@ -32,8 +32,18 @@ LTUI是一个基于lua的跨平台字符终端UI界面库。 +## 编译 + +我们需要先安装跨平台构建工具:[xmake](https://github.com/tboox/xmake) + +```console +$ xmake +``` + ## 例子 +#### 窗口 + ```lua -- requires local ltui = require("ltui") @@ -62,6 +72,42 @@ end demo:run() ``` +#### 输入框 + +```lua +-- requires +local ltui = require("ltui") +local label = ltui.label +local button = ltui.button +local application = ltui.application +local event = ltui.event +local rect = ltui.rect +local inputdialog = ltui.inputdialog + +-- the demo application +local demo = application() + +-- init demo +function demo:init() + + -- init name + application.init(self, "demo") + + -- init background + self:background_set("blue") + + -- init input dialog + 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 + +-- run demo +demo:run() +``` + ## 快照 #### 菜单配置