Struct TerminalRawModeScope

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

Enable or disable the terminal raw mode while its instance is in scope.

While it automatically resets the mode when it’s out of scope, reset() should be called explicitly when the mode should be reset or at the end of the scope to avoid it being dropped earlier by the compiler.

§Examples

use git_iblame::extensions::TerminalRawModeScope;

let mut terminal_raw_mode = TerminalRawModeScope::new(true)?;
// Do the work.
// If it returns early, the terminal raw mode will be reset automatically.
terminal_raw_mode.reset()?;

Implementations§

Source§

impl TerminalRawModeScope

Source

pub fn new(enable: bool) -> Result<Self>

Enable the raw mode if enable is true, or disable it if enable is false.

Source

pub fn new_with_alternate_screen() -> Result<Self>

Switches to the alternate screen, in addition to the raw mode. See crossterm::terminal::EnterAlternateScreen.

Source

pub fn reset(&mut self) -> Result<()>

Reset the terminal raw mode. This should be called when the mode should be reset, or at the end of the scope.

Even if the mode should be reset at the end of the scope, and that the Drop trait should reset the raw mode, it should be called to avoid it being dropped earlier by the compiler.

Trait Implementations§

Source§

impl Debug for TerminalRawModeScope

Source§

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

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

impl Drop for TerminalRawModeScope

Source§

fn drop(&mut self)

Calls reset() if it’s not already reset. This is called when the instance goes out of scope.

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 = 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,