pub struct Screen { /* private fields */ }Expand description
Retained W×H cell grid + current/prev frames.
Indexing: cells[row][col] with row ∈ 0..height,
col ∈ 0..width. ANSI emit converts to 1-indexed at the
boundary.
Implementations§
Source§impl Screen
impl Screen
pub fn new(width: u16, height: u16) -> Self
pub fn width(&self) -> u16
pub fn height(&self) -> u16
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset every cell of the current frame to a blank with default
style. O(W·H). Typically called by render_diff after a swap
so the next draw cycle starts from a clean scratch.
Sourcepub fn draw_row(&mut self, row: usize, col: usize, cells: &[Cell])
pub fn draw_row(&mut self, row: usize, col: usize, cells: &[Cell])
Write cells starting at (row, col) in the current frame.
Out-of-bounds rows are silently skipped (so callers don’t
need to clamp every time); cols beyond width are truncated
to the right edge.
Cells with width == 2 (wide CJK / emoji) should have a
following Cell::continuation() from the caller — this method
itself doesn’t auto-insert them. push_str_cells on the
caller side handles that invariant.
Sourcepub fn set_cursor(&mut self, row: u16, col: u16)
pub fn set_cursor(&mut self, row: u16, col: u16)
Park the terminal cursor at (row, col) (1-indexed ANSI
coords) at the end of the next render_diff. Typically
pointed at the input prompt’s insertion cell.
Sourcepub fn set_cursor_visible(&mut self, visible: bool)
pub fn set_cursor_visible(&mut self, visible: bool)
Toggle DECTCEM cursor visibility for the next render_diff.
Used to hide the cursor while a live body spinner is animating
(otherwise it sits at the end of “Pondering… · 5s” and blinks).
render_diff re-emits this every frame, so flipping the flag
once is enough — every subsequent paint reasserts it.
Sourcepub fn scroll_up(&mut self, bottom: usize, n: usize)
pub fn scroll_up(&mut self, bottom: usize, n: usize)
Scroll the top bottom rows up by n. Rows [0..n) are
dropped; rows [n..bottom) slide to [0..bottom-n); rows
[bottom-n..bottom) become blank, ready for new content.
Rows [bottom..height) (typically the fixed footer) are
untouched.
Used for body “append a line” semantics in retained mode:
scroll the whole body region up by one, then draw the new
line at bottom - 1.
Sourcepub fn render_diff(&mut self) -> Vec<u8> ⓘ
pub fn render_diff(&mut self) -> Vec<u8> ⓘ
Produce the ANSI patch stream for (prev → current). Swaps
frames at the end so the cells we just rendered becomes
the next diff’s prev_cells. Scratches cells to blank so
the next draw cycle starts clean — callers must re-draw
every widget every frame (retained-mode invariant).
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force the next render_diff to emit every non-blank cell as
if prev were all-blank. Called after resume_from_external,
resize, or any other event that leaves terminal state
unknown. Safe to call even when prev is already blank
(just produces no additional emit).
Sourcepub fn resize(&mut self, width: u16, height: u16)
pub fn resize(&mut self, width: u16, height: u16)
Rebuild for new dimensions. Current and prev frames are
discarded — the caller must re-draw every widget before
the next render_diff.
Sourcepub fn prev_cells_for_test(&self) -> &[Vec<Cell>]
pub fn prev_cells_for_test(&self) -> &[Vec<Cell>]
Peek at the last-emitted frame. Used by tests and the
diagnostic trace path (tuix_trace!("FOOT", ...)) to
inspect “what is actually on screen right now” without
reconstructing state from the ANSI byte stream. Not meant
for normal rendering — that goes through render_diff.
Auto Trait Implementations§
impl Freeze for Screen
impl RefUnwindSafe for Screen
impl Send for Screen
impl Sync for Screen
impl Unpin for Screen
impl UnsafeUnpin for Screen
impl UnwindSafe for Screen
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> 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>
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>
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 more