Skip to main content

TerminalSessionGuard

Struct TerminalSessionGuard 

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

RAII terminal session guard restoring cursor visibility, raw mode flags, and alternate screen on drop.

Implementations§

Source§

impl TerminalSessionGuard

Session lifecycle entry and idempotent ANSI state restoration for TerminalSessionGuard.

Source

pub fn build_enter_sequence( alt_screen: bool, cursor_hidden: bool, raw_mode: bool, ) -> String

Builds the escape sequence required to enter the configured interactive terminal modes.

§Arguments
  • bool - Whether to enter the alternate screen buffer.
  • bool - Whether to hide the terminal cursor.
  • bool - Whether to enable raw bracketed input mode.
§Returns
  • String - Concatenated ANSI enter sequence.
Source

pub fn build_restore_sequence( alt_screen: bool, cursor_hidden: bool, raw_mode: bool, ) -> String

Builds the escape sequence required to cleanly restore terminal state upon exit or unwind.

§Arguments
  • bool - Whether alternate screen mode was entered.
  • bool - Whether cursor visibility was hidden.
  • bool - Whether raw input modes were enabled.
§Returns
  • String - Concatenated ANSI restoration sequence.
Source

pub fn enter_captured( alt_screen: bool, cursor_hidden: bool, raw_mode: bool, sink: Option<Rc<RefCell<String>>>, ) -> Self

Enters an interactive terminal session writing enter/restore sequences to an optional capture buffer.

§Arguments
  • bool - Enter alternate screen buffer.
  • bool - Hide terminal cursor.
  • bool - Enable raw input tracking modes.
  • Option<Rc<RefCell<String>>> - Optional capture buffer for deterministic testing or virtual PTYs.
§Returns
  • Self - Active RAII session guard.
Source

pub fn enter_stdout( alt_screen: bool, cursor_hidden: bool, raw_mode: bool, ) -> Self

Enters an interactive terminal session flushing enter and restore sequences directly to stdout on native targets.

§Arguments
  • bool - Enter alternate screen buffer.
  • bool - Hide terminal cursor.
  • bool - Enable raw input tracking modes.
§Returns
  • Self - Active RAII session guard bound to stdout.
Source

pub fn restore_now(&mut self) -> String

Restores terminal state immediately if not already restored and returns the emitted ANSI sequence.

§Arguments
  • &Self - Mutable session guard.
§Returns
  • String - Restoration escape sequence emitted (empty if already restored).
Source§

impl TerminalSessionGuard

Source

pub fn get_alt_screen(&self) -> bool

Source

pub fn get_mut_alt_screen(&mut self) -> &mut bool

Source

pub fn set_alt_screen(&mut self, val: bool) -> &mut Self

Source

pub fn get_cursor_hidden(&self) -> bool

Source

pub fn get_mut_cursor_hidden(&mut self) -> &mut bool

Source

pub fn set_cursor_hidden(&mut self, val: bool) -> &mut Self

Source

pub fn get_raw_mode(&self) -> bool

Source

pub fn get_mut_raw_mode(&mut self) -> &mut bool

Source

pub fn set_raw_mode(&mut self, val: bool) -> &mut Self

Source

pub fn get_restored(&self) -> bool

Source

pub fn get_mut_restored(&mut self) -> &mut bool

Source

pub fn set_restored(&mut self, val: bool) -> &mut Self

Source

pub fn get_write_to_stdout(&self) -> bool

Source

pub fn get_mut_write_to_stdout(&mut self) -> &mut bool

Source

pub fn set_write_to_stdout(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl Debug for TerminalSessionGuard

Source§

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

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.
Source§

impl Drop for TerminalSessionGuard

Guaranteed RAII restoration of cursor, raw mode, and alternate screen on normal exit or panic unwind.

Source§

fn drop(&mut self)

Restores terminal modes automatically when the guard leaves scope.

§Arguments
  • &Self - Mutable session guard being dropped.
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§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.