pub enum TerminalType {
WindowsTerminal,
Wsl,
WindowsConsole,
MacOsTerminal,
LinuxNative,
Unknown,
}Expand description
Terminal type detection for viewport handling
Different terminals report their dimensions differently:
- Some report the visible viewport size (what the user sees)
- Others report the buffer size (which can be larger, enabling scrollback)
This enum categorizes terminals based on their reporting behavior.
Variants§
WindowsTerminal
Windows Terminal - reports viewport size correctly
Wsl
WSL (Windows Subsystem for Linux) - may report buffer size
WindowsConsole
PowerShell / cmd - reports buffer size (not viewport)
MacOsTerminal
macOS Terminal.app
LinuxNative
Ubuntu native terminal (gnome-terminal, etc.)
Unknown
Unknown terminal - use conservative defaults
Implementations§
Source§impl TerminalType
impl TerminalType
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detect the terminal type from environment variables
Uses environment variables to identify the terminal emulator:
WT_SESSION: Windows TerminalWSL_DISTRO_NAME: WSL environmentTERM_PROGRAM: macOS Terminal.app or other- Platform detection for fallback
Sourcepub const fn viewport_height_offset(self, reported_height: u16) -> u16
pub const fn viewport_height_offset(self, reported_height: u16) -> u16
Calculate viewport height offset based on terminal type
Returns the number of rows to subtract from the reported terminal size to get the actual visible viewport. This compensates for terminals that report buffer size instead of viewport size.
§Arguments
reported_height- The height reported by the terminal
§Returns
The number of rows to subtract to get the visible viewport height
Trait Implementations§
Source§impl Clone for TerminalType
impl Clone for TerminalType
Source§fn clone(&self) -> TerminalType
fn clone(&self) -> TerminalType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TerminalType
impl Debug for TerminalType
Source§impl PartialEq for TerminalType
impl PartialEq for TerminalType
impl Copy for TerminalType
impl Eq for TerminalType
impl StructuralPartialEq for TerminalType
Auto Trait Implementations§
impl Freeze for TerminalType
impl RefUnwindSafe for TerminalType
impl Send for TerminalType
impl Sync for TerminalType
impl Unpin for TerminalType
impl UnwindSafe for TerminalType
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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