pub struct TerminalCursor {
pub row: usize,
pub col: usize,
pub visible: bool,
pub shape: TerminalCursorShape,
}Expand description
Zero-based cursor position and presentation state.
Public fields and deserialization may place the cursor out of bounds; call
Self::clamp_to before indexing a screen.
§Examples
use ailloli_ui_terminal_core::{TerminalCursor, TerminalCursorShape};
let cursor = TerminalCursor::new();
assert_eq!((cursor.row, cursor.col, cursor.visible, cursor.shape), (0, 0, true, TerminalCursorShape::Block));Fields§
§row: usizeZero-based screen row.
col: usizeZero-based screen column.
visible: boolWhether the renderer should show the cursor.
shape: TerminalCursorShapeRequested renderer shape.
Implementations§
Source§impl TerminalCursor
impl TerminalCursor
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a visible block cursor at row zero, column zero.
§Examples
use ailloli_ui_terminal_core::TerminalCursor;
assert_eq!((TerminalCursor::new().row, TerminalCursor::new().col), (0, 0));Sourcepub fn clamp_to(&mut self, size: TerminalSize)
pub fn clamp_to(&mut self, size: TerminalSize)
Clamps row and column into a terminal size.
Zero dimensions are first clamped to one, so the result is always a
valid (row, col) for TerminalSize::clamped. Visibility and shape
are unchanged.
§Examples
use ailloli_ui_terminal_core::{TerminalCursor, TerminalSize};
let mut cursor = TerminalCursor { row: 9, col: 9, ..TerminalCursor::new() };
cursor.clamp_to(TerminalSize { rows: 2, cols: 3 });
assert_eq!((cursor.row, cursor.col), (1, 2));Trait Implementations§
Source§impl Clone for TerminalCursor
impl Clone for TerminalCursor
Source§fn clone(&self) -> TerminalCursor
fn clone(&self) -> TerminalCursor
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 TerminalCursor
impl Debug for TerminalCursor
Source§impl Default for TerminalCursor
impl Default for TerminalCursor
Source§impl<'de> Deserialize<'de> for TerminalCursor
impl<'de> Deserialize<'de> for TerminalCursor
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 TerminalCursor
impl PartialEq for TerminalCursor
Source§impl Serialize for TerminalCursor
impl Serialize for TerminalCursor
impl Copy for TerminalCursor
impl Eq for TerminalCursor
impl StructuralPartialEq for TerminalCursor
Auto Trait Implementations§
impl Freeze for TerminalCursor
impl RefUnwindSafe for TerminalCursor
impl Send for TerminalCursor
impl Sync for TerminalCursor
impl Unpin for TerminalCursor
impl UnwindSafe for TerminalCursor
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