pub struct TerminalSession { /* private fields */ }Expand description
Complete RAII ownership of a terminal session, in either ScreenMode.
Construction enables raw mode and enhanced keyboard reporting, hides the cursor, and — depending on the mode — enters the alternate screen and enables mouse capture. Enhanced reporting is what lets crossterm distinguish chords such as Shift+Enter from plain Enter on ANSI terminals; Windows console events already carry modifier state through the native input API. Drop restores exactly what it took, including when unwinding from a panic. Pre-existing raw mode and keyboard-reporting stack entries are preserved. If construction fails partway through, it performs the same best-effort rollback before returning.
A split-footer session touches neither the alternate screen nor (by default)
mouse capture, so the terminal’s scrollback, selection, and wheel keep
working while the footer is up. It does not reserve or release the footer’s
rows — that is the renderer’s job, since only it knows where the viewport
landed: see pin_footer and
close_footer.
Implementations§
Source§impl TerminalSession
impl TerminalSession
Sourcepub fn enter() -> Result<Self>
pub fn enter() -> Result<Self>
Enter a full-screen session on the alternate screen, rolling back on
failure. Shorthand for enter_with(ScreenMode::Alternate).
Sourcepub fn enter_with(mode: ScreenMode) -> Result<Self>
pub fn enter_with(mode: ScreenMode) -> Result<Self>
Enter a session in mode, rolling back on failure.
Sourcepub fn mode(&self) -> ScreenMode
pub fn mode(&self) -> ScreenMode
The mode this session was entered in.
Trait Implementations§
Source§impl Drop for TerminalSession
impl Drop for TerminalSession
Auto Trait Implementations§
impl Freeze for TerminalSession
impl RefUnwindSafe for TerminalSession
impl Send for TerminalSession
impl Sync for TerminalSession
impl Unpin for TerminalSession
impl UnsafeUnpin for TerminalSession
impl UnwindSafe for TerminalSession
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> 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