From b2a9b6df36732b07fa0e35b373b1c2d94dcd23a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sun, 9 Nov 2025 06:53:19 +0100 Subject: [PATCH] Simplify keyboard handling and increase poll timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed complex signal handling that wasn't working reliably. Now using simpler event polling with 10ms timeout instead of 0ms, which allows keyboard events to be properly detected. Exit methods: - Press 'q' (most reliable) - Press ESC - Ctrl+C (with 10ms poll window) - Ctrl+D (alternative) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/animation/renderer.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/animation/renderer.rs b/src/animation/renderer.rs index 91535e1..13648d0 100644 --- a/src/animation/renderer.rs +++ b/src/animation/renderer.rs @@ -36,31 +36,23 @@ impl<'a> Renderer<'a> { let mut timeline = Timeline::new(self.timeline.duration_ms(), self.timeline.fps()); timeline.start(); - // Setup Ctrl+C handler - let mut sigint = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::interrupt())?; - loop { let frame_start = std::time::Instant::now(); - // Check for keyboard input (Ctrl+C, q, or ESC to exit) - if event::poll(Duration::from_millis(0))? { - if let Event::Key(key) = event::read()? { - match key.code { + // Check for keyboard input with a small timeout + // In raw mode, Ctrl+C comes through as a key event + if event::poll(Duration::from_millis(10))? { + match event::read()? { + Event::Key(key) => match key.code { KeyCode::Char('q') | KeyCode::Esc => break, KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => break, + KeyCode::Char('d') if key.modifiers.contains(KeyModifiers::CONTROL) => break, _ => {} - } + }, + _ => {} } } - // Also check for SIGINT - tokio::select! { - _ = sigint.recv() => { - break; - } - _ = tokio::time::sleep(Duration::from_millis(0)) => {} - } - // Calculate progress with easing let linear_progress = timeline.progress(); let eased_progress = self.easing.ease(linear_progress);