diff options
author | Rory Dudley | 2024-08-24 16:06:23 -0600 |
---|---|---|
committer | Rory Dudley | 2024-08-24 16:06:23 -0600 |
commit | 3c3cea0c7c494c998f05f21317a7c1bfa078a80e (patch) | |
tree | 0ff5661646e86d5c88463743fe96c102d9590f2d /Cargo.toml | |
parent | 6328666624e59574946f7af1570c5676aa54d0ac (diff) | |
download | dwarvish-3c3cea0c7c494c998f05f21317a7c1bfa078a80e.tar.gz |
Replace io::stdin().read_line() with custom function
Added the termios crate to facilitate the changing of certain terminal
options. It is a wrapper around the termios C library, so 'man 3
termios' for more details.
Added the custom getchar() function, with retrieves characters from
STDIN as they are typed by the user (as opposed to waiting for a
newline, like io::stdin().read_line()). This is necessary, since keys
like <tab> and <up> have special functionality, which needs to be acted
on before command submission.
Added the custom getline() function, which uses getchar() to read
characters as they are typed. The getline() function contains the logic
for the various key presses. For most characters, we simply push the
byte to a buffer, and print it out to the screen (since getline()
assumes ECHO is off).
Notes
Notes:
For now, <tab> autocomplete is not finished, so hitting the tab key only
replaces the tabs with spaces in the inbut buffer. Also, some edge cases
are unhandled in getline(). For instance, using the arrow keys appears
to move the cursor keys. The parser gets upset when you move the cursor
then try to submit a command, so this needs to be fixed.
Diffstat (limited to 'Cargo.toml')
-rw-r--r-- | Cargo.toml | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -15,3 +15,4 @@ path = "src/main.rs" [dependencies] libc = "0.2.153" signal-hook = "0.3.17" +termios = "0.3.3" |