From 350be1b8869ce9d3a572348104c30f804d44641e Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Mon, 30 Sep 2024 21:55:32 -0600 Subject: 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 and 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). Signed-off-by: Rory Dudley --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'Cargo.toml') diff --git a/Cargo.toml b/Cargo.toml index 8baea37..93c090a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ path = "src/main.rs" [dependencies] libc = "0.2.153" signal-hook = "0.3.17" +termios = "0.3.3" -- cgit v1.2.3