add examples
This commit is contained in:
46
README.md
46
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
|
||||
|
Reference in New Issue
Block a user