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.lock | |
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.lock')
-rw-r--r-- | Cargo.lock | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -8,13 +8,14 @@ version = "0.0.1" dependencies = [ "libc", "signal-hook", + "termios", ] [[package]] name = "libc" -version = "0.2.153" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "signal-hook" @@ -28,9 +29,18 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "termios" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" dependencies = [ "libc", ] |