diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-23 20:46:18 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-23 20:57:20 +0200 |
| commit | 56db1511baeb0376a12915c69c1552b04010c26f (patch) | |
| tree | d03aa6b4c33a6de39371e9be336c471bfd2cafc5 /examples/terminalsize.lua | |
| parent | 8f8d34f03428dbaa6cac229bbe36efc6d80d186d (diff) | |
| download | luasystem-56db1511baeb0376a12915c69c1552b04010c26f.tar.gz luasystem-56db1511baeb0376a12915c69c1552b04010c26f.tar.bz2 luasystem-56db1511baeb0376a12915c69c1552b04010c26f.zip | |
cleanup and documentation
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 |
