pub struct TerminalGeometry {
pub pixel_width: u32,
pub pixel_height: u32,
pub metrics: TerminalCellMetrics,
pub cols: u16,
pub rows: u16,
}Expand description
Committed terminal viewport geometry.
pixel_width/pixel_height are rounded non-negative content extents in the
runtime coordinate space. Grid dimensions are whole cells and normally stay
within 1..=u16::MAX. Self::new itself stores all inputs unchanged.
§Examples
use ailloli_ui_widgets::controls::{TerminalCellMetrics, TerminalGeometry};
let geometry = TerminalGeometry::new(
640,
380,
TerminalCellMetrics::new(8.0, 19.0, 14.0),
80,
20,
);
assert_eq!(geometry.terminal_size().cols, 80);Fields§
§pixel_width: u32Rounded content width, saturated at u32::MAX by runtime measurement.
pixel_height: u32Rounded content height, saturated at u32::MAX by runtime measurement.
metrics: TerminalCellMetricsCell width, height, and baseline used to derive the grid.
cols: u16Visible column count in cells.
rows: u16Visible row count in cells.
Implementations§
Source§impl TerminalGeometry
impl TerminalGeometry
Sourcepub const fn new(
pixel_width: u32,
pixel_height: u32,
metrics: TerminalCellMetrics,
cols: u16,
rows: u16,
) -> Self
pub const fn new( pixel_width: u32, pixel_height: u32, metrics: TerminalCellMetrics, cols: u16, rows: u16, ) -> Self
Stores viewport geometry unchanged.
§Examples
use ailloli_ui_widgets::controls::{TerminalCellMetrics, TerminalGeometry};
let geometry = TerminalGeometry::new(800, 600, TerminalCellMetrics::new(8.0, 20.0, 14.0), 100, 30);
assert_eq!((geometry.pixel_width, geometry.rows), (800, 30));Sourcepub fn terminal_size(self) -> TerminalSize
pub fn terminal_size(self) -> TerminalSize
Converts (rows, cols) to a core [TerminalSize].
TerminalSize::new replaces a zero row or column with one.
§Examples
use ailloli_ui_widgets::controls::{TerminalCellMetrics, TerminalGeometry};
let geometry = TerminalGeometry::new(0, 0, TerminalCellMetrics::new(1.0, 1.0, 1.0), 0, 0);
assert_eq!((geometry.terminal_size().rows, geometry.terminal_size().cols), (1, 1));Sourcepub fn viewport_size(self) -> TerminalViewportSize
pub fn viewport_size(self) -> TerminalViewportSize
Converts to the resize callback payload.
Pixel extents above u16::MAX saturate independently; grid dimensions
pass through Self::terminal_size.
§Examples
use ailloli_ui_widgets::controls::{TerminalCellMetrics, TerminalGeometry};
let geometry = TerminalGeometry::new(100_000, 480, TerminalCellMetrics::new(8.0, 20.0, 14.0), 80, 24);
let viewport = geometry.viewport_size();
assert_eq!(viewport.pixel_width, u16::MAX);
assert_eq!(viewport.pixel_height, 480);Trait Implementations§
Source§impl Clone for TerminalGeometry
impl Clone for TerminalGeometry
Source§fn clone(&self) -> TerminalGeometry
fn clone(&self) -> TerminalGeometry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TerminalGeometry
impl Debug for TerminalGeometry
Source§impl PartialEq for TerminalGeometry
impl PartialEq for TerminalGeometry
impl Copy for TerminalGeometry
impl StructuralPartialEq for TerminalGeometry
Auto Trait Implementations§
impl Freeze for TerminalGeometry
impl RefUnwindSafe for TerminalGeometry
impl Send for TerminalGeometry
impl Sync for TerminalGeometry
impl Unpin for TerminalGeometry
impl UnwindSafe for TerminalGeometry
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.