From 88ac69f94ddbe172458c79f2a5e37b6704c606a2 Mon Sep 17 00:00:00 2001
From: Thijs Schreijer "char"
for a single key, "ansi"
for an ANSI sequence"ctrl"
for 0-31 and 127 bytes, "char"
for other UTF-8 characters, "ansi"
for an ANSI sequence
Or
@@ -1070,6 +1070,15 @@ sequences will be buffered internally and returned one byte at a time.
+
Usage:
+
+
local key, keytype = system.readansi(5)
+if keytype == "char" then ... end -- printable character
+if keytype ~= "char" then ... end -- non-printable character or sequence
+if keytype == "ansi" then ... end -- a multi-byte sequence, but not a UTF8 character
+if keytype ~= "ansi" then ... end -- a valid UTF8 character (which includes control characters)
+if keytype == "ctrl" then ... end -- a single-byte ctrl character (0-31, 127)
+
fsleep
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.
+ The sleep period is exponentially backing off, starting at 0.0125 seconds, with a maximum of 0.1 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 @@ -1509,7 +1518,7 @@ This function will sleep, without doing a busy-loop and wasting CPU cycles.