aboutsummaryrefslogtreecommitdiff
path: root/examples/terminalsize.lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2024-05-23 20:46:18 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2024-05-23 20:57:20 +0200
commit56db1511baeb0376a12915c69c1552b04010c26f (patch)
treed03aa6b4c33a6de39371e9be336c471bfd2cafc5 /examples/terminalsize.lua
parent8f8d34f03428dbaa6cac229bbe36efc6d80d186d (diff)
downloadluasystem-56db1511baeb0376a12915c69c1552b04010c26f.tar.gz
luasystem-56db1511baeb0376a12915c69c1552b04010c26f.tar.bz2
luasystem-56db1511baeb0376a12915c69c1552b04010c26f.zip
cleanup and documentation
Diffstat (limited to 'examples/terminalsize.lua')
-rw-r--r--examples/terminalsize.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/terminalsize.lua b/examples/terminalsize.lua
index 78d1910..ed66792 100644
--- a/examples/terminalsize.lua
+++ b/examples/terminalsize.lua
@@ -26,11 +26,12 @@ end
26 26
27local w, h 27local w, h
28print("Change the terminal window size, press any key to exit") 28print("Change the terminal window size, press any key to exit")
29while not sys.readkey(0.2) do 29while not sys.readansi(0.2) do -- use readansi to not leave stray bytes in the input buffer
30 local nw, nh = sys.termsize() 30 local nw, nh = sys.termsize()
31 if w ~= nw or h ~= nh then 31 if w ~= nw or h ~= nh then
32 w, h = nw, nh 32 w, h = nw, nh
33 local text = "Terminal size: " .. w .. "x" .. h .. " " 33 local text = "Terminal size: " .. w .. "x" .. h .. " "
34 io.write(text .. cursor_move_horiz(-#text)) 34 io.write(text .. cursor_move_horiz(-#text))
35 io.flush()
35 end 36 end
36end 37end