Add shift as a modifier to the new tab shortcuts

This commit is contained in:
Josh Megnauth 2024-01-18 22:01:01 -05:00 committed by Jeremy Soller
parent 9dffe2543e
commit c2f06a975a

View file

@ -1358,13 +1358,19 @@ impl Application for App {
} }
Event::Keyboard(KeyEvent::KeyPressed { Event::Keyboard(KeyEvent::KeyPressed {
key_code: key @ (KeyCode::PageUp | KeyCode::PageDown), key_code: key @ (KeyCode::PageUp | KeyCode::PageDown),
modifiers: Modifiers::CTRL, modifiers,
}) => match key { }) => {
KeyCode::PageDown => Some(Message::TabPrev), if modifiers == Modifiers::CTRL | Modifiers::SHIFT {
KeyCode::PageUp => Some(Message::TabNext), match key {
_ => None, KeyCode::PageDown => Some(Message::TabPrev),
}, KeyCode::PageUp => Some(Message::TabNext),
// Ctrl + N to switch tabs _ => None,
}
} else {
None
}
}
// Ctrl + Shift + N to jump to a tab
Event::Keyboard(KeyEvent::KeyPressed { Event::Keyboard(KeyEvent::KeyPressed {
key_code: key_code:
key @ (KeyCode::Key1 key @ (KeyCode::Key1
@ -1375,17 +1381,20 @@ impl Application for App {
| KeyCode::Key6 | KeyCode::Key6
| KeyCode::Key7 | KeyCode::Key7
| KeyCode::Key8 | KeyCode::Key8
| KeyCode::Key9 | KeyCode::Key9),
| KeyCode::Key0), modifiers,
modifiers: Modifiers::CTRL,
}) => { }) => {
// 0 to 9 if modifiers == Modifiers::CTRL | Modifiers::SHIFT {
// Key1 is 0 and Key0 is 9 // 0 to 8
// This does not seem to be platform specific according to iced's source // Key1 is 0 and Key9 is 8
let code = key as u32 as usize; // This does not seem to be platform specific according to iced's source
debug_assert!(code <= 9); let code = key as u32 as usize;
debug_assert!(code <= 8);
Some(Message::TabActivateJump(code)) Some(Message::TabActivateJump(code))
} else {
None
}
} }
Event::Keyboard(KeyEvent::KeyPressed { Event::Keyboard(KeyEvent::KeyPressed {
key_code: KeyCode::V, key_code: KeyCode::V,