Skip to main content

lattice_config/
pane_options.rs

1// `linkme`'s distributed slices use `link_section` to aggregate
2// items at link time. The `options!` macro expansion in this file
3// emits such a declaration; allow the workspace's `unsafe_code =
4// "deny"` lint locally with the same safety rationale documented in
5// `option_decl.rs`, `group.rs`, and `core_options.rs`.
6#![allow(unsafe_code)]
7
8//! Per-pane behaviour options (`pane.*`).
9//!
10//! PBH.4: the bound on each pane's buffer-history trail, walked with
11//! `<C-6>` / `<C-7>`. See
12//! `docs/dev/architecture/pane-buffer-history.md` §9.
13
14crate::options! {
15    group = crate::Pane;
16
17    /// How many buffers one pane remembers in its back/forward trail
18    /// (`<C-6>` / `<C-7>`, `:history pane-buffers`).
19    ///
20    /// Oldest entries are evicted past this bound. Each entry is a
21    /// buffer id plus a cursor position, so the default is cheap; raise
22    /// it if you routinely walk further back than a hundred buffer
23    /// switches within one pane.
24    ///
25    /// Values below 1 are clamped to 1 — a zero-length trail would have
26    /// nowhere to store the buffer the pane is currently showing.
27    #[name("pane.buffer-history-size")]
28    pub PaneBufferHistorySize: i64 = 100;
29
30    /// ZP.4: where the zoom marker shows while a pane is zoomed
31    /// (`<C-w>z` / `:zoom-pane`).
32    ///
33    /// - `both`     — the zoomed pane's modeline AND its tab (default).
34    /// - `modeline` — modeline only.
35    /// - `tabline`  — tabline only.
36    /// - `none`     — no marker.
37    ///
38    /// The two surfaces answer different questions. The modeline
39    /// marker tells you the pane you are looking at is zoomed; the
40    /// tabline marker is the only one that can tell you a *background*
41    /// tab is zoomed, since zoom is per-tab state.
42    ///
43    /// See `docs/dev/architecture/pane-zoom.md` §6.
44    #[name("pane.zoom-indicator")]
45    pub PaneZoomIndicator: lattice_core::ui::pane::ZoomIndicator =
46        lattice_core::ui::pane::ZoomIndicator::Both;
47}
48
49#[cfg(test)]
50mod tests {
51    #![allow(clippy::unwrap_used, clippy::panic)]
52    use crate::{ConfigRegistry, PaneBufferHistorySize};
53
54    fn reg() -> ConfigRegistry {
55        let r = ConfigRegistry::new();
56        r.init_from_linkme();
57        r
58    }
59
60    #[test]
61    fn default_is_100() {
62        let r = reg();
63        assert_eq!(*r.get_typed::<PaneBufferHistorySize>().unwrap(), 100);
64    }
65
66    #[test]
67    fn is_settable() {
68        let r = reg();
69        r.parse_and_set_command("pane.buffer-history-size=25")
70            .unwrap();
71        assert_eq!(*r.get_typed::<PaneBufferHistorySize>().unwrap(), 25);
72    }
73
74    #[test]
75    fn the_option_is_registered_under_its_dotted_name() {
76        // `:set pane.buffer-history-size` / `:customize` reach it by
77        // name; a typo in `#[name(..)]` would only show up here.
78        let r = reg();
79        assert!(r.lookup("pane.buffer-history-size").is_some());
80    }
81}