3 -- This file contains a basic example of BTUI Lua usage.
5 local btui = require("btui")
10 while key ~= "q" and key ~= "Ctrl-c" do
12 bt:withdisabled(function()
13 io.write("Press enter to continue.")
17 elseif key == "Ctrl-z" then
23 bt:withfg(.8,.95,.2, function()
24 bt:linebox(x, y, 30, 1);
26 bt:write("Pressed: ", key)
29 local title = "Lua BTUI Demo"
31 local center = math.floor((bt:width() - w) / 2)
32 bt:withattributes("fg_blue", "bg_normal", function()
33 bt:shadow(center-2, 0, w+4, 3)
35 bt:withattributes("bg_blue", "fg_black", function()
36 bt:fillbox(center-2, 0, w+4, 3)
41 bt:withattributes("bold", function()
42 bt:move(0, bt:height()-1)
43 bt:write("Press 'q' to quit")
46 bt:withattributes("faint", function()
47 local s = ("Size: (%dx%d)"):format(bt:width(), bt:height())
48 bt:move(bt:width()-#s, bt:height()-1)
52 local mouse_x, mouse_y
53 key, mouse_x, mouse_y = bt:getkey()
54 if mouse_x then x, y = mouse_x, mouse_y end
56 if key == "Ctrl-c" then
57 error("Interrupt received!")