pub struct TerminalSize {
pub rows: usize,
pub cols: usize,
}Expand description
Terminal grid dimensions, measured in whole character cells.
Self::new guarantees both values are at least one. Public fields and
derived deserialization can bypass that invariant; use Self::clamped
before arithmetic/indexing. There is no upper bound.
§Examples
use ailloli_ui_terminal_core::TerminalSize;
assert_eq!(TerminalSize::new(24, 80), TerminalSize { rows: 24, cols: 80 });Fields§
§rows: usizeVisible row count in cells.
cols: usizeVisible column count in cells.
Implementations§
Source§impl TerminalSize
impl TerminalSize
Sourcepub const DEFAULT_ROWS: usize = 24usize
pub const DEFAULT_ROWS: usize = 24usize
Default terminal height: 24 rows.
§Examples
use ailloli_ui_terminal_core::TerminalSize;
assert_eq!(TerminalSize::DEFAULT_ROWS, 24);Sourcepub const DEFAULT_COLS: usize = 80usize
pub const DEFAULT_COLS: usize = 80usize
Default terminal width: 80 columns.
§Examples
use ailloli_ui_terminal_core::TerminalSize;
assert_eq!(TerminalSize::DEFAULT_COLS, 80);Sourcepub const fn new(rows: usize, cols: usize) -> Self
pub const fn new(rows: usize, cols: usize) -> Self
Creates a size, replacing each zero dimension independently with one.
All positive usize values, including usize::MAX, are retained.
§Examples
use ailloli_ui_terminal_core::TerminalSize;
assert_eq!(TerminalSize::new(0, 0), TerminalSize { rows: 1, cols: 1 });Trait Implementations§
Source§impl Clone for TerminalSize
impl Clone for TerminalSize
Source§fn clone(&self) -> TerminalSize
fn clone(&self) -> TerminalSize
Returns a copy 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<'de> Deserialize<'de> for TerminalSize
impl<'de> Deserialize<'de> for TerminalSize
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for TerminalSize
impl PartialEq for TerminalSize
Source§impl Serialize for TerminalSize
impl Serialize for TerminalSize
impl Copy for TerminalSize
impl Eq 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