Skip to content

Commit 7c23548

Browse files
authored
Refactor split view menu shortcuts and enhance shortcut display logic
1 parent 673cf48 commit 7c23548

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

‎crates/edit/src/bin/edit/draw_menubar.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ fn draw_menu_view(ctx: &mut Context, state: &mut State) {
126126
drop(tb);
127127

128128
// Split view menu items
129-
if ctx.menubar_menu_button(loc(LocId::ViewSplitHorizontal), 'H', kbmod::CTRL_ALT | vk::RIGHT)
129+
if ctx.menubar_menu_button(loc(LocId::ViewSplitHorizontal), 'H', kbmod::CTRL | vk::BACKSLASH)
130130
{
131131
state.wants_split_horizontal = true;
132132
ctx.needs_rerender();
133133
}
134-
if ctx.menubar_menu_button(loc(LocId::ViewSplitVertical), 'V', kbmod::CTRL_ALT | vk::DOWN) {
134+
if ctx.menubar_menu_button(loc(LocId::ViewSplitVertical), 'V', kbmod::CTRL_SHIFT | vk::BACKSLASH) {
135135
state.wants_split_vertical = true;
136136
ctx.needs_rerender();
137137
}
138138
if state.split_layout.pane_count() > 1 {
139-
if ctx.menubar_menu_button(loc(LocId::ViewClosePane), 'C', kbmod::CTRL_ALT | vk::LEFT) {
139+
if ctx.menubar_menu_button(loc(LocId::ViewClosePane), 'C', kbmod::CTRL_SHIFT | vk::W) {
140140
state.wants_close_pane = true;
141141
ctx.needs_rerender();
142142
}

‎crates/edit/src/tui.rs‎

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,8 +3314,46 @@ impl<'a> Context<'a, '_> {
33143314
}
33153315

33163316
fn menubar_shortcut(&mut self, shortcut: InputKey) {
3317-
let shortcut_letter = shortcut.value() as u8 as char;
3318-
if shortcut_letter.is_ascii_uppercase() {
3317+
let shortcut_key = shortcut.key().value();
3318+
let shortcut_letter = shortcut_key as u8 as char;
3319+
3320+
// Check if it's a displayable shortcut (letter, function key, or special key)
3321+
let key_name: Option<&str> = if shortcut_letter.is_ascii_uppercase() {
3322+
None // Will use the letter directly
3323+
} else {
3324+
match shortcut_key {
3325+
// Arrow keys
3326+
0x25 => Some("←"),
3327+
0x26 => Some("↑"),
3328+
0x27 => Some("→"),
3329+
0x28 => Some("↓"),
3330+
// Function keys
3331+
0x70 => Some("F1"),
3332+
0x71 => Some("F2"),
3333+
0x72 => Some("F3"),
3334+
0x73 => Some("F4"),
3335+
0x74 => Some("F5"),
3336+
0x75 => Some("F6"),
3337+
0x76 => Some("F7"),
3338+
0x77 => Some("F8"),
3339+
0x78 => Some("F9"),
3340+
0x79 => Some("F10"),
3341+
0x7A => Some("F11"),
3342+
0x7B => Some("F12"),
3343+
// Other special keys
3344+
0x21 => Some("PgUp"),
3345+
0x22 => Some("PgDn"),
3346+
0x23 => Some("End"),
3347+
0x24 => Some("Home"),
3348+
0x2D => Some("Ins"),
3349+
0x2E => Some("Del"),
3350+
0x1B => Some("Esc"),
3351+
0x5C => Some("\\"), // Backslash
3352+
_ => None,
3353+
}
3354+
};
3355+
3356+
if shortcut_letter.is_ascii_uppercase() || key_name.is_some() {
33193357
let mut shortcut_text = ArenaString::new_in(self.arena());
33203358
if shortcut.modifiers_contains(kbmod::CTRL) {
33213359
shortcut_text.push_str(self.tui.modifier_translations.ctrl);
@@ -3329,7 +3367,11 @@ impl<'a> Context<'a, '_> {
33293367
shortcut_text.push_str(self.tui.modifier_translations.shift);
33303368
shortcut_text.push('+');
33313369
}
3332-
shortcut_text.push(shortcut_letter);
3370+
if let Some(name) = key_name {
3371+
shortcut_text.push_str(name);
3372+
} else {
3373+
shortcut_text.push(shortcut_letter);
3374+
}
33333375

33343376
self.label("shortcut", &shortcut_text);
33353377
} else {

0 commit comments

Comments
 (0)