Edit the spacing in shortcuts (#4330)
<img width="739" height="132" alt="image" src="https://github.com/user-attachments/assets/e8d40abb-ac41-49a2-abc4-ddc6decef989" />
This commit is contained in:
@@ -1204,17 +1204,25 @@ impl ChatComposer {
|
||||
}
|
||||
|
||||
fn handle_shortcut_overlay_key(&mut self, key_event: &KeyEvent) -> bool {
|
||||
if key_event.kind == KeyEventKind::Press
|
||||
&& key_event.modifiers.is_empty()
|
||||
&& matches!(key_event.code, KeyCode::Char('?'))
|
||||
{
|
||||
if key_event.kind != KeyEventKind::Press {
|
||||
return false;
|
||||
}
|
||||
|
||||
let toggles = match key_event.code {
|
||||
KeyCode::Char('?') if key_event.modifiers.is_empty() => true,
|
||||
KeyCode::BackTab => true,
|
||||
KeyCode::Tab if key_event.modifiers.contains(KeyModifiers::SHIFT) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if !toggles {
|
||||
return false;
|
||||
}
|
||||
|
||||
let next = toggle_shortcut_mode(self.footer_mode, self.ctrl_c_quit_hint);
|
||||
let changed = next != self.footer_mode;
|
||||
self.footer_mode = next;
|
||||
changed
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn footer_props(&self) -> FooterProps {
|
||||
|
||||
@@ -140,6 +140,7 @@ fn build_columns(entries: Vec<String>) -> Vec<Line<'static>> {
|
||||
|
||||
const COLUMNS: usize = 3;
|
||||
const MAX_PADDED_WIDTHS: [usize; COLUMNS - 1] = [24, 28];
|
||||
const MIN_PADDED_WIDTHS: [usize; COLUMNS - 1] = [22, 0];
|
||||
|
||||
let rows = entries.len().div_ceil(COLUMNS);
|
||||
let mut column_widths = [0usize; COLUMNS];
|
||||
@@ -160,7 +161,8 @@ fn build_columns(entries: Vec<String>) -> Vec<Line<'static>> {
|
||||
let entry = &entries[idx];
|
||||
if col < COLUMNS - 1 {
|
||||
let max_width = MAX_PADDED_WIDTHS[col];
|
||||
let target_width = column_widths[col].min(max_width);
|
||||
let mut target_width = column_widths[col];
|
||||
target_width = target_width.max(MIN_PADDED_WIDTHS[col]).min(max_width);
|
||||
let pad_width = target_width + 2;
|
||||
line.push_str(&format!("{entry:<pad_width$}"));
|
||||
} else {
|
||||
@@ -179,13 +181,13 @@ fn build_columns(entries: Vec<String>) -> Vec<Line<'static>> {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
enum ShortcutId {
|
||||
Commands,
|
||||
FilePaths,
|
||||
InsertNewline,
|
||||
ChangeMode,
|
||||
FilePaths,
|
||||
PasteImage,
|
||||
EditPrevious,
|
||||
Quit,
|
||||
ShowTranscript,
|
||||
ToggleOverlay,
|
||||
EditPrevious,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -272,17 +274,6 @@ const SHORTCUTS: &[ShortcutDescriptor] = &[
|
||||
prefix: "",
|
||||
label: " for commands",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::FilePaths,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::Char('@'),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
overlay_text: "@",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: " for file paths",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::InsertNewline,
|
||||
bindings: &[
|
||||
@@ -302,6 +293,28 @@ const SHORTCUTS: &[ShortcutDescriptor] = &[
|
||||
prefix: "",
|
||||
label: " for newline",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::ChangeMode,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::BackTab,
|
||||
modifiers: KeyModifiers::SHIFT,
|
||||
overlay_text: "shift + tab",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: " to change mode",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::FilePaths,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::Char('@'),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
overlay_text: "@",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: " for file paths",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::PasteImage,
|
||||
bindings: &[ShortcutBinding {
|
||||
@@ -313,6 +326,17 @@ const SHORTCUTS: &[ShortcutDescriptor] = &[
|
||||
prefix: "",
|
||||
label: " to paste images",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::EditPrevious,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::Esc,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
overlay_text: "esc",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: "",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::Quit,
|
||||
bindings: &[ShortcutBinding {
|
||||
@@ -335,28 +359,6 @@ const SHORTCUTS: &[ShortcutDescriptor] = &[
|
||||
prefix: "",
|
||||
label: " to view transcript",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::ToggleOverlay,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::Char('?'),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
overlay_text: "?",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: " to hide shortcuts",
|
||||
},
|
||||
ShortcutDescriptor {
|
||||
id: ShortcutId::EditPrevious,
|
||||
bindings: &[ShortcutBinding {
|
||||
code: KeyCode::Esc,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
overlay_text: "esc",
|
||||
condition: DisplayCondition::Always,
|
||||
}],
|
||||
prefix: "",
|
||||
label: "",
|
||||
},
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -10,6 +10,6 @@ expression: terminal.backend()
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" / for commands @ for file paths shift + enter for newline "
|
||||
" ctrl + v to paste images ctrl + c to exit ctrl + t to view transcript "
|
||||
" ? to hide shortcuts esc again to edit previous message "
|
||||
" / for commands shift + enter for newline shift + tab to change mode "
|
||||
" @ for file paths ctrl + v to paste images esc again to edit previous message "
|
||||
" ctrl + c to exit ctrl + t to view transcript "
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
source: tui/src/bottom_pane/footer.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
" / for commands @ for file paths shift + enter for ne"
|
||||
" ctrl + v to paste images ctrl + c to exit ctrl + t to view tra"
|
||||
" ? to hide shortcuts esc again to edit previous message "
|
||||
" / for commands shift + enter for newline shift + tab to change m"
|
||||
" @ for file paths ctrl + v to paste images esc again to edit previ"
|
||||
" ctrl + c to exit ctrl + t to view transcript "
|
||||
|
||||
Reference in New Issue
Block a user