diff options
Diffstat (limited to 'examples/terminalsize.lua')
-rw-r--r-- | examples/terminalsize.lua | 3 |
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 | ||
27 | local w, h | 27 | local w, h |
28 | print("Change the terminal window size, press any key to exit") | 28 | print("Change the terminal window size, press any key to exit") |
29 | while not sys.readkey(0.2) do | 29 | while 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 |
36 | end | 37 | end |