use super::{KeyStroke, Shortcut};
use crate::event::{Key, Modifiers};
#[doc(hidden)]
pub const NEXT_REGION: &str = "focus.next_region";
#[doc(hidden)]
pub const PREVIOUS_REGION: &str = "focus.previous_region";
const NAVIGATION_CATEGORY: &str = "navigation";
pub(crate) fn region_direction(id: &str) -> Option<bool> {
match id {
NEXT_REGION => Some(true),
PREVIOUS_REGION => Some(false),
_ => None,
}
}
#[doc(hidden)]
pub fn focus_region_shortcuts() -> [Shortcut; 2] {
[
region_shortcut(NEXT_REGION, "Next Region", Modifiers::NONE),
region_shortcut(PREVIOUS_REGION, "Previous Region", Modifiers::SHIFT),
]
}
fn region_shortcut(id: &'static str, name: &str, modifiers: Modifiers) -> Shortcut {
Shortcut::new(id)
.name(name.to_owned())
.category(NAVIGATION_CATEGORY)
.category_label("Navigation")
.primary(KeyStroke::new(Key::F6, modifiers))
.build()
}
pub(crate) fn region_default(id: &str) -> Option<Shortcut> {
region_direction(id)?;
focus_region_shortcuts()
.into_iter()
.find(|shortcut| shortcut.id == id)
}
pub(crate) fn register_focus_region_shortcuts(registry: &mut super::ShortcutRegistry) {
for shortcut in focus_region_shortcuts() {
registry.register(shortcut);
}
}