use crate::bubbles::help::KeyMap as HelpKeyMap;
use crate::bubbles::key::Binding;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct KeyMap {
pub line_up: Binding,
pub line_down: Binding,
pub page_up: Binding,
pub page_down: Binding,
pub half_page_up: Binding,
pub half_page_down: Binding,
pub goto_top: Binding,
pub goto_bottom: Binding,
}
impl Default for KeyMap {
fn default() -> Self {
let b = |keys: &[&str], key: &str, desc: &str| Binding::new(keys).with_help(key, desc);
Self {
line_up: b(&["up", "k"], "↑/k", "up"),
line_down: b(&["down", "j"], "↓/j", "down"),
page_up: b(&["b", "pgup"], "b/pgup", "page up"),
page_down: b(&["f", "pgdown", "space"], "f/pgdn", "page down"),
half_page_up: b(&["u", "ctrl+u"], "u", "½ page up"),
half_page_down: b(&["d", "ctrl+d"], "d", "½ page down"),
goto_top: b(&["home", "g"], "g/home", "go to start"),
goto_bottom: b(&["end", "G"], "G/end", "go to end"),
}
}
}
impl HelpKeyMap for KeyMap {
fn short_help(&self) -> Vec<Binding> {
vec![self.line_up.clone(), self.line_down.clone()]
}
fn full_help(&self) -> Vec<Vec<Binding>> {
vec![
vec![
self.line_up.clone(),
self.line_down.clone(),
self.goto_top.clone(),
self.goto_bottom.clone(),
],
vec![
self.page_up.clone(),
self.page_down.clone(),
self.half_page_up.clone(),
self.half_page_down.clone(),
],
]
}
}