Skip to main content

Session

Struct Session 

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

A single detached RMUX session.

Implementations§

Source§

impl Session

Source

pub const fn name(&self) -> &SessionName

Returns the stable validated session name.

Source

pub const fn group_name(&self) -> Option<&SessionName>

Returns the named session group when the session is grouped.

Source

pub const fn id(&self) -> SessionId

Returns the store-assigned session identity used by $N targets.

Source

pub const fn created_at(&self) -> i64

Returns the session creation timestamp as Unix seconds.

Source

pub const fn activity_at(&self) -> i64

Returns the last session activity timestamp as Unix seconds.

Source

pub const fn last_attached_at(&self) -> Option<i64>

Returns the last attached timestamp as Unix seconds.

Source

pub fn cwd(&self) -> Option<&Path>

Returns the session working directory when one has been assigned.

Source

pub fn rename(&mut self, new_name: SessionName)

Renames the session without rewriting any other session state.

Source

pub fn set_group_name(&mut self, group_name: Option<SessionName>)

Assigns or clears the session group name without mutating any other session state.

Source

pub fn set_cwd(&mut self, cwd: Option<PathBuf>)

Updates the session working directory.

Source

pub fn touch_activity(&mut self)

Records session activity at the current time.

Source

pub fn touch_attached(&mut self)

Records that a client attached to the session at the current time.

Source

pub fn clone_as_group_member( &self, name: SessionName, group_name: SessionName, session_id: SessionId, ) -> Self

Clones the session as a grouped peer with a fresh identity and timestamps.

Source

pub fn synchronize_group_from(&mut self, source: &Session)

Synchronizes shared grouped-session window state from the source session while preserving the local current window when possible.

Source

pub fn window(&self) -> &Window

Returns the session’s active window.

Source

pub fn window_at(&self, window_index: u32) -> Option<&Window>

Returns the explicitly addressed window when it exists.

Source

pub const fn windows(&self) -> &BTreeMap<u32, Window>

Returns all windows keyed by window index.

Source

pub fn window_at_mut(&mut self, window_index: u32) -> Option<&mut Window>

Returns the addressed window as a mutable reference when it exists.

Returns the persistent alert flags for the addressed window slot.

Source

pub fn session_alert_flags(&self) -> AlertFlags

Returns the combined session alert flags across all alerted windows.

Source

pub fn alerted_window_indexes(&self) -> Vec<u32>

Returns the alerted window indexes in display order.

Source

pub fn has_alerts(&self) -> bool

Returns whether any window in the session currently carries an alert.

Adds persistent alert flags to the addressed session winlink.

Clears the selected persistent alert flags from the addressed session winlink.

Clears all persistent alert flags from the addressed session winlink.

Source

pub const fn active_window_index(&self) -> u32

Returns the active window index.

Source

pub const fn last_window_index(&self) -> Option<u32>

Returns the previously active window index when one exists.

Source

pub fn active_pane_index(&self) -> u32

Returns the active pane index owned by the session.

Source

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

Returns the stable internal identity for the active pane.

Source

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

Returns the active pane when the session invariant is satisfied.

Source

pub fn pane_id(&self, pane_index: u32) -> Option<PaneId>

Returns the stable internal identity for a pane in the active window.

Source

pub fn pane_id_in_window( &self, window_index: u32, pane_index: u32, ) -> Option<PaneId>

Returns the stable internal identity for a pane in the addressed window.

Source§

impl Session

Source

pub fn select_layout(&mut self, layout: LayoutName)

Applies a layout to the session’s active window.

Source

pub fn select_layout_in_window( &mut self, window_index: u32, layout: LayoutName, ) -> Result<(), RmuxError>

Applies a layout to the addressed window.

Source

pub fn select_layout_in_window_with_main_pane_size( &mut self, window_index: u32, layout: LayoutName, main_width: Option<u16>, main_height: Option<u16>, ) -> Result<(), RmuxError>

Applies a layout to the addressed window using tmux main-pane-* option values.

Source

pub fn select_custom_layout_in_window( &mut self, window_index: u32, layout: &str, ) -> Result<(), RmuxError>

Applies a tmux custom layout string to the addressed window.

Source

pub fn reapply_old_layout_in_window( &mut self, window_index: u32, ) -> Result<bool, RmuxError>

Reapplies the previously saved tmux old layout to the addressed window.

Source

pub fn save_old_layout_in_window( &mut self, window_index: u32, ) -> Result<(), RmuxError>

Saves the current serialized layout as the window old layout.

Source

pub fn spread_layout_in_window( &mut self, window_index: u32, ) -> Result<bool, RmuxError>

Spreads the addressed window around its active pane, matching tmux select-layout -E.

Source

pub fn next_layout_in_window( &mut self, window_index: u32, ) -> Result<LayoutName, RmuxError>

Selects the next tmux-standard layout for the addressed window.

Source

pub fn next_layout_in_window_with_main_pane_size( &mut self, window_index: u32, main_width: Option<u16>, main_height: Option<u16>, ) -> Result<LayoutName, RmuxError>

Selects the next tmux-standard layout using tmux main-pane-* option values.

Source

pub fn previous_layout_in_window( &mut self, window_index: u32, ) -> Result<LayoutName, RmuxError>

Selects the previous tmux-standard layout for the addressed window.

Source

pub fn previous_layout_in_window_with_main_pane_size( &mut self, window_index: u32, main_width: Option<u16>, main_height: Option<u16>, ) -> Result<LayoutName, RmuxError>

Selects the previous tmux-standard layout using tmux main-pane-* option values.

Source§

impl Session

Source

pub fn break_pane( &mut self, source: SessionPaneTarget, options: BreakPaneOptions, ) -> Result<u32, RmuxError>

Breaks one pane out into another window in the same session.

Source§

impl Session

Source

pub fn last_pane_in_window( &mut self, window_index: u32, ) -> Result<u32, RmuxError>

Selects the previously active pane in the addressed window.

Source

pub fn swap_panes( &mut self, source: SessionPaneTarget, target: SessionPaneTarget, options: PaneSwapOptions, ) -> Result<(), RmuxError>

Swaps two panes within the same session without renumbering either pane.

Source

pub fn join_pane( &mut self, source: SessionPaneTarget, target: SessionPaneTarget, options: PaneJoinOptions, ) -> Result<(), RmuxError>

Moves one pane next to another pane in the same session.

Source§

impl Session

Source

pub fn swap_panes_with_session( &mut self, source: SessionPaneTarget, target_session: &mut Session, target: SessionPaneTarget, options: PaneSwapOptions, ) -> Result<(), RmuxError>

Swaps one pane in this session with one pane in another session.

Source

pub fn join_pane_from_session( &mut self, target: SessionPaneTarget, source_session: &mut Session, source: SessionPaneTarget, options: PaneJoinOptions, ) -> Result<(), RmuxError>

Moves one pane from another session into this session.

Source

pub fn break_pane_to_session( &mut self, source: SessionPaneTarget, destination_session: &mut Session, options: BreakPaneOptions, ) -> Result<u32, RmuxError>

Breaks one pane out into another session as its own window.

Source§

impl Session

Source

pub fn select_window(&mut self, window_index: u32) -> Result<(), RmuxError>

Selects the active window by index.

Source

pub fn next_window(&mut self) -> Result<u32, RmuxError>

Selects the next window in sparse index order, wrapping to the lowest index.

Source

pub fn next_window_with_alerts(&mut self) -> Result<u32, RmuxError>

Selects the next alerted window in sparse index order.

Source

pub fn previous_window(&mut self) -> Result<u32, RmuxError>

Selects the previous window in sparse index order, wrapping to the highest index.

Source

pub fn previous_window_with_alerts(&mut self) -> Result<u32, RmuxError>

Selects the previous alerted window in sparse index order.

Source

pub fn last_window(&mut self) -> Result<u32, RmuxError>

Selects the most recently active window.

Restores tmux’s winlink stack fallback after unlinking an active linked slot.

Source§

impl Session

Source

pub fn create_window( &mut self, size: TerminalSize, ) -> Result<(u32, PaneId), RmuxError>

Creates a new window at the lowest available index and returns its window index together with the initial pane ID.

Source

pub fn create_window_at_or_above( &mut self, size: TerminalSize, minimum_index: u32, ) -> Result<(u32, PaneId), RmuxError>

Creates a new window at the lowest available index at or above minimum_index.

Source

pub fn create_window_at_or_above_with_pane_id( &mut self, size: TerminalSize, minimum_index: u32, pane_id: PaneId, ) -> Result<(u32, PaneId), RmuxError>

Creates a new window at the lowest available index at or above minimum_index using the provided initial pane identity.

Source

pub fn insert_window_with_initial_pane( &mut self, window_index: u32, size: TerminalSize, ) -> Result<(), RmuxError>

Inserts a window with its initial pane at the provided window index.

Source

pub fn insert_window_with_initial_pane_with_id( &mut self, window_index: u32, size: TerminalSize, pane_id: PaneId, ) -> Result<(), RmuxError>

Inserts a window with its initial pane at the provided window index using the supplied pane identity.

Source

pub fn insert_existing_window( &mut self, window_index: u32, window: Window, ) -> Result<(), RmuxError>

Inserts an existing window at the provided window index without rewriting its identities.

Source

pub fn make_room_for_window( &mut self, window_index: u32, ) -> Result<(), RmuxError>

Opens a destination slot for link-window style insertion by shifting existing winlinks upward.

Inserts a linked copy of an existing window at the destination slot.

Source

pub fn replace_window( &mut self, window_index: u32, window: Window, ) -> Result<Window, RmuxError>

Replaces an existing window at the provided index and returns the removed window.

Source

pub fn remove_window(&mut self, window_index: u32) -> Result<Window, RmuxError>

Removes the addressed window and returns it, using tmux’s last-then-previous-then-next active fallback when needed.

Source

pub fn rename_window( &mut self, window_index: u32, name: String, ) -> Result<(), RmuxError>

Renames the addressed window and disables automatic renaming for it.

Source

pub fn set_automatic_window_name( &mut self, window_index: u32, name: String, ) -> Result<(), RmuxError>

Updates the addressed window name while preserving automatic renaming.

Source

pub fn reindex_windows(&mut self) -> Result<BTreeMap<u32, u32>, RmuxError>

Reindexes sparse window slots into a contiguous 0..n range without rewriting the windows themselves.

Source

pub fn move_window( &mut self, source_index: u32, destination_index: u32, kill_destination: bool, select_destination: bool, ) -> Result<Option<Window>, RmuxError>

Moves one window to another slot within the same session, optionally removing an occupied destination.

When select_destination is true, the destination slot becomes active using tmux’s winlink-based selection semantics instead of following the moved window by identity.

Source

pub fn swap_windows( &mut self, source_index: u32, destination_index: u32, ) -> Result<(), RmuxError>

Swaps two window slots within the same session while preserving the underlying windows.

Source

pub fn rotate_window( &mut self, window_index: u32, direction: RotateWindowDirection, ) -> Result<(), RmuxError>

Rotates pane positions in the addressed window without renumbering the panes themselves.

Source

pub fn rotate_window_with_zoom( &mut self, window_index: u32, direction: RotateWindowDirection, restore_zoom: bool, ) -> Result<(), RmuxError>

Rotates pane positions with zoom save/restore via -Z.

Source

pub fn resize_window( &mut self, window_index: u32, size: TerminalSize, ) -> Result<(), RmuxError>

Sets the explicit size of the addressed window.

Source

pub fn respawn_window(&mut self, window_index: u32) -> Result<PaneId, RmuxError>

Respawns the addressed window, replacing it with a single pane. Returns the pane ID retained for the respawned pane.

Source

pub fn respawn_window_with_pane_id( &mut self, window_index: u32, pane_id: PaneId, ) -> Result<PaneId, RmuxError>

Respawns the addressed window with an explicitly provided pane identity.

Source§

impl Session

Source

pub fn new(name: SessionName, size: TerminalSize) -> Self

Creates a new session with its initial pane active.

Source

pub fn split_active_pane(&mut self) -> Result<u32, RmuxError>

Splits the current active pane and returns the new pane index, making the new pane active.

Source

pub fn split_active_pane_with_direction( &mut self, direction: SplitDirection, ) -> Result<u32, RmuxError>

Splits the current active pane in the requested direction.

Source

pub fn split_pane(&mut self, pane_index: u32) -> Result<u32, RmuxError>

Splits the addressed pane, inserting the new pane immediately after the split target in window order.

Source

pub fn split_pane_with_direction( &mut self, pane_index: u32, direction: SplitDirection, ) -> Result<u32, RmuxError>

Splits the addressed pane in the active window using the requested direction.

Source

pub fn split_pane_in_window( &mut self, window_index: u32, pane_index: u32, ) -> Result<u32, RmuxError>

Splits the addressed pane in the addressed window and returns the new pane index.

Source

pub fn split_pane_in_window_with_direction( &mut self, window_index: u32, pane_index: u32, direction: SplitDirection, ) -> Result<u32, RmuxError>

Splits the addressed pane in the addressed window using the requested direction.

Source

pub fn split_pane_in_window_with_direction_before( &mut self, window_index: u32, pane_index: u32, direction: SplitDirection, before: bool, ) -> Result<u32, RmuxError>

Splits the addressed pane in the addressed window using the requested direction, controlling whether the new pane is inserted before the target on the chosen axis (tmux -b).

Source

pub fn split_pane_in_window_with_id_and_direction( &mut self, window_index: u32, pane_index: u32, pane_id: PaneId, direction: SplitDirection, ) -> Result<u32, RmuxError>

Splits the addressed pane in the addressed window using the provided pane identity.

The new pane is inserted after the target on the chosen axis. Callers that need tmux -b semantics (insert before) should use Session::split_pane_in_window_with_id_and_direction_before.

Source

pub fn split_pane_in_window_with_id_and_direction_before( &mut self, window_index: u32, pane_index: u32, pane_id: PaneId, direction: SplitDirection, before: bool, ) -> Result<u32, RmuxError>

Splits the addressed pane, controlling whether the new pane lands before (-b) or after the target on the chosen axis.

Source

pub fn kill_pane( &mut self, pane_index: u32, ) -> Result<KillPaneOutcome, RmuxError>

Removes the addressed pane in the active window.

Source

pub fn kill_pane_in_window( &mut self, window_index: u32, pane_index: u32, ) -> Result<KillPaneOutcome, RmuxError>

Removes the addressed pane or destroys its window when it is the last pane there.

Source

pub fn kill_other_panes_in_window( &mut self, window_index: u32, pane_index: u32, ) -> Result<KillPaneOutcome, RmuxError>

Removes every pane except the addressed pane, matching kill-pane -a.

Source

pub fn select_pane(&mut self, pane_index: u32) -> Result<(), RmuxError>

Selects the active pane for the session.

Source

pub fn select_pane_in_window( &mut self, window_index: u32, pane_index: u32, ) -> Result<(), RmuxError>

Selects the active pane for the addressed window.

Source

pub fn select_adjacent_pane_in_window( &mut self, window_index: u32, pane_index: u32, direction: SelectPaneDirection, ) -> Result<u32, RmuxError>

Selects the pane adjacent to the addressed pane in the requested direction.

Source

pub fn resize_pane( &mut self, pane_index: u32, adjustment: ResizePaneAdjustment, ) -> Result<(), RmuxError>

Applies the supported resize adjustment to the session layout by updating the main-vertical main-pane width.

Source

pub fn resize_pane_in_window( &mut self, window_index: u32, pane_index: u32, adjustment: ResizePaneAdjustment, ) -> Result<(), RmuxError>

Applies the supported resize adjustment to the addressed window.

Source

pub fn toggle_zoom_in_window( &mut self, window_index: u32, pane_index: u32, ) -> Result<(), RmuxError>

Toggles zoom for the addressed pane’s window.

Source

pub fn resize_terminal(&mut self, size: TerminalSize)

Updates the backing terminal size and recalculates pane geometry for all windows.

Source

pub fn window_index_for_pane_id(&self, pane_id: PaneId) -> Option<u32>

Resolves the owning window index for the given pane identity when present.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

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 Session

Source§

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

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

impl PartialEq for Session

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Session

Source§

impl StructuralPartialEq for Session

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