Skip to main content

PaneManager

Struct PaneManager 

Source
pub struct PaneManager { /* private fields */ }
Expand description

Manages the pane tree within a single tab

Implementations§

Source§

impl PaneManager

Source

pub fn create_initial_pane( &mut self, config: &Config, runtime: Arc<Runtime>, working_directory: Option<String>, ) -> Result<PaneId>

Create the initial pane (when tab is first created)

If bounds have been set on the PaneManager via set_bounds(), the pane will be created with dimensions calculated from those bounds. Otherwise, the default config dimensions are used.

Source

pub fn create_initial_pane_for_split( &mut self, direction: SplitDirection, config: &Config, runtime: Arc<Runtime>, working_directory: Option<String>, ) -> Result<PaneId>

Create the initial pane sized for an upcoming split

This calculates dimensions based on what the pane size will be AFTER the split, preventing the shell from seeing a resize.

Source

pub fn split( &mut self, direction: SplitDirection, focus_new: bool, config: &Config, runtime: Arc<Runtime>, initial_command: Option<(String, Vec<String>)>, ratio: f32, ) -> Result<Option<PaneId>>

Split the focused pane in the given direction

Returns the ID of the new pane, or None if no pane is focused.

initial_command — when Some((cmd, args)) the new pane launches that process directly instead of the login shell. The pane closes when the process exits.

Source§

impl PaneManager

Source

pub fn close_pane(&mut self, id: PaneId) -> bool

Close a pane by ID

Returns true if this was the last pane (tab should close)

Source

pub fn navigate(&mut self, direction: NavigationDirection)

Navigate to a pane in the given direction

Source

pub fn focus_pane(&mut self, id: PaneId)

Focus a specific pane by ID

Source

pub fn focus_pane_at(&mut self, x: f32, y: f32) -> Option<PaneId>

Focus the pane at a given pixel position

Source

pub fn focused_pane(&self) -> Option<&Pane>

Get the currently focused pane

Source

pub fn focused_pane_mut(&mut self) -> Option<&mut Pane>

Get the currently focused pane mutably

Source

pub fn focused_pane_id(&self) -> Option<PaneId>

Get the focused pane ID

Source§

impl PaneManager

Source

pub fn set_bounds(&mut self, bounds: PaneBounds)

Set the total bounds available for panes and recalculate layout

Source

pub fn recalculate_bounds(&mut self)

Recalculate bounds for all panes

Source

pub fn resize_all_terminals(&self, cell_width: f32, cell_height: f32)

Resize all pane terminals to match their current bounds

This should be called after bounds are updated (split, resize, window resize) to ensure each PTY is sized correctly for its pane area.

Source

pub fn resize_all_terminals_with_padding( &self, cell_width: f32, cell_height: f32, padding: f32, height_offset: f32, )

Resize all terminal PTYs to match their pane bounds, accounting for padding.

The padding reduces the content area where text is rendered, so terminals should be sized for the padded (smaller) area to avoid content being cut off.

height_offset is an additional height reduction (e.g., pane title bar height) subtracted once from each pane’s content height.

Source

pub fn set_divider_width(&mut self, width: f32)

Set the divider width

Source

pub fn divider_width(&self) -> f32

Get the divider width

Source

pub fn divider_hit_padding(&self) -> f32

Get the hit detection padding (extra area around divider for easier grabbing)

Source

pub fn resize_split(&mut self, pane_id: PaneId, delta: f32)

Resize a split by adjusting its ratio

pane_id: The pane whose adjacent split should be resized delta: Amount to adjust the ratio (-1.0 to 1.0)

Source

pub fn get_dividers(&self) -> Vec<DividerRect>

Get all divider rectangles in the pane tree

Source

pub fn find_divider_at(&self, x: f32, y: f32, padding: f32) -> Option<usize>

Find a divider at the given position

Returns the index of the divider if found, with optional padding for easier grabbing

Source

pub fn is_on_divider(&self, x: f32, y: f32) -> bool

Check if a position is on a divider

Source

pub fn set_divider_hit_width(&mut self, width: f32)

Set the divider hit width

Source

pub fn get_divider(&self, index: usize) -> Option<DividerRect>

Get the divider at an index

Source

pub fn drag_divider(&mut self, divider_index: usize, new_x: f32, new_y: f32)

Resize by dragging a divider to a new position

divider_index: Which divider is being dragged new_position: New mouse position (x for vertical, y for horizontal dividers)

Source§

impl PaneManager

Source

pub fn build_from_layout( &mut self, layout: &SessionPaneNode, config: &Config, runtime: Arc<Runtime>, ) -> Result<()>

Build a pane tree from a saved session layout

Recursively constructs live PaneNode tree from a SessionPaneNode, creating new terminal panes for each leaf. If a leaf’s CWD no longer exists, falls back to $HOME.

Source§

impl PaneManager

Source

pub fn set_from_tmux_layout( &mut self, layout: &TmuxLayout, config: &Config, runtime: Arc<Runtime>, ) -> Result<HashMap<TmuxPaneId, PaneId>>

Set the pane tree from a tmux layout

This replaces the entire pane tree with one constructed from the tmux layout. Returns a mapping of tmux pane IDs to native pane IDs.

§Arguments
  • layout - The parsed tmux layout
  • config - Configuration for creating panes
  • runtime - Async runtime for pane tasks
Source

pub fn rebuild_from_tmux_layout( &mut self, layout: &TmuxLayout, existing_mappings: &HashMap<TmuxPaneId, PaneId>, new_tmux_panes: &[TmuxPaneId], config: &Config, runtime: Arc<Runtime>, ) -> Result<HashMap<TmuxPaneId, PaneId>>

Rebuild the pane tree from a tmux layout, preserving existing pane terminals

This is called when panes are added or the layout structure changes. It rebuilds the entire tree structure to match the tmux layout while reusing existing Pane objects to preserve their terminal state.

§Arguments
  • layout - The parsed tmux layout
  • existing_mappings - Map from tmux pane ID to native pane ID for panes to preserve
  • new_tmux_panes - List of new tmux pane IDs that need new Pane objects
  • config - Configuration for creating new panes
  • runtime - Async runtime for new pane tasks
§Returns

Updated mapping of tmux pane IDs to native pane IDs

Source§

impl PaneManager

Source

pub fn update_layout_from_tmux( &mut self, layout: &TmuxLayout, pane_mappings: &HashMap<TmuxPaneId, PaneId>, )

Update the layout structure (ratios) from a tmux layout without recreating terminals

This is called when the tmux pane IDs haven’t changed but the layout dimensions have (e.g., due to resize or another client connecting). It updates the split ratios in our pane tree to match the tmux layout.

Source

pub fn update_from_tmux_layout( &mut self, layout: &TmuxLayout, existing_mappings: &HashMap<TmuxPaneId, PaneId>, config: &Config, runtime: Arc<Runtime>, ) -> Result<Option<HashMap<TmuxPaneId, PaneId>>>

Update an existing pane tree to match a new tmux layout

This tries to preserve existing panes where possible and only creates/destroys panes as needed.

Returns updated mappings (Some = new mappings, None = no changes needed)

Source§

impl PaneManager

Source

pub fn new() -> Self

Create a new empty pane manager

Source

pub fn new_with_existing_terminal( terminal: Arc<RwLock<TerminalManager>>, working_directory: Option<String>, is_active: Arc<AtomicBool>, ) -> Self

Create a pane manager pre-populated with a single primary pane that wraps an already-running TerminalManager.

This is used by Tab::new_internal so that every tab always starts with a PaneManager (R-32). The primary pane shares the caller’s terminal Arc, so no new shell process is spawned.

§Arguments
  • terminalArc cloned from Tab::terminal
  • working_directory — Optional CWD for the primary pane
  • is_active — Shared atomic cloned from Tab::is_active
Source

pub fn new_with_pane(pane: Pane) -> Self

Create a pane manager wrapping an existing Pane as the single root node.

Used by Tab::new_from_pane() when promoting a pane to its own tab. The pane’s ID is preserved and next_pane_id is advanced past it.

Source

pub fn with_initial_pane( config: &Config, runtime: Arc<Runtime>, working_directory: Option<String>, ) -> Result<Self>

Create a pane manager with an initial pane

Source

pub fn next_pane_id(&self) -> PaneId

Get the next pane ID that will be assigned

Source

pub fn get_pane(&self, id: PaneId) -> Option<&Pane>

Get a pane by ID

Source

pub fn get_pane_mut(&mut self, id: PaneId) -> Option<&mut Pane>

Get a mutable pane by ID

Source

pub fn all_panes(&self) -> Vec<&Pane>

Get all panes

Source

pub fn all_panes_mut(&mut self) -> Vec<&mut Pane>

Get all panes mutably

Source

pub fn collect_pane_backgrounds(&self) -> Vec<PaneBackgroundConfig>

Collect current per-pane background settings for config persistence

Returns a Vec<PaneBackgroundConfig> containing only panes that have a custom background image set. The index field corresponds to the pane’s position in the tree traversal order.

Source

pub fn pane_count(&self) -> usize

Get the number of panes

Source

pub fn has_multiple_panes(&self) -> bool

Check if there are multiple panes

Source

pub fn root(&self) -> Option<&PaneNode>

Get access to the root node (for rendering)

Source

pub fn root_mut(&mut self) -> Option<&mut PaneNode>

Get mutable access to the root node

Source

pub fn insert_subtree_at( &mut self, target_pane_id: PaneId, subtree: PaneNode, direction: SplitDirection, ratio: f32, ) -> Result<PaneIdRemap, PaneNode>

Insert a PaneNode subtree into the tree by splitting the target pane.

The target leaf is replaced with a Split containing the original pane as one child and the subtree as the other. Bounds are recalculated.

On success, returns the ids the adopted panes hold afterwards, which are not always the ids they arrived with.

On failure — there is no tree here to insert into, or no pane holds target_pane_id — the tree is left untouched and the subtree is handed back, carrying the ids it arrived with. Handing it back is the point of the Err, not a courtesy: a caller gets a subtree to pass here by detaching it from wherever it was living, so this is the only remaining reference to those panes, and dropping it closes them and kills their PTYs. The caller must put it back somewhere.

A subtree arriving from another tab (“Demote Tab to Pane”) brings that tab’s ids with it, and ids are allocated per PaneManager — that is, per tab — so an incoming id can already belong to a pane here: tab A’s panes 1 and 2 landing in a tab that already holds 1 and 2. get_pane is a search over the tree, so a duplicate would make every id-keyed lookup resolve to whichever pane the walk reaches first, and the adopted pane would be unreachable. Colliding panes are therefore renumbered from this manager’s counter.

Advancing the counter past every adopted id closes the other half: this tab must not later hand a new pane an id one of the adopted panes is already using.

A caller holding an id from the subtree across this call must translate it through the returned map; the pre-move id may now name a different pane, or no pane at all.

Source

pub fn extract_pane(&mut self, target_id: PaneId) -> ExtractResult

Extract a pane from the tree by ID, returning ownership of the live Pane.

Unlike remove_pane() which drops the pane, this returns the pane intact so it can be transferred to another tab or pane tree. All processes in the pane’s PTY continue running.

Source

pub fn take_root(&mut self) -> Option<PaneNode>

Take ownership of the root node, leaving None in its place.

Used by demote (tab → pane) to extract the entire pane tree for transplantation into another tab.

Source

pub fn set_root(&mut self, node: PaneNode)

Replace the root node (drops any existing tree).

Used after extract_pane when the remaining tree needs to be restored and the default ExtractResult::Extracted.remaining has already been taken by the caller.

Trait Implementations§

Source§

impl Default for PaneManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more