Skip to main content

Screen

Struct Screen 

Source
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

Source

pub fn new(width: u16, height: u16) -> Self

Source

pub fn width(&self) -> u16

Source

pub fn height(&self) -> u16

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more