Add zooming in/out to PDF

This commit is contained in:
2026-03-25 10:54:14 +01:00
parent 75dcacf011
commit 0b354462e0
14 changed files with 386 additions and 95 deletions

View File

@@ -51,6 +51,13 @@ pub const ACTION_DELETE: &str = "action.delete";
/// Create a new item in the current context.
pub const ACTION_NEW: &str = "action.new";
// ── PDF viewer ────────────────────────────────────────────────────────────────
/// Scroll the active PDF viewer to the next page.
pub const PDF_PAGE_NEXT: &str = "pdf.page.next";
/// Scroll the active PDF viewer to the previous page.
pub const PDF_PAGE_PREV: &str = "pdf.page.prev";
// ── Tabs ──────────────────────────────────────────────────────────────────────
/// Cycle to the next tab (wraps around).

View File

@@ -44,9 +44,14 @@ pub fn default_bindings() -> BindingSet {
bind!("zo" => a::TREE_EXPAND);
bind!("zc" => a::TREE_COLLAPSE);
bind!("za" => a::TREE_TOGGLE);
// Arrow-style tree navigation: l expands, h collapses.
bind!("l" => a::TREE_EXPAND);
bind!("h" => a::TREE_COLLAPSE);
// ── Pane navigation ───────────────────────────────────────────────────────
bind!("h" => a::FOCUS_PREV);
bind!("l" => a::FOCUS_NEXT);
// ── PDF viewer ────────────────────────────────────────────────────────────
bind!("J" => a::PDF_PAGE_NEXT);
bind!("K" => a::PDF_PAGE_PREV);
// ── Item actions ──────────────────────────────────────────────────────────
bind!("<Enter>" => a::ACTION_OPEN);
@@ -59,6 +64,7 @@ pub fn default_bindings() -> BindingSet {
bind!("gt" => a::TAB_NEXT);
bind!("gT" => a::TAB_PREV);
bind!("q" => a::TAB_CLOSE);
bind!("<C-w>" => a::TAB_CLOSE);
// ── Input modes ───────────────────────────────────────────────────────────
bind!(":" => a::MODE_COMMAND);
@@ -132,6 +138,33 @@ mod tests {
);
}
#[test]
fn zc_maps_to_tree_collapse() {
let d = defaults();
assert_eq!(
d.lookup(&[Key::char('z'), Key::char('c')]),
LookupResult::Exact(a::TREE_COLLAPSE.into())
);
}
#[test]
fn h_maps_to_focus_prev() {
let d = defaults();
assert_eq!(
d.lookup(&[Key::char('h')]),
LookupResult::Exact(a::FOCUS_PREV.into())
);
}
#[test]
fn l_maps_to_focus_next() {
let d = defaults();
assert_eq!(
d.lookup(&[Key::char('l')]),
LookupResult::Exact(a::FOCUS_NEXT.into())
);
}
#[test]
fn colon_maps_to_mode_command() {
let d = defaults();