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
impl TerminalRawModeScope
Sourcepub fn new(enable: bool) -> Result<Self>
pub fn new(enable: bool) -> Result<Self>
Enable the raw mode if enable
is true,
or disable it if enable
is false.
Sourcepub fn new_with_alternate_screen() -> Result<Self>
pub fn new_with_alternate_screen() -> Result<Self>
Switches to the alternate screen, in addition to the raw mode.
See crossterm::terminal::EnterAlternateScreen
.
Sourcepub fn reset(&mut self) -> Result<()>
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
impl Debug for TerminalRawModeScope
Auto Trait Implementations§
impl Freeze for TerminalRawModeScope
impl RefUnwindSafe for TerminalRawModeScope
impl Send for TerminalRawModeScope
impl Sync for TerminalRawModeScope
impl Unpin for TerminalRawModeScope
impl UnwindSafe for TerminalRawModeScope
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
Mutably borrows from an owned value. Read more