Add tty_inkey(),tty_simple() and tty_subcmd_readln()

Add following functions to handle input from a thread that uses standard
input.

tty_inkey() waits for a key to be pressed for a specified amount of
time, and then returns the pressed string.

tty_simple_readln() reads user input until Enter is pressed.
It supports Backspace key.

tty_subcmd_readln() reads user input until Enter is pressed.
It supports line editing (cursor keys, Backspace) and command history.

The script REPL history buffer is now a dedicated history buffer instead
of the subcommand history buffer. REPL prompt changes from ">>" to "->".

Reduced the history buffer size from 1000 lines to 500 lines.
This commit is contained in:
yabu76 2026-04-04 16:17:14 +09:00
parent 9703c25503
commit c8df45ceff
4 changed files with 92 additions and 32 deletions

View file

@ -191,13 +191,13 @@ Example:
[10:17:30.215] Enter file name or "!" Lua commands or "@" interpreter directive:
>> @repl
[10:17:31.956] Enter Lua REPL mode (@exit to exit)
>> p=1
>> for i=1,10 do\
>> p = p * i\
>> end
>> print(p, "\r")
-> p=1
-> for i=1,10 do\
-> p = p * i\
-> end
-> print(p, "\r")
3628800
>> @exit
-> @exit
```
---