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 /system | |
parent | 8f8d34f03428dbaa6cac229bbe36efc6d80d186d (diff) | |
download | luasystem-56db1511baeb0376a12915c69c1552b04010c26f.zip |
cleanup and documentation
Diffstat (limited to 'system')
-rw-r--r-- | system/init.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/system/init.lua b/system/init.lua index b9a4f6f..8049167 100644 --- a/system/init.lua +++ b/system/init.lua @@ -7,7 +7,7 @@ local sys = require 'system.core' do local backup_mt = {} - --- Returns a backup of terminal setting for stdin/out/err. + --- Returns a backup of terminal settings for stdin/out/err. -- Handles terminal/console flags, Windows codepage, and non-block flags on the streams. -- Backs up terminal/console flags only if a stream is a tty. -- @return table with backup of terminal settings @@ -227,8 +227,11 @@ do -- This function uses `system.sleep` to wait until either a byte is available or the timeout is reached. -- The sleep period is exponentially backing off, starting at 0.0125 seconds, with a maximum of 0.2 seconds. -- It returns immediately if a byte is available or if `timeout` is less than or equal to `0`. + -- + -- Using `system.readansi` is preferred over this function. Since this function can leave stray/invalid + -- byte-sequences in the input buffer, while `system.readansi` reads full ANSI and UTF8 sequences. -- @tparam number timeout the timeout in seconds. - -- @treturn[1] integer the key code of the key that was received + -- @treturn[1] byte the byte value that was read. -- @treturn[2] nil if no key was read -- @treturn[2] string error message; `"timeout"` if the timeout was reached. function sys.readkey(timeout) |