diff --git a/crates/pacdef_core/src/ui.rs b/crates/pacdef_core/src/ui.rs index 4280336..aa49762 100644 --- a/crates/pacdef_core/src/ui.rs +++ b/crates/pacdef_core/src/ui.rs @@ -15,6 +15,14 @@ pub fn get_user_confirmation() -> Result { Ok(reply.trim().is_empty() || reply.to_lowercase().contains('y')) } +/// Read a single byte from the stdin and interpret it as `char`. Use the +/// `termios` library to switch the terminal to raw mode before reading, +/// and restore the original terminal mode afterwards. +/// +/// # Errors +/// +/// This function will return an error if the data cannot be read or the +/// terminal settings cannot be changed. pub fn read_single_char_from_terminal() -> Result { // 0 is the file descriptor for stdin let fd = 0; @@ -32,6 +40,7 @@ pub fn read_single_char_from_terminal() -> Result { let result: char = input[0] .try_into() .context("reading a single byte from stdin")?; + // stdin is not echoed automatically in this terminal mode println!("{result}");