Skip to main content

TerminalRawGuard

Struct TerminalRawGuard 

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

RAII terminal raw-mode, alternate-screen, mouse, and cursor restoration guard surviving normal and panic exits.

Implementations§

Source§

impl TerminalRawGuard

RAII terminal mode entry and idempotent restoration methods for TerminalRawGuard.

Source

pub fn enter_live( alt_screen: bool, mouse_enabled: bool, paste_enabled: bool, cursor_hidden: bool, ) -> Self

Enters live OS terminal raw mode (Unix termios / Windows VT console), installs SIGWINCH, and emits enter sequences.

§Arguments
  • bool - Enter alternate screen buffer.
  • bool - Enable SGR 1006 mouse tracking.
  • bool - Enable bracketed paste mode.
  • bool - Hide terminal cursor.
§Returns
  • Self - Active RAII guard restoring terminal state on drop.
Source

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

Creates a deterministic captured RAII guard writing enter/restore sequences into sink without mutating host TTY state.

§Arguments
  • bool - Emit alternate screen enter/leave sequences.
  • bool - Emit mouse enable/disable sequences.
  • bool - Emit bracketed paste enable/disable sequences.
  • bool - Emit cursor hide/show sequences.
  • Option<Rc<RefCell<String>>> - Optional capture sink recording emitted ANSI sequences.
§Returns
  • Self - Captured RAII terminal guard.
Source

pub fn restore(&mut self)

Idempotently restores terminal raw mode, SGR attributes, mouse/paste tracking, cursor visibility, and primary screen.

§Arguments
  • &Self - Mutable guard reference.
Source§

impl TerminalRawGuard

Source

pub fn get_os_raw_active(&self) -> bool

Source

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

Source

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

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_mouse_enabled(&self) -> bool

Source

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

Source

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

Source

pub fn get_paste_enabled(&self) -> bool

Source

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

Source

pub fn set_paste_enabled(&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_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 TerminalRawGuard

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 TerminalRawGuard

Guaranteed RAII terminal restoration on normal scope exit and panic unwind.

Source§

fn drop(&mut self)

Restores terminal state unconditionally when TerminalRawGuard drops.

§Arguments
  • &Self - Mutable 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.