Handle Ctrl+C quit when idle (#1402)
## Summary - show `Ctrl+C to quit` hint when pressing Ctrl+C with no active task - exiting with Ctrl+C if the hint is already visible - clear the hint when tasks begin or other keys are pressed https://github.com/user-attachments/assets/931e2d7c-1c80-4b45-9908-d119f74df23c ------ https://chatgpt.com/s/cd_685ec8875a308191beaa95886dc1379e Fixes #1245
This commit is contained in:
@@ -38,6 +38,7 @@ pub(crate) struct ChatComposer<'a> {
|
||||
command_popup: Option<CommandPopup>,
|
||||
app_event_tx: AppEventSender,
|
||||
history: ChatComposerHistory,
|
||||
ctrl_c_quit_hint: bool,
|
||||
}
|
||||
|
||||
impl ChatComposer<'_> {
|
||||
@@ -51,6 +52,7 @@ impl ChatComposer<'_> {
|
||||
command_popup: None,
|
||||
app_event_tx,
|
||||
history: ChatComposerHistory::new(),
|
||||
ctrl_c_quit_hint: false,
|
||||
};
|
||||
this.update_border(has_input_focus);
|
||||
this
|
||||
@@ -114,6 +116,11 @@ impl ChatComposer<'_> {
|
||||
self.update_border(has_focus);
|
||||
}
|
||||
|
||||
pub fn set_ctrl_c_quit_hint(&mut self, show: bool, has_focus: bool) {
|
||||
self.ctrl_c_quit_hint = show;
|
||||
self.update_border(has_focus);
|
||||
}
|
||||
|
||||
/// Handle a key event coming from the main UI.
|
||||
pub fn handle_key_event(&mut self, key_event: KeyEvent) -> (InputResult, bool) {
|
||||
let result = match self.command_popup {
|
||||
@@ -304,10 +311,17 @@ impl ChatComposer<'_> {
|
||||
}
|
||||
|
||||
let bs = if has_focus {
|
||||
BlockState {
|
||||
right_title: Line::from("Enter to send | Ctrl+D to quit | Ctrl+J for newline")
|
||||
.alignment(Alignment::Right),
|
||||
border_style: Style::default(),
|
||||
if self.ctrl_c_quit_hint {
|
||||
BlockState {
|
||||
right_title: Line::from("Ctrl+C to quit").alignment(Alignment::Right),
|
||||
border_style: Style::default(),
|
||||
}
|
||||
} else {
|
||||
BlockState {
|
||||
right_title: Line::from("Enter to send | Ctrl+D to quit | Ctrl+J for newline")
|
||||
.alignment(Alignment::Right),
|
||||
border_style: Style::default(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockState {
|
||||
|
||||
Reference in New Issue
Block a user