pub struct Cursor {
pub row: u16,
pub col: u16,
pub visible: bool,
pub pending_wrap: bool,
pub attrs: SgrAttrs,
pub charset_slots: [u8; 4],
pub active_charset: u8,
pub single_shift: Option<u8>,
/* private fields */
}Expand description
Terminal cursor state.
Fields§
§row: u16Current row (0-indexed from top of viewport).
col: u16Current column (0-indexed from left).
visible: boolWhether the cursor is visible (DECTCEM).
pending_wrap: boolPending wrap: the cursor is at the right margin and the next printable character should trigger a line wrap. This avoids the xterm off-by-one behavior where the cursor sits past the last column.
attrs: SgrAttrsCurrent SGR attributes applied to newly written characters.
charset_slots: [u8; 4]Character set slots G0–G3. Each stores a charset designator byte:
b'B' = ASCII (default), b'0' = DEC Special Graphics, b'A' = UK.
active_charset: u8Active character set slot index (0 = G0, default).
single_shift: Option<u8>Single-shift override: if Some(2) or Some(3), the next printed char
uses G2 or G3 respectively, then clears back to None.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn at(row: u16, col: u16) -> Self
pub fn at(row: u16, col: u16) -> Self
Create a cursor at the given position with default attributes.
Sourcepub fn scroll_top(&self) -> u16
pub fn scroll_top(&self) -> u16
Top of scroll region (inclusive).
Sourcepub fn scroll_bottom(&self) -> u16
pub fn scroll_bottom(&self) -> u16
Bottom of scroll region (exclusive).
Sourcepub fn set_scroll_region(&mut self, top: u16, bottom: u16, rows: u16)
pub fn set_scroll_region(&mut self, top: u16, bottom: u16, rows: u16)
Set scroll region margins (DECSTBM). Both are 0-indexed.
top is inclusive, bottom is exclusive.
If top >= bottom or bottom > rows, the request is ignored.
Sourcepub fn reset_scroll_region(&mut self, rows: u16)
pub fn reset_scroll_region(&mut self, rows: u16)
Reset scroll region to full screen.
Sourcepub fn in_scroll_region(&self) -> bool
pub fn in_scroll_region(&self) -> bool
Whether the cursor is inside the scroll region.
Sourcepub fn clamp(&mut self, rows: u16, cols: u16)
pub fn clamp(&mut self, rows: u16, cols: u16)
Clamp the cursor position to the given grid bounds.
Sourcepub fn move_to(&mut self, row: u16, col: u16, rows: u16, cols: u16)
pub fn move_to(&mut self, row: u16, col: u16, rows: u16, cols: u16)
CUP: Move cursor to absolute position (0-indexed). Coordinates are clamped to grid bounds.
Sourcepub fn move_up(&mut self, count: u16)
pub fn move_up(&mut self, count: u16)
CUU: Move cursor up by count rows, stopping at the top margin.
Sourcepub fn move_down(&mut self, count: u16, rows: u16)
pub fn move_down(&mut self, count: u16, rows: u16)
CUD: Move cursor down by count rows, stopping at the bottom margin.
Sourcepub fn move_right(&mut self, count: u16, cols: u16)
pub fn move_right(&mut self, count: u16, cols: u16)
CUF: Move cursor right by count columns, stopping at the right margin.
Sourcepub fn move_left(&mut self, count: u16)
pub fn move_left(&mut self, count: u16)
CUB: Move cursor left by count columns, stopping at column 0.
Sourcepub fn carriage_return(&mut self)
pub fn carriage_return(&mut self)
CR: Carriage return — move cursor to column 0.
Sourcepub fn next_tab_stop(&self, cols: u16) -> u16
pub fn next_tab_stop(&self, cols: u16) -> u16
Advance to the next tab stop. Returns the new column.
Sourcepub fn prev_tab_stop(&self) -> u16
pub fn prev_tab_stop(&self) -> u16
Move back to the previous tab stop. Returns the new column.
Sourcepub fn set_tab_stop(&mut self)
pub fn set_tab_stop(&mut self)
Set a tab stop at the current column.
Sourcepub fn clear_tab_stop(&mut self)
pub fn clear_tab_stop(&mut self)
Clear the tab stop at the current column.
Sourcepub fn clear_all_tab_stops(&mut self)
pub fn clear_all_tab_stops(&mut self)
Clear all tab stops.
Sourcepub fn reset_tab_stops(&mut self, cols: u16)
pub fn reset_tab_stops(&mut self, cols: u16)
Reset tab stops to the default interval (every 8 columns).
Source§impl Cursor
impl Cursor
Sourcepub fn effective_charset(&self) -> u8
pub fn effective_charset(&self) -> u8
Get the effective charset designator for the next printed character, accounting for single-shift overrides.
Sourcepub fn consume_single_shift(&mut self)
pub fn consume_single_shift(&mut self)
Consume the single-shift state (call after printing a character).
Sourcepub fn designate_charset(&mut self, slot: u8, charset: u8)
pub fn designate_charset(&mut self, slot: u8, charset: u8)
Designate a charset for a slot.
Sourcepub fn reset_charset(&mut self)
pub fn reset_charset(&mut self)
Reset charset state to defaults (all ASCII, G0 active, no single-shift).