diff options
Diffstat (limited to 'src/term.rs')
| -rw-r--r-- | src/term.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/term.rs b/src/term.rs index 33d9d7c..d77a8f6 100644 --- a/src/term.rs +++ b/src/term.rs @@ -109,6 +109,12 @@ pub fn read_key(stdin: &mut BufReader<Stdin>) -> Result<Key, Box<dyn Error>> { // cursor_pos *WILL* fail if the user is typing on the keyboard. Be sure to handle // errors appropriately. pub fn cursor_pos(stdin: &mut BufReader<Stdin>) -> Result<(u16, u16), Box<dyn Error>> { + let buf = stdin.fill_buf()?; + if buf.len() > 0 { + // If there is any buffered input, the below call to fill_buf will just return the buffered + // data and not actually read the terminal response. + return Err(Box::from("interrupted")); + } write!(stdout(), "\x1b[6n")?; stdout().flush()?; let buf = stdin.fill_buf()?; |
