diff --git a/src/tty/unix.rs b/src/tty/unix.rs index 6c42f9cf3363315d010f73c292d654e81f2fb276..2427848a9a5e57b9c1b2b3e5ab94e3d36f7f17e7 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -4,7 +4,6 @@ use std::sync; use std::sync::atomic; use libc; use nix; -use nix::poll; use nix::sys::signal; use nix::sys::termios; @@ -208,28 +207,13 @@ impl RawReader for PosixRawReader { // As there is no read timeout to properly handle single ESC key, // we make possible to deactivate escape sequence processing. fn next_key(&mut self, esc_seq: bool) -> Result<KeyPress> { + // FIXME Stdin is buffered, so polling after reading an ESC char is useless (next available chars are already buffered)... let c = try!(self.next_char()); let mut key = consts::char_to_key_press(c); - if key == KeyPress::Esc { - if esc_seq { - // escape sequence - key = try!(self.escape_sequence()); - } else { - let mut fds = - [poll::PollFd::new(STDIN_FILENO, poll::POLLIN, poll::EventFlags::empty())]; - match poll::poll(&mut fds, 500) { - Ok(n) if n == 0 => { - // single escape - } - Ok(_) => { - // escape sequence - key = try!(self.escape_sequence()) - } - // Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, - Err(e) => return Err(e.into()), - } - } + if key == KeyPress::Esc && esc_seq { + // escape sequence + key = try!(self.escape_sequence()); } Ok(key) }