pub struct WindowState { /* private fields */ }Expand description
Per-window state that manages a single terminal window with multiple tabs
Implementations§
Source§impl WindowState
impl WindowState
Sourcepub fn new_tab_or_show_profiles(&mut self)
pub fn new_tab_or_show_profiles(&mut self)
Create a new tab, or show profile picker if configured and profiles exist
Sourcepub fn close_current_tab(&mut self) -> bool
pub fn close_current_tab(&mut self) -> bool
Close the current tab Returns true if the window should close (last tab was closed)
Sourcepub fn close_current_tab_immediately(&mut self) -> bool
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)
Sourcepub fn reopen_closed_tab(&mut self)
pub fn reopen_closed_tab(&mut self)
Reopen the most recently closed tab at its original position
Sourcepub fn switch_to_tab_index(&mut self, index: usize)
pub fn switch_to_tab_index(&mut self, index: usize)
Switch to tab by index (1-based)
Sourcepub fn move_tab_left(&mut self)
pub fn move_tab_left(&mut self)
Move current tab left
Sourcepub fn move_tab_right(&mut self)
pub fn move_tab_right(&mut self)
Move current tab right
Sourcepub fn duplicate_tab(&mut self)
pub fn duplicate_tab(&mut self)
Duplicate current tab
Sourcepub fn duplicate_tab_by_id(&mut self, source_tab_id: TabId)
pub fn duplicate_tab_by_id(&mut self, source_tab_id: TabId)
Duplicate a specific tab by ID
Sourcepub fn has_multiple_tabs(&self) -> bool
pub fn has_multiple_tabs(&self) -> bool
Check if there are multiple tabs
Sourcepub fn active_terminal(&self) -> Option<&Arc<Mutex<TerminalManager>>>
pub fn active_terminal(&self) -> Option<&Arc<Mutex<TerminalManager>>>
Get the active tab’s terminal
Sourcepub fn split_pane_horizontal(&mut self)
pub fn split_pane_horizontal(&mut self)
Split the current pane horizontally (panes stacked top/bottom)
Sourcepub fn split_pane_vertical(&mut self)
pub fn split_pane_vertical(&mut self)
Split the current pane vertically (panes side by side)
Sourcepub fn close_focused_pane(&mut self) -> bool
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).
Sourcepub fn has_multiple_panes(&self) -> bool
pub fn has_multiple_panes(&self) -> bool
Check if the current tab has multiple panes
Navigate to an adjacent pane in the given direction
Sourcepub fn resize_pane(&mut self, direction: NavigationDirection)
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
Sourcepub fn open_profile(&mut self, profile_id: ProfileId)
pub fn open_profile(&mut self, profile_id: ProfileId)
Open a new tab from a profile
Sourcepub fn toggle_profile_drawer(&mut self)
pub fn toggle_profile_drawer(&mut self)
Toggle the profile drawer visibility
Sourcepub fn save_profiles(&self)
pub fn save_profiles(&self)
Save profiles to disk
Sourcepub fn apply_profile_changes(&mut self, profiles: Vec<Profile>)
pub fn apply_profile_changes(&mut self, profiles: Vec<Profile>)
Update profile manager from modal working copy
Sourcepub fn check_auto_profile_switch(&mut self) -> bool
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
impl WindowState
Sourcepub fn notify_tmux_of_resize(&self)
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.
Sourcepub fn initiate_tmux_gateway(
&mut self,
session_name: Option<&str>,
) -> Result<()>
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.
Sourcepub fn attach_tmux_gateway(&mut self, session_name: &str) -> Result<()>
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.
Sourcepub fn disconnect_tmux_session(&mut self)
pub fn disconnect_tmux_session(&mut self)
Disconnect from the current tmux session
Sourcepub fn is_tmux_connected(&self) -> bool
pub fn is_tmux_connected(&self) -> bool
Check if tmux session is active
Sourcepub fn is_gateway_active(&self) -> bool
pub fn is_gateway_active(&self) -> bool
Check if gateway mode is active (connected or connecting)
Sourcepub fn set_tmux_focused_pane_from_native(&mut self, native_pane_id: PaneId)
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.
Sourcepub fn send_input_via_tmux(&self, data: &[u8]) -> bool
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.
Sourcepub fn paste_via_tmux(&self, text: &str) -> bool
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.
Sourcepub fn split_pane_via_tmux(&self, vertical: bool) -> bool
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.
Sourcepub fn close_pane_via_tmux(&self) -> bool
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.
Sourcepub fn sync_clipboard_to_tmux(&self, content: &str) -> bool
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.
Sourcepub fn sync_pane_resize_to_tmux(&self, is_horizontal_divider: bool)
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)
Sourcepub fn handle_tmux_prefix_key(&mut self, event: &KeyEvent) -> bool
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WindowState
impl !RefUnwindSafe for WindowState
impl Send for WindowState
impl !Sync for WindowState
impl Unpin for WindowState
impl UnsafeUnpin for WindowState
impl !UnwindSafe for WindowState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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