From 637559e7ee2f5873800639a734795136601b819b Mon Sep 17 00:00:00 2001 From: Ed Swartz <875407+eswartz@users.noreply.github.com> Date: Sat, 8 Aug 2026 20:59:53 -0500 Subject: [PATCH] Use `crossterm::event::poll` to avoid blank screen between choices. --- examples/yarnspinner_without_bevy/src/terminal.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/yarnspinner_without_bevy/src/terminal.rs b/examples/yarnspinner_without_bevy/src/terminal.rs index 1f8edb66..67e86f9b 100644 --- a/examples/yarnspinner_without_bevy/src/terminal.rs +++ b/examples/yarnspinner_without_bevy/src/terminal.rs @@ -1,7 +1,7 @@ //! This module is here for using ratatui to interact with the terminal and //! crossterm to listen to input. It does not contain any code specific to yarnspinner -use std::io::Stdout; +use std::{io::Stdout, time::Duration}; use crossterm::event::{Event, KeyCode, KeyEventKind}; use ratatui::backend::CrosstermBackend; @@ -35,7 +35,8 @@ pub fn set_panic_hook() { } pub fn poll_input() -> anyhow::Result> { - if let Event::Key(key) = crossterm::event::read()? + if crossterm::event::poll(Duration::from_millis(100))? + && let Event::Key(key) = crossterm::event::read()? && key.kind == KeyEventKind::Press { return Ok(Some(key.code));