wpaulino · GitHub

and others added 10 commits

August 11, 2024 22:53
This is a refactor that prepares us for grouping all terminal/tty
related logic within a struct.
This will allow us to intercept input events to perform actions once
triggered. For now, we just handle the existing capabilities of the
REPL, which include appending and deleting characters from the prompt.
Raw input mode is widely supported across terminals, though its
activation requires different APIs in Windows vs POSIX-compliant
systems. We opt to only enter this mode when being prompted for a
command. Once a command is being executed, we revert back to the
starting input mode that was present when the application was started.
As user inputs are being provided in this mode, we need to accurately
track the terminal's size and cursor position to handle certain complex
use-cases (i.e., inserting/deleting a character in the middle of the
prompt buffer, navigating through the command history, etc.).
Now that the cursor is no longer assumed to be at the end of the prompt,
we must handle the user inserting or deleting a character in the middle
of the buffer.
This allows users to cancel their current prompt without attempting to
parse it as a command. EOF is still needed to exit the REPL cleanly
while at the prompt.
Ctrl-C can still be used to kill the application when not in prompt mode
in the event of a hang/slow request.
…ovements
…ovements-static

@brson

batiati

Co-authored-by: Rafael Batiati <rbatiati@gmail.com>

@brson

@brson

batiati

@brson

@brson

brson deleted the interactive-repl-improvements-static branch

November 15, 2024 23:52

@brson brson mentioned this pull request

Nov 15, 2024

Merged

@brson brson mentioned this pull request

Feb 4, 2025

Open

Read the original on github.com ↗