Skip to main content

LayoutPlan

Enum LayoutPlan 

Source
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.

Fields

§

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: SplitOrientation
§ratio: SplitRatio

Same 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.

Implementations§

Source§

impl LayoutPlan

Source

pub fn leaf(slot: PaneSlot) -> Self

A single-slot plan.

Source

pub fn split( orientation: SplitOrientation, a: LayoutPlan, b: LayoutPlan, ) -> Self

A balanced (ratio = 0.5) split.

Source

pub fn slots(&self) -> Vec<PaneSlot>

Every slot in the plan, left-to-right (then top-to-bottom).

Source

pub fn slot_count(&self) -> usize

Number of slots (= number of panes the plan will spawn).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LayoutPlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LayoutPlan

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LayoutPlan

Source§

fn eq(&self, other: &LayoutPlan) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for LayoutPlan

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LayoutPlan

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.