diff options
Diffstat (limited to '')
-rw-r--r-- | docs/modules/system.html | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/docs/modules/system.html b/docs/modules/system.html index 6840b85..0a2447e 100644 --- a/docs/modules/system.html +++ b/docs/modules/system.html | |||
@@ -1051,7 +1051,7 @@ sequences will be buffered internally and returned one byte at a time. | |||
1051 | the character that was received (can be multi-byte), or a complete ANSI sequence</li> | 1051 | the character that was received (can be multi-byte), or a complete ANSI sequence</li> |
1052 | <li> | 1052 | <li> |
1053 | <span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span> | 1053 | <span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span> |
1054 | the type of input: <code>"char"</code> for a single key, <code>"ansi"</code> for an ANSI sequence</li> | 1054 | the type of input: <code>"ctrl"</code> for 0-31 and 127 bytes, <code>"char"</code> for other UTF-8 characters, <code>"ansi"</code> for an ANSI sequence</li> |
1055 | </ol> | 1055 | </ol> |
1056 | <h3>Or</h3> | 1056 | <h3>Or</h3> |
1057 | <ol> | 1057 | <ol> |
@@ -1070,6 +1070,15 @@ sequences will be buffered internally and returned one byte at a time. | |||
1070 | 1070 | ||
1071 | 1071 | ||
1072 | 1072 | ||
1073 | <h3>Usage:</h3> | ||
1074 | <ul> | ||
1075 | <pre class="example"><span class="keyword">local</span> key, keytype = system.<span class="function-name">readansi</span>(<span class="number">5</span>) | ||
1076 | <span class="keyword">if</span> keytype == <span class="string">"char"</span> <span class="keyword">then</span> ... <span class="keyword">end</span> <span class="comment">-- printable character | ||
1077 | </span><span class="keyword">if</span> keytype ~= <span class="string">"char"</span> <span class="keyword">then</span> ... <span class="keyword">end</span> <span class="comment">-- non-printable character or sequence | ||
1078 | </span><span class="keyword">if</span> keytype == <span class="string">"ansi"</span> <span class="keyword">then</span> ... <span class="keyword">end</span> <span class="comment">-- a multi-byte sequence, but not a UTF8 character | ||
1079 | </span><span class="keyword">if</span> keytype ~= <span class="string">"ansi"</span> <span class="keyword">then</span> ... <span class="keyword">end</span> <span class="comment">-- a valid UTF8 character (which includes control characters) | ||
1080 | </span><span class="keyword">if</span> keytype == <span class="string">"ctrl"</span> <span class="keyword">then</span> ... <span class="keyword">end</span> <span class="comment">-- a single-byte ctrl character (0-31, 127)</span></pre> | ||
1081 | </ul> | ||
1073 | 1082 | ||
1074 | </dd> | 1083 | </dd> |
1075 | <dt> | 1084 | <dt> |
@@ -1079,7 +1088,7 @@ sequences will be buffered internally and returned one byte at a time. | |||
1079 | <dd> | 1088 | <dd> |
1080 | Reads a single byte from the console, with a timeout. | 1089 | Reads a single byte from the console, with a timeout. |
1081 | This function uses <code>fsleep</code> to wait until either a byte is available or the timeout is reached. | 1090 | This function uses <code>fsleep</code> to wait until either a byte is available or the timeout is reached. |
1082 | The sleep period is exponentially backing off, starting at 0.0125 seconds, with a maximum of 0.2 seconds. | 1091 | The sleep period is exponentially backing off, starting at 0.0125 seconds, with a maximum of 0.1 seconds. |
1083 | It returns immediately if a byte is available or if <code>timeout</code> is less than or equal to <code>0</code>.</p> | 1092 | It returns immediately if a byte is available or if <code>timeout</code> is less than or equal to <code>0</code>.</p> |
1084 | 1093 | ||
1085 | <p> Using <a href="../modules/system.html#readansi">system.readansi</a> is preferred over this function. Since this function can leave stray/invalid | 1094 | <p> Using <a href="../modules/system.html#readansi">system.readansi</a> 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. | |||
1509 | </div> <!-- id="main" --> | 1518 | </div> <!-- id="main" --> |
1510 | <div id="about"> | 1519 | <div id="about"> |
1511 | <i>generated by <a href="http://github.com/lunarmodules/LDoc">LDoc 1.5.0</a></i> | 1520 | <i>generated by <a href="http://github.com/lunarmodules/LDoc">LDoc 1.5.0</a></i> |
1512 | <i style="float:right;">Last updated 2025-04-17 09:50:39 </i> | 1521 | <i style="float:right;">Last updated 2025-07-11 22:55:05 </i> |
1513 | </div> <!-- id="about" --> | 1522 | </div> <!-- id="about" --> |
1514 | </div> <!-- id="container" --> | 1523 | </div> <!-- id="container" --> |
1515 | </body> | 1524 | </body> |