(&mut self, key: KeyEvent)
| 1019 | } |
| 1020 | |
| 1021 | fn handle_dialog_key(&mut self, key: KeyEvent) -> anyhow::Result<bool> { |
| 1022 | if self.alert_dialog.is_open() { |
| 1023 | match key.code { |
| 1024 | KeyCode::Esc | KeyCode::Enter => { |
| 1025 | self.alert_dialog.close(); |
| 1026 | } |
| 1027 | KeyCode::Char('c') |
| 1028 | if key.modifiers.contains(KeyModifiers::CONTROL) |
| 1029 | && !self.alert_dialog.message().is_empty() => |
| 1030 | { |
| 1031 | let _ = Clipboard::write_text(self.alert_dialog.message()); |
| 1032 | } |
| 1033 | _ => {} |
| 1034 | } |
| 1035 | return Ok(true); |
| 1036 | } |
| 1037 | if self.help_dialog.is_open() { |
| 1038 | if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { |
| 1039 | self.help_dialog.close(); |
| 1040 | } |
| 1041 | return Ok(true); |
| 1042 | } |
| 1043 | if self.status_dialog.is_open() { |
| 1044 | if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { |
| 1045 | self.status_dialog.close(); |
| 1046 | } |
| 1047 | return Ok(true); |
| 1048 | } |
| 1049 | if self.session_rename_dialog.is_open() { |
| 1050 | match key.code { |
| 1051 | KeyCode::Esc => self.session_rename_dialog.close(), |
| 1052 | KeyCode::Backspace => self.session_rename_dialog.handle_backspace(), |
| 1053 | KeyCode::Enter => { |
| 1054 | if let Some((session_id, title)) = self.session_rename_dialog.confirm() { |
| 1055 | if let Some(client) = self.context.get_api_client() { |
| 1056 | if let Err(err) = client.update_session_title(&session_id, &title) { |
| 1057 | self.alert_dialog.set_message(&format!( |
| 1058 | "Failed to rename session `{}`:\n{}", |
| 1059 | session_id, err |
| 1060 | )); |
| 1061 | self.alert_dialog.open(); |
| 1062 | } else { |
| 1063 | self.refresh_session_list_dialog(); |
| 1064 | let _ = self.sync_session_from_server(&session_id); |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | KeyCode::Char(c) |
| 1070 | if !key.modifiers.contains(KeyModifiers::CONTROL) |
| 1071 | && !key.modifiers.contains(KeyModifiers::ALT) => |
| 1072 | { |
| 1073 | self.session_rename_dialog.handle_input(c); |
| 1074 | } |
| 1075 | _ => {} |
| 1076 | } |
| 1077 | return Ok(true); |
| 1078 | } |
no test coverage detected