Skip to main content

WindowState

Struct WindowState 

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

Per-window state that manages a single terminal window with multiple tabs

Implementations§

Source§

impl WindowState

Source

pub fn new_tab_or_show_profiles(&mut self)

Create a new tab, or show profile picker if configured and profiles exist

Source

pub fn new_tab(&mut self)

Create a new tab

Source

pub fn close_current_tab(&mut self) -> bool

Close the current tab Returns true if the window should close (last tab was closed)

Source

pub fn close_current_tab_immediately(&mut self) -> bool

Close the current tab immediately without confirmation Returns true if the window should close (last tab was closed)

Source

pub fn reopen_closed_tab(&mut self)

Reopen the most recently closed tab at its original position

Source

pub fn next_tab(&mut self)

Switch to next tab

Source

pub fn prev_tab(&mut self)

Switch to previous tab

Source

pub fn switch_to_tab_index(&mut self, index: usize)

Switch to tab by index (1-based)

Source

pub fn move_tab_left(&mut self)

Move current tab left

Source

pub fn move_tab_right(&mut self)

Move current tab right

Source

pub fn duplicate_tab(&mut self)

Duplicate current tab

Source

pub fn duplicate_tab_by_id(&mut self, source_tab_id: TabId)

Duplicate a specific tab by ID

Source

pub fn has_multiple_tabs(&self) -> bool

Check if there are multiple tabs

Source

pub fn active_terminal(&self) -> Option<&Arc<Mutex<TerminalManager>>>

Get the active tab’s terminal

Source

pub fn split_pane_horizontal(&mut self)

Split the current pane horizontally (panes stacked top/bottom)

Source

pub fn split_pane_vertical(&mut self)

Split the current pane vertically (panes side by side)

Source

pub fn close_focused_pane(&mut self) -> bool

Close the focused pane in the current tab

If this is the last pane, the tab is closed. Returns true if the window should close (last tab was closed).

Source

pub fn has_multiple_panes(&self) -> bool

Check if the current tab has multiple panes

Source

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

Navigate to an adjacent pane in the given direction

Source

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

Resize the focused pane in the given direction

Growing left/up decreases the pane’s ratio, growing right/down increases it

Source

pub fn open_profile(&mut self, profile_id: ProfileId)

Open a new tab from a profile

Source

pub fn toggle_profile_drawer(&mut self)

Toggle the profile drawer visibility

Source

pub fn save_profiles(&self)

Save profiles to disk

Source

pub fn apply_profile_changes(&mut self, profiles: Vec<Profile>)

Update profile manager from modal working copy

Source

pub fn check_auto_profile_switch(&mut self) -> bool

Check for automatic profile switching based on hostname, SSH command, and directory detection

This checks the active tab for hostname and CWD changes (detected via OSC 7), SSH command detection, and applies matching profiles automatically. Priority: explicit user selection > hostname match > SSH command match > directory match > default

Returns true if a profile was auto-applied, triggering a redraw.

Source§

impl WindowState

Source

pub fn notify_tmux_of_resize(&self)

Notify tmux of a window/pane resize

Called when the window is resized to keep tmux in sync with par-term’s size. This sends refresh-client -C cols,rows to tmux in gateway mode.

Source

pub fn initiate_tmux_gateway( &mut self, session_name: Option<&str>, ) -> Result<()>

Initiate a new tmux session via gateway mode.

This writes tmux -CC new-session to the active tab’s PTY and enables tmux control mode parsing. The session will be fully connected once we receive the %session-changed notification.

§Arguments
  • session_name - Optional session name. If None, tmux will auto-generate one.
Source

pub fn attach_tmux_gateway(&mut self, session_name: &str) -> Result<()>

Attach to an existing tmux session via gateway mode.

This writes tmux -CC attach -t session to the active tab’s PTY.

Source

pub fn disconnect_tmux_session(&mut self)

Disconnect from the current tmux session

Source

pub fn is_tmux_connected(&self) -> bool

Check if tmux session is active

Source

pub fn is_gateway_active(&self) -> bool

Check if gateway mode is active (connected or connecting)

Source

pub fn set_tmux_focused_pane_from_native(&mut self, native_pane_id: PaneId)

Update the tmux focused pane when a native pane is focused

This should be called when the user clicks on a pane to ensure input is routed to the correct tmux pane.

Source

pub fn send_input_via_tmux(&self, data: &[u8]) -> bool

Send input through tmux gateway mode.

When in gateway mode, keyboard input is sent via send-keys command written to the gateway tab’s PTY. This routes input to the appropriate tmux pane.

Returns true if input was handled via tmux, false if it should go to PTY directly.

Source

pub fn paste_via_tmux(&self, text: &str) -> bool

Send paste text through tmux gateway mode.

Uses send-keys -l for literal text to handle special characters properly.

Source

pub fn split_pane_via_tmux(&self, vertical: bool) -> bool

Split the current pane via tmux control mode.

Writes split-window command to the gateway PTY.

§Arguments
  • vertical - true for vertical split (side by side), false for horizontal (stacked)

Returns true if the command was sent successfully.

Source

pub fn close_pane_via_tmux(&self) -> bool

Close the focused pane via tmux control mode.

Writes kill-pane command to the gateway PTY.

Returns true if the command was sent successfully.

Source

pub fn sync_clipboard_to_tmux(&self, content: &str) -> bool

Sync clipboard content to tmux paste buffer.

Writes set-buffer command to the gateway PTY.

Returns true if the command was sent successfully.

Source

pub fn sync_pane_resize_to_tmux(&self, is_horizontal_divider: bool)

Sync pane resize to tmux after a divider drag.

When the user resizes panes by dragging a divider in par-term, this sends the new pane sizes to tmux so external clients see the same layout.

§Arguments
  • is_horizontal_divider - true if dragging a horizontal divider (changes heights), false if dragging a vertical divider (changes widths)
Source

pub fn handle_tmux_prefix_key(&mut self, event: &KeyEvent) -> bool

Handle tmux prefix key mode

In control mode, we intercept the prefix key (e.g., Ctrl+B or Ctrl+Space) and wait for the next key to translate into a tmux command.

Returns true if the key was handled by the prefix system.

Source§

impl WindowState

Source

pub fn new(config: Config, runtime: Arc<Runtime>) -> Self

Create a new window state with the given configuration

Trait Implementations§

Source§

impl Drop for WindowState

Source§

fn drop(&mut self)

Executes the destructor for this 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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> 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> Same for T

Source§

type Output = T

Should always be Self
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> 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
Source§

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

Source§

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