pub struct TerminalManager { /* private fields */ }Expand description
Terminal manager that wraps the PTY session
Implementations§
Source§impl TerminalManager
impl TerminalManager
Sourcepub fn new(cols: usize, rows: usize) -> Result<Self>
pub fn new(cols: usize, rows: usize) -> Result<Self>
Create a new terminal manager with the specified dimensions
Sourcepub fn new_with_scrollback(
cols: usize,
rows: usize,
scrollback_size: usize,
) -> Result<Self>
pub fn new_with_scrollback( cols: usize, rows: usize, scrollback_size: usize, ) -> Result<Self>
Create a new terminal manager with specified dimensions and scrollback size
Sourcepub fn set_cell_dimensions(&self, width: u32, height: u32)
pub fn set_cell_dimensions(&self, width: u32, height: u32)
Set cell dimensions in pixels for sixel graphics scroll calculations
This should be called when the renderer is initialized or cell size changes. Default is (1, 2) for TUI half-block rendering.
Sourcepub fn spawn_shell(&mut self) -> Result<()>
pub fn spawn_shell(&mut self) -> Result<()>
Spawn a shell in the terminal
Sourcepub fn spawn_custom_shell(&mut self, command: &str) -> Result<()>
pub fn spawn_custom_shell(&mut self, command: &str) -> Result<()>
Spawn a custom shell command in the terminal
§Arguments
command- The shell command to execute (e.g., “/bin/zsh”, “fish”)
Sourcepub fn spawn_custom_shell_with_args(
&mut self,
command: &str,
args: &[String],
) -> Result<()>
pub fn spawn_custom_shell_with_args( &mut self, command: &str, args: &[String], ) -> Result<()>
Spawn a custom shell with arguments
§Arguments
command- The shell command to executeargs- Arguments to pass to the shell
Sourcepub fn spawn_shell_with_dir(
&mut self,
working_dir: Option<&str>,
env_vars: Option<&HashMap<String, String>>,
) -> Result<()>
pub fn spawn_shell_with_dir( &mut self, working_dir: Option<&str>, env_vars: Option<&HashMap<String, String>>, ) -> Result<()>
Spawn shell with optional working directory and environment variables
§Arguments
working_dir- Optional working directory pathenv_vars- Optional environment variables to set
Sourcepub fn spawn_custom_shell_with_dir(
&mut self,
command: &str,
args: Option<&[String]>,
working_dir: Option<&str>,
env_vars: Option<&HashMap<String, String>>,
) -> Result<()>
pub fn spawn_custom_shell_with_dir( &mut self, command: &str, args: Option<&[String]>, working_dir: Option<&str>, env_vars: Option<&HashMap<String, String>>, ) -> Result<()>
Spawn custom shell with args, optional working directory, and environment variables
§Arguments
command- The shell command to executeargs- Arguments to pass to the shellworking_dir- Optional working directory pathenv_vars- Optional environment variables to set
Sourcepub fn write(&self, data: &[u8]) -> Result<()>
pub fn write(&self, data: &[u8]) -> Result<()>
Write data to the PTY (send user input to shell)
Sourcepub fn resize_with_pixels(
&mut self,
cols: usize,
rows: usize,
width_px: usize,
height_px: usize,
) -> Result<()>
pub fn resize_with_pixels( &mut self, cols: usize, rows: usize, width_px: usize, height_px: usize, ) -> Result<()>
Resize the terminal with pixel dimensions This sets both the character dimensions AND pixel dimensions in the PTY winsize struct, which is required for applications like kitty icat that query pixel dimensions via TIOCGWINSZ
Sourcepub fn set_pixel_size(
&mut self,
width_px: usize,
height_px: usize,
) -> Result<()>
pub fn set_pixel_size( &mut self, width_px: usize, height_px: usize, ) -> Result<()>
Set pixel dimensions for XTWINOPS CSI 14 t query support
Sourcepub fn dimensions(&self) -> (usize, usize)
pub fn dimensions(&self) -> (usize, usize)
Get the current terminal dimensions
Sourcepub fn terminal(&self) -> Arc<Mutex<Terminal>>
pub fn terminal(&self) -> Arc<Mutex<Terminal>>
Get a clone of the underlying terminal for direct access
Sourcepub fn has_updates(&self) -> bool
pub fn has_updates(&self) -> bool
Check if there have been updates since last check
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the PTY is still running
Sourcepub fn bell_count(&self) -> u64
pub fn bell_count(&self) -> u64
Get the current bell event count
Sourcepub fn scrollback(&self) -> Vec<String>
pub fn scrollback(&self) -> Vec<String>
Get scrollback lines
Sourcepub fn scrollback_len(&self) -> usize
pub fn scrollback_len(&self) -> usize
Get scrollback length
Sourcepub fn clear_scrollback(&self)
pub fn clear_scrollback(&self)
Clear scrollback buffer
Removes all scrollback history while preserving the current screen content. Uses CSI 3 J (ED 3) escape sequence which is the standard way to clear scrollback.
Sourcepub fn take_notifications(&self) -> Vec<Notification>
pub fn take_notifications(&self) -> Vec<Notification>
Take all pending OSC 9/777 notifications
Sourcepub fn has_notifications(&self) -> bool
pub fn has_notifications(&self) -> bool
Check if there are pending OSC 9/777 notifications
Sourcepub fn screenshot_to_file(
&self,
path: &Path,
format: &str,
scrollback_lines: usize,
) -> Result<()>
pub fn screenshot_to_file( &self, path: &Path, format: &str, scrollback_lines: usize, ) -> Result<()>
Take a screenshot of the terminal and save to file
§Arguments
path- Path to save the screenshotformat- Screenshot format (“png”, “jpeg”, “svg”, “html”)scrollback_lines- Number of scrollback lines to include (0 for none)
Sourcepub fn shell_integration_cwd(&self) -> Option<String>
pub fn shell_integration_cwd(&self) -> Option<String>
Get current working directory from shell integration (OSC 7)
Sourcepub fn shell_integration_exit_code(&self) -> Option<i32>
pub fn shell_integration_exit_code(&self) -> Option<i32>
Get last command exit code from shell integration (OSC 133)
Sourcepub fn shell_integration_command(&self) -> Option<String>
pub fn shell_integration_command(&self) -> Option<String>
Get current command from shell integration
Sourcepub fn get_graphics(&self) -> Vec<TerminalGraphic>
pub fn get_graphics(&self) -> Vec<TerminalGraphic>
Get all graphics (Sixel, iTerm2, Kitty) Returns a vector of cloned TerminalGraphic objects for rendering
Sourcepub fn get_graphics_at_row(&self, row: usize) -> Vec<TerminalGraphic>
pub fn get_graphics_at_row(&self, row: usize) -> Vec<TerminalGraphic>
Get graphics at a specific row
Sourcepub fn graphics_count(&self) -> usize
pub fn graphics_count(&self) -> usize
Get total graphics count
Sourcepub fn get_all_hyperlinks(&self) -> Vec<HyperlinkInfo>
pub fn get_all_hyperlinks(&self) -> Vec<HyperlinkInfo>
Get all OSC 8 hyperlinks from the terminal
Sourcepub fn get_hyperlink_url(&self, hyperlink_id: u32) -> Option<String>
pub fn get_hyperlink_url(&self, hyperlink_id: u32) -> Option<String>
Get the URL for a specific hyperlink ID
Sourcepub fn get_scrollback_graphics(&self) -> Vec<TerminalGraphic>
pub fn get_scrollback_graphics(&self) -> Vec<TerminalGraphic>
Get all scrollback graphics
Sourcepub fn update_animations(&self) -> bool
pub fn update_animations(&self) -> bool
Update animations and return true if any frames changed
This should be called periodically (e.g., in the redraw loop) to advance animation frames based on timing. Returns true if any animation advanced to a new frame, indicating that a redraw is needed.
Sourcepub fn get_graphics_with_animations(&self) -> Vec<TerminalGraphic>
pub fn get_graphics_with_animations(&self) -> Vec<TerminalGraphic>
Get all graphics with current animation frames
For animated graphics, returns the current frame based on animation state. For static graphics, returns the original graphic unchanged.
Sourcepub fn cursor_position(&self) -> (usize, usize)
pub fn cursor_position(&self) -> (usize, usize)
Get cursor position
Sourcepub fn cursor_style(&self) -> CursorStyle
pub fn cursor_style(&self) -> CursorStyle
Get cursor style from terminal for rendering
Sourcepub fn is_cursor_visible(&self) -> bool
pub fn is_cursor_visible(&self) -> bool
Check if cursor is visible (controlled by DECTCEM escape sequence)
TUI applications typically hide the cursor when entering alternate screen mode. Returns false when the terminal has received CSI ?25l (hide cursor).
Sourcepub fn is_mouse_tracking_enabled(&self) -> bool
pub fn is_mouse_tracking_enabled(&self) -> bool
Check if mouse tracking is enabled
Sourcepub fn is_alt_screen_active(&self) -> bool
pub fn is_alt_screen_active(&self) -> bool
Check if alternate screen is active (used by TUI applications)
When the alternate screen is active, text selection should typically be disabled as the content is controlled by an application (vim, htop, etc.) rather than being scrollback history.
Sourcepub fn get_title(&self) -> String
pub fn get_title(&self) -> String
Get the terminal title set by OSC 0, 1, or 2 sequences
Returns the title string that applications have set via escape sequences. Returns empty string if no title has been set.
Sourcepub fn should_report_mouse_motion(&self, button_pressed: bool) -> bool
pub fn should_report_mouse_motion(&self, button_pressed: bool) -> bool
Check if mouse motion events should be reported Returns true if mode is ButtonEvent or AnyEvent
Sourcepub fn encode_mouse_event(
&self,
button: u8,
col: usize,
row: usize,
pressed: bool,
modifiers: u8,
) -> Vec<u8> ⓘ
pub fn encode_mouse_event( &self, button: u8, col: usize, row: usize, pressed: bool, modifiers: u8, ) -> Vec<u8> ⓘ
Send a mouse event to the terminal and get the encoded bytes
§Arguments
button- Mouse button (0 = left, 1 = middle, 2 = right)col- Column position (0-indexed)row- Row position (0-indexed)pressed- true for press, false for releasemodifiers- Modifier keys bit mask
§Returns
Encoded mouse event bytes to send to PTY, or empty vec if tracking is disabled
Sourcepub fn get_styled_segments(&self) -> Vec<StyledSegment>
pub fn get_styled_segments(&self) -> Vec<StyledSegment>
Get styled segments from the terminal for rendering
Sourcepub fn update_generation(&self) -> u64
pub fn update_generation(&self) -> u64
Get the current generation number for dirty tracking
The generation number increments whenever the terminal content changes. This can be used to detect when a cached representation needs to be updated.
Sourcepub fn get_cells_with_scrollback(
&self,
scroll_offset: usize,
selection: Option<((usize, usize), (usize, usize))>,
rectangular: bool,
_cursor: Option<((usize, usize), f32)>,
) -> Vec<Cell>
pub fn get_cells_with_scrollback( &self, scroll_offset: usize, selection: Option<((usize, usize), (usize, usize))>, rectangular: bool, _cursor: Option<((usize, usize), f32)>, ) -> Vec<Cell>
Get terminal grid with scrollback offset as Cell array for CellRenderer
§Arguments
scroll_offset- Number of lines to scroll back (0 = current view at bottom)selection- Optional selection range (start_col, start_row, end_col, end_row) in screen coordinatesrectangular- Whether the selection is rectangular/block mode (default: false)cursor- Optional cursor (position, opacity) for smooth fade animations
Source§impl TerminalManager
impl TerminalManager
Sourcepub fn get_clipboard_history(&self, slot: ClipboardSlot) -> Vec<ClipboardEntry>
pub fn get_clipboard_history(&self, slot: ClipboardSlot) -> Vec<ClipboardEntry>
Get clipboard history for a specific slot
Sourcepub fn get_latest_clipboard(
&self,
slot: ClipboardSlot,
) -> Option<ClipboardEntry>
pub fn get_latest_clipboard( &self, slot: ClipboardSlot, ) -> Option<ClipboardEntry>
Get the most recent clipboard entry for a slot
Sourcepub fn search_clipboard_history(
&self,
query: &str,
slot: Option<ClipboardSlot>,
) -> Vec<ClipboardEntry>
pub fn search_clipboard_history( &self, query: &str, slot: Option<ClipboardSlot>, ) -> Vec<ClipboardEntry>
Search clipboard history across all slots or a specific slot
Sourcepub fn add_to_clipboard_history(
&self,
slot: ClipboardSlot,
content: String,
label: Option<String>,
)
pub fn add_to_clipboard_history( &self, slot: ClipboardSlot, content: String, label: Option<String>, )
Add content to clipboard history
Sourcepub fn clear_clipboard_history(&self, slot: ClipboardSlot)
pub fn clear_clipboard_history(&self, slot: ClipboardSlot)
Clear clipboard history for a specific slot
Sourcepub fn clear_all_clipboard_history(&self)
pub fn clear_all_clipboard_history(&self)
Clear all clipboard history
Sourcepub fn set_max_clipboard_sync_events(&self, max: usize)
pub fn set_max_clipboard_sync_events(&self, max: usize)
Set maximum clipboard sync events retained
Sourcepub fn set_max_clipboard_event_bytes(&self, max_bytes: usize)
pub fn set_max_clipboard_event_bytes(&self, max_bytes: usize)
Set maximum bytes cached per clipboard event
Sourcepub fn set_max_clipboard_sync_history(&self, max: usize)
pub fn set_max_clipboard_sync_history(&self, max: usize)
Set maximum clipboard history entries per slot
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TerminalManager
impl !RefUnwindSafe for TerminalManager
impl Send for TerminalManager
impl Sync for TerminalManager
impl Unpin for TerminalManager
impl !UnwindSafe for TerminalManager
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<T> DowncastSync for T
impl<T> DowncastSync for T
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