pub struct TerminalSize {
pub columns: u16,
pub rows: u16,
pub pixels: Option<PixelSize>,
pub cell: Option<PixelSize>,
}Expand description
The size of a terminal.
Fields§
§columns: u16The width of the terminal, in characters aka columns.
rows: u16The height of the terminal, in lines.
pixels: Option<PixelSize>The size in pixels, if available.
cell: Option<PixelSize>The size of once cell, if available.
Implementations§
Source§impl TerminalSize
impl TerminalSize
Sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Get terminal size from $COLUMNS and $LINES.
Do not assume any knowledge about window size.
Sourcepub fn from_terminal() -> Option<Self>
pub fn from_terminal() -> Option<Self>
Detect the terminal size by querying the underlying terminal.
On unix this issues a ioctl to the controlling terminal.
On Windows this uses the terminal_size crate which does some magic windows API calls.
Sourcepub fn detect() -> Option<Self>
pub fn detect() -> Option<Self>
Detect the terminal size.
Get the terminal size from the underlying TTY, and fallback to
$COLUMNS and $LINES.
Sourcepub fn with_max_columns(&self, max_columns: u16) -> Self
pub fn with_max_columns(&self, max_columns: u16) -> Self
Shrink the terminal size to the given amount of maximum columns.
Also shrinks the pixel size accordingly.
Trait Implementations§
Source§impl Clone for TerminalSize
impl Clone for TerminalSize
Source§fn clone(&self) -> TerminalSize
fn clone(&self) -> TerminalSize
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TerminalSize
impl Debug for TerminalSize
Source§impl Default for TerminalSize
impl Default for TerminalSize
Source§impl PartialEq for TerminalSize
impl PartialEq for TerminalSize
impl Copy for TerminalSize
impl StructuralPartialEq for TerminalSize
Auto Trait Implementations§
impl Freeze for TerminalSize
impl RefUnwindSafe for TerminalSize
impl Send for TerminalSize
impl Sync for TerminalSize
impl Unpin for TerminalSize
impl UnwindSafe for TerminalSize
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().