autexousious
autexousious copied to clipboard
Shell input improvement
In GitLab by @azriel91 on Mar 30, 2019, 13:55
At the time of writing, the input-handling
branch of crossterm
is in the works to provide an abstraction to make it easy to handle multi-line input.
We want to replace the ion
copy and paste solution with this, so we don't have "it works when it works, but is difficult to understand what's wrong when you make a mistake".
Original problem: Reading multiple inputs per frame
In order to read multiple inputs per frame, we had to choose from:
- Modify command to take in args for multiple events + change
StdinMapper
to read multiple events as return value. - Have a
CommandSet
StdinCommand
, which indicates the number of commands to keep reading inStdinSystem
and keep sending. - Figure out how to parse connectors in input.
We went with the last option, copying code from the ion
shell. A side effect of this change is, we need to insert "#" instead of use blank lines to indicate "no input this frame", because:
-
StdinReader
reads everything from stdin really quickly, sending it to the channel. -
StdinSystem
reads and sends one "command chain" eachdispatcher.update()
- Blank lines no longer mean "nothing happened", but "just whitespace in the file".
- The "#" indicates "nothing happened this frame".