diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-06-08 09:28:20 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-06-08 09:28:20 +0200 |
commit | 8996a5022fa82e5d5335f71580d0cd6b6d323c9b (patch) | |
tree | aac6b6a015cf06aad845627f51b739fe58f85166 /examples | |
parent | 52562e9986f8f5a4d2dda4333acba110734def0f (diff) | |
download | luasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.tar.gz luasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.tar.bz2 luasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.zip |
switch termsize results to standard; rows, cols
Diffstat (limited to 'examples')
-rw-r--r-- | examples/terminalsize.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/terminalsize.lua b/examples/terminalsize.lua index ed66792..105a415 100644 --- a/examples/terminalsize.lua +++ b/examples/terminalsize.lua | |||
@@ -24,13 +24,13 @@ local function cursor_move_horiz(n) | |||
24 | end | 24 | end |
25 | 25 | ||
26 | 26 | ||
27 | local w, h | 27 | local rows, cols |
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.readansi(0.2) do -- use readansi to not leave stray bytes in the input buffer | 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 nrows, ncols = sys.termsize() |
31 | if w ~= nw or h ~= nh then | 31 | if rows ~= nrows or cols ~= ncols then |
32 | w, h = nw, nh | 32 | rows, cols = nrows, ncols |
33 | local text = "Terminal size: " .. w .. "x" .. h .. " " | 33 | local text = "Terminal size: " .. rows .. "x" .. cols .. " " |
34 | io.write(text .. cursor_move_horiz(-#text)) | 34 | io.write(text .. cursor_move_horiz(-#text)) |
35 | io.flush() | 35 | io.flush() |
36 | end | 36 | end |