Skip to main content

steer_tui/tui/handlers/
confirm_exit.rs

1use crate::error::Result;
2use crate::tui::Tui;
3use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
4
5impl Tui {
6    pub async fn handle_confirm_exit_mode(&mut self, key: KeyEvent) -> Result<bool> {
7        match key.code {
8            KeyCode::Char('y' | 'Y') => {
9                // User confirmed exit
10                return Ok(true);
11            }
12            KeyCode::Char('c' | 'd') if key.modifiers.contains(KeyModifiers::CONTROL) => {
13                // Ctrl+C/Ctrl+D again also confirms exit
14                return Ok(true);
15            }
16            _ => {
17                // Any other key cancels exit and returns to normal mode
18                self.input_mode = self.default_input_mode();
19            }
20        }
21        Ok(false)
22    }
23}