steer_tui/tui/handlers/
edit_selection.rs1use crate::error::Result;
2use crate::tui::Tui;
3use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
4
5impl Tui {
6 pub async fn handle_edit_selection_mode(&mut self, key: KeyEvent) -> Result<bool> {
7 match (key.code, key.modifiers) {
8 (KeyCode::Esc, _) | (KeyCode::Char('c' | 'd'), KeyModifiers::CONTROL) => {
9 self.input_mode = self.default_input_mode();
10 self.edit_selection_state.clear();
11 }
12 (KeyCode::Enter, _) => {
13 if let Some((message_id, _)) = self.edit_selection_state.get_selected().cloned() {
14 self.enter_edit_mode(&message_id);
15 self.edit_selection_state.clear();
16 }
17 }
18 (KeyCode::Up | KeyCode::Char('k'), _) => {
19 self.edit_selection_state.select_prev();
20 }
21 (KeyCode::Down | KeyCode::Char('j'), _) => {
22 self.edit_selection_state.select_next();
23 }
24 _ => {}
25 }
26 Ok(false)
27 }
28}