-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
62 lines (55 loc) · 1.76 KB
/
test.lua
File metadata and controls
62 lines (55 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env lua
--
-- This file contains a basic example of BTUI Lua usage.
--
local btui = require("btui")
btui(function(bt)
local key = nil
local x, y = 1, 1
while key ~= "q" and key ~= "Ctrl-c" do
if key == "?" then
bt:withdisabled(function()
io.write("Press enter to continue.")
io.flush()
io.read()
end)
elseif key == "Ctrl-z" then
bt:suspend()
end
bt:batch(function()
bt:clear()
bt:move(15, 15)
bt:withfg(.8,.95,.2, function()
bt:linebox(x, y, 30, 1);
bt:move(x, y)
bt:write("Pressed: ", key)
end)
local title = "Lua BTUI Demo"
local w = #title
local center = math.floor((bt:width() - w) / 2)
bt:withattributes("fg_blue", "bg_normal", function()
bt:shadow(center-2, 0, w+4, 3)
end)
bt:withattributes("bg_blue", "fg_black", function()
bt:fillbox(center-2, 0, w+4, 3)
bt:move(center, 1)
bt:write(title)
end)
bt:withattributes("bold", function()
bt:move(0, bt:height()-1)
bt:write("Press 'q' to quit")
end)
bt:withattributes("faint", function()
local s = ("Size: (%dx%d)"):format(bt:width(), bt:height())
bt:move(bt:width()-#s, bt:height()-1)
bt:write(s)
end)
end)
local mouse_x, mouse_y
key, mouse_x, mouse_y = bt:getkey()
if mouse_x then x, y = mouse_x, mouse_y end
end
if key == "Ctrl-c" then
error("Interrupt received!")
end
end)