Skip to main content

Tab

Struct Tab 

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

A single terminal tab with its own state (supports split panes).

§Mutex Strategy

terminal is behind a tokio::sync::RwLock because TerminalManager is shared across async tasks (PTY reader, input sender, resize handler) and the sync winit event loop. See the global policy in crate (lib.rs) and the locking table on the terminal field below.

pane_manager is owned directly (not behind a Mutex) because it is only ever accessed from the sync winit event loop on the main thread.

For the complete threading model see docs/MUTEX_PATTERNS.md.

Implementations§

Source§

impl Tab

Source

pub fn new( id: TabId, tab_number: usize, config: &Config, runtime: Arc<Runtime>, working_directory: Option<String>, grid_size: Option<(usize, usize)>, ) -> Result<Self>

Create a new tab with a terminal session

§Arguments
  • id - Unique tab identifier
  • tab_number - Display number for the tab (1-indexed)
  • config - Terminal configuration
  • runtime - Tokio runtime for async operations
  • working_directory - Optional working directory to start in
  • grid_size - Optional (cols, rows) override. When provided, uses these dimensions instead of config.cols/rows. This ensures the shell starts with the correct dimensions when the renderer has already calculated the grid size accounting for tab bar height.
Source

pub fn new_from_profile( id: TabId, config: &Config, _runtime: Arc<Runtime>, profile: &Profile, grid_size: Option<(usize, usize)>, ) -> Result<Self>

Create a new tab from a profile configuration

The profile can override:

  • Working directory
  • Command and arguments (instead of default shell)
  • Tab name

If a profile specifies a command, it always runs from the profile’s working directory (or config default if unset).

§Arguments
  • id - Unique tab identifier
  • config - Terminal configuration
  • _runtime - Tokio runtime (unused: profile tabs don’t send initial text)
  • profile - Profile configuration to use
  • grid_size - Optional (cols, rows) override for initial terminal size
§Unique logic vs Tab::new()

This constructor’s divergent logic (not shared with Tab::new() via new_internal):

  • SSH command detection (profile.ssh_command_args())
  • Per-profile login_shell override (takes precedence over config.login_shell)
  • Per-profile SHELL env-var injection when profile.shell is set
  • Title derived from profile.tab_nameprofile.name (not “Tab N”)
  • Profile tabs do NOT send config.initial_text on startup
Source

pub fn new_from_pane( id: TabId, pane: Pane, _config: &Config, _runtime: Arc<Runtime>, tab_number: usize, ) -> Self

Create a new tab wrapping an existing Pane (e.g., from a promote operation).

The pane’s PTY, scroll state, and session logger are preserved. No new shell is spawned — the pane’s terminal keeps running. The tab shares the pane’s Arc<RwLock<TerminalManager>> as its primary terminal.

Source§

impl Tab

Source

pub fn has_multiple_panes(&self) -> bool

Check if this tab has multiple panes (split)

Source

pub fn pane_count(&self) -> usize

Get the number of panes in this tab

Source

pub fn split_horizontal( &mut self, focus_new: bool, config: &Config, runtime: Arc<Runtime>, dpi_scale: f32, initial_command: Option<(String, Vec<String>)>, split_percent: u8, ) -> Result<Option<PaneId>>

Split the current pane horizontally (panes stacked vertically)

Returns the new pane ID if successful. dpi_scale converts logical pixel config values to physical pixels. focus_new controls whether the new pane receives focus after splitting. initial_command — when Some((cmd, args)) the new pane runs that process directly.

Source

pub fn split_vertical( &mut self, focus_new: bool, config: &Config, runtime: Arc<Runtime>, dpi_scale: f32, initial_command: Option<(String, Vec<String>)>, split_percent: u8, ) -> Result<Option<PaneId>>

Split the current pane vertically (panes side by side)

Returns the new pane ID if successful. dpi_scale converts logical pixel config values to physical pixels. focus_new controls whether the new pane receives focus after splitting. initial_command — when Some((cmd, args)) the new pane runs that process directly.

Source

pub fn close_focused_pane(&mut self) -> bool

Close the focused pane

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

Source

pub fn close_exited_panes(&mut self) -> (Vec<PaneId>, bool)

Check for exited panes and close them

Returns (closed_pane_ids, tab_should_close) where:

  • closed_pane_ids: Vec of pane IDs that were closed
  • tab_should_close: true if all panes have exited (tab should close)
Source

pub fn pane_manager(&self) -> Option<&PaneManager>

Get the pane manager if split panes are enabled

Source

pub fn pane_manager_mut(&mut self) -> Option<&mut PaneManager>

Get mutable access to the pane manager

Source

pub fn init_pane_manager(&mut self)

Initialize the pane manager if not already present

This is used for tmux integration where we need to create the pane manager before applying a layout.

Source

pub fn set_pane_bounds( &mut self, bounds: PaneBounds, cell_width: f32, cell_height: f32, )

Set the pane bounds and resize terminals

This should be called before creating splits to ensure panes are sized correctly. If the pane manager doesn’t exist yet, this creates it with the bounds set.

Source

pub fn set_pane_bounds_with_padding( &mut self, bounds: PaneBounds, cell_width: f32, cell_height: f32, padding: f32, )

Set the pane bounds and resize terminals with padding

This should be called before creating splits to ensure panes are sized correctly. The padding parameter accounts for content inset from pane edges.

Source

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

Focus the pane at the given pixel coordinates

Returns the ID of the newly focused pane, or None if no pane at that position

Source

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

Get the ID of the currently focused pane

Source

pub fn is_pane_focused(&self, pane_id: PaneId) -> bool

Check if a specific pane is focused

Source

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

Navigate to an adjacent pane

Source

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

Check if a position is on a divider

Source

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

Find divider at position

Returns the divider index if found

Source

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

Get divider info by index

Source

pub fn drag_divider(&mut self, divider_index: usize, x: f32, y: f32)

Drag a divider to a new position

Source

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

Restore a pane layout from a saved session

Replaces the current single-pane layout with a saved pane tree. Each leaf in the tree gets a new terminal session with the saved CWD. If the build fails, the tab keeps its existing single pane.

Source

pub fn start_pane_refresh_tasks( &mut self, runtime: Arc<Runtime>, window: Arc<Window>, active_fps: u32, inactive_fps: u32, )

Start refresh tasks for all panes that don’t already have one.

Must be called after pane creation (split, restore) to ensure each pane’s terminal output triggers redraws. Without this, only tab.terminal is polled by the tab refresh task, so secondary panes never trigger redraws.

Source§

impl Tab

Source

pub fn is_bell_active(&self) -> bool

Check if the visual bell is currently active (within flash duration)

Source

pub fn update_title( &mut self, title_mode: TabTitleMode, remote_format: RemoteTabTitleFormat, remote_osc_priority: bool, )

Update tab title from terminal OSC sequences or shell integration data.

Priority when on a remote host (hostname detected via OSC 7):

  1. Explicit OSC title (\033]0;...\007) if remote_osc_priority is true
  2. remote_format — formatted from hostname/username/cwd

Priority when local:

  1. Explicit OSC title
  2. Last CWD component (only in TabTitleMode::Auto)

User-named tabs are never auto-updated.

Source

pub fn set_default_title(&mut self, tab_number: usize)

Set the tab’s default title based on its position

Source

pub fn set_title(&mut self, title: &str)

Explicitly set the tab title (for tmux window names, etc.)

This overrides any default title and marks the tab as having a custom title.

Source

pub fn is_running(&self) -> bool

Check if the terminal in this tab is still running

Source

pub fn get_cwd(&self) -> Option<String>

Get the current working directory of this tab’s shell

Source

pub fn set_custom_color(&mut self, color: [u8; 3])

Set a custom color for this tab

Source

pub fn clear_custom_color(&mut self)

Clear the custom color for this tab (reverts to default config colors)

Source

pub fn has_custom_color(&self) -> bool

Check if this tab has a custom color set

Source

pub fn parse_hostname_from_osc7_url(url: &str) -> Option<String>

Parse hostname from an OSC 7 file:// URL

OSC 7 format: file://hostname/path or file:///path (localhost) Returns the hostname if present and not localhost, None otherwise.

Source

pub fn check_hostname_change(&mut self) -> Option<String>

Check if hostname has changed and update tracking

Returns Some(hostname) if a new remote hostname was detected, None if hostname hasn’t changed or is local.

This uses the hostname extracted from OSC 7 sequences by the terminal emulator.

Source

pub fn check_cwd_change(&mut self) -> Option<String>

Check if CWD has changed and update tracking

Returns Some(cwd) if the CWD has changed, None otherwise. Uses the CWD reported via OSC 7 by the terminal emulator.

Source

pub fn clear_auto_profile(&mut self)

Clear auto-applied profile tracking

Call this when manually switching profiles or when the hostname returns to local, or when disconnecting from tmux.

Source§

impl Tab

Source

pub fn start_refresh_task( &mut self, runtime: Arc<Runtime>, window: Arc<Window>, active_fps: u32, inactive_fps: u32, )

Start the refresh polling task for this tab

Source

pub fn stop_refresh_task(&mut self)

Stop the refresh polling task

Source§

impl Tab

Source

pub fn toggle_session_logging(&mut self, config: &Config) -> Result<bool>

Toggle session logging on/off.

Returns Ok(true) if logging is now active, Ok(false) if stopped. If logging wasn’t active and no logger exists, creates a new one.

Source

pub fn is_session_logging_active(&self) -> bool

Check if session logging is currently active.

Trait Implementations§

Source§

impl Drop for Tab

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Tab

§

impl !RefUnwindSafe for Tab

§

impl !UnwindSafe for Tab

§

impl Send for Tab

§

impl Sync for Tab

§

impl Unpin for Tab

§

impl UnsafeUnpin for Tab

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