For some reason, termion
is not returning from next()
until [enter]
is pressed. By necessity, I need next()
to return after each key is pressed. Thus, I use raw mode, but it doesn't seem to work. Why might this be? Is this a termion bug?
fn spawn_input_listener(mut input_tx: tokio::sync::mpsc::Sender<String>, ctx: ConsoleContext) {
std::thread::spawn(move || {
let mut iter = std::io::stdin().events_and_raw();
loop {
while let Some(key) = iter.next() {
if let Ok(key) = key {
match key.0 {
termion::event::Event::Key(termion::event::Key::Backspace) => {
INPUT_ROUTER.backspace(&ctx)
}
termion::event::Event::Key(termion::event::Key::Char('\n')) => {
if !INPUT_ROUTER.send_internal_buffer(&mut input_tx) {
log::warn!("Error sending input. Closing program");
std::process::exit(-1);
}
}
termion::event::Event::Key(termion::event::Key::Char(val)) => {
INPUT_ROUTER.push(val);
}
_ => {}
}
}
}
}
});
}
Using Ubuntu/WSL