pub enum LayoutPlan {
Leaf {
slot: PaneSlot,
},
Split {
orientation: SplitOrientation,
ratio: SplitRatio,
a: Box<LayoutPlan>,
b: Box<LayoutPlan>,
},
}Expand description
The latent layout: structurally the binary-tree twin of
LayoutNode, but its leaves hold PaneSlot (a definition-local
key) instead of a live PaneId. A stored definition therefore
references nothing runtime — the design’s deliberate choice over
generifying the shipped LayoutNode<L> (which would churn its whole
proptest suite + every call site). LayoutPlan::realize bridges the
two id spaces.
Variants§
Leaf
One slot filling its box.
Split
A split between side a (top/left) and side b (bottom/right);
ratio is side a’s fraction, same convention as LayoutNode.
Fields
orientation: SplitOrientationratio: SplitRatioSame refinement as LayoutNode’s — and it matters MORE here,
because a plan is persisted (praça writes definitions to
praca.json), so an out-of-range or NaN ratio would survive a
restart and be re-instantiated every time.
a: Box<LayoutPlan>b: Box<LayoutPlan>Implementations§
Source§impl LayoutPlan
impl LayoutPlan
Sourcepub fn split(
orientation: SplitOrientation,
a: LayoutPlan,
b: LayoutPlan,
) -> Self
pub fn split( orientation: SplitOrientation, a: LayoutPlan, b: LayoutPlan, ) -> Self
A balanced (ratio = 0.5) split.
Sourcepub fn slots(&self) -> Vec<PaneSlot>
pub fn slots(&self) -> Vec<PaneSlot>
Every slot in the plan, left-to-right (then top-to-bottom).
Sourcepub fn slot_count(&self) -> usize
pub fn slot_count(&self) -> usize
Number of slots (= number of panes the plan will spawn).
Sourcepub fn leftmost_slot(&self) -> PaneSlot
pub fn leftmost_slot(&self) -> PaneSlot
The first slot in left-to-right (top-to-bottom) order — the slot
the session’s initial pane (from new_session) holds when the plan
is instantiated. The interpreter spawns this slot’s shell first,
then splits outward to build the rest of the tree.
Sourcepub fn validate(&self) -> Result<(), PlanError>
pub fn validate(&self) -> Result<(), PlanError>
Structural validation: no duplicate slot, every ratio in
(0.0, 1.0). A plan that validates is safe to realize.
Sourcepub fn realize(&self, mint: &mut impl FnMut(PaneSlot) -> PaneId) -> LayoutNode
pub fn realize(&self, mint: &mut impl FnMut(PaneSlot) -> PaneId) -> LayoutNode
Turn a plan into a live LayoutNode by minting one PaneId
per slot. mint is called once per leaf in traversal order — the
instantiation interpreter passes a closure that spawns a PTY and
returns its id. After this, the entire shipped layout algebra
(compute_rects, neighbor, split_leaf, validate, …) applies
to the result — the plan reuses the live tree, never duplicates it.
Sourcepub fn from_node(node: &LayoutNode) -> (LayoutPlan, BTreeMap<PaneSlot, PaneId>)
pub fn from_node(node: &LayoutNode) -> (LayoutPlan, BTreeMap<PaneSlot, PaneId>)
Harvest a live LayoutNode back into a plan — the inverse of
realize. Assigns PaneSlot(0), (1), … to the
tree’s leaves in traversal order, producing a structurally-identical
plan (same shape + ratios) plus the slot → PaneId map recording
which live pane each slot stood for. This is how a running layout is
captured as a reusable preset: from_node dehydrates the live tree,
the plan + spawn specs become a [crate::SessionDefinition].
Round-trips with realize both ways: from_node(realize(plan))
returns plan (when its slots are already 0..n in traversal
order), and realize(from_node(node).0, |s| map[&s]) returns node.
Sourcepub fn from_node_into(
node: &LayoutNode,
next: &mut u32,
map: &mut BTreeMap<PaneSlot, PaneId>,
) -> LayoutPlan
pub fn from_node_into( node: &LayoutNode, next: &mut u32, map: &mut BTreeMap<PaneSlot, PaneId>, ) -> LayoutPlan
The running-counter harvest behind from_node:
assign slots starting at *next, advancing it, and record each
slot → PaneId in map. Use this to harvest several trees into
one global slot space — e.g. a multi-window session, where each
window’s panes must get distinct slots (per-window from_node
would restart at 0 and collide).
Trait Implementations§
Source§impl Clone for LayoutPlan
impl Clone for LayoutPlan
Source§fn clone(&self) -> LayoutPlan
fn clone(&self) -> LayoutPlan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more