Skip to main content

RegionScreen

Struct RegionScreen 

Source
pub struct RegionScreen { /* private fields */ }
Expand description

A bounded per-region virtual terminal.

Feed a child’s raw output bytes with feed; ANSI cursor, erase, scroll, and color sequences are applied to a fixed rows × cols cell grid rather than passed through, so a child that redraws in place renders correctly and can never move the host terminal’s cursor. Content past the last column truncates (the region does not auto-wrap). Rows that scroll off the top are returned so the caller can retain a bounded tail for a failure replay; on success they are simply dropped.

Implementations§

Source§

impl RegionScreen

Source

pub fn new(rows: usize, cols: usize) -> Self

Create a screen over a fresh rows × cols grid (each clamped to ≥ 1).

Source

pub fn feed(&mut self, bytes: &[u8]) -> Vec<String>

Feed raw output bytes, returning the rows evicted by scrolling.

Bytes are parsed as a VT stream and applied to the grid; multi-byte and split UTF-8 sequences are reassembled across calls by the parser. Evicted rows are returned oldest first, already styled, so the caller can retain a bounded tail in order (for a failure replay) or drop them.

Source

pub fn render(&self) -> Vec<String>

The current grid contents as styled rows (exactly the grid height).

Source

pub fn drain(self) -> Vec<String>

Consume the screen, returning its remaining rows with trailing blank rows trimmed, so evicted rows plus this drain reconstruct the transcript.

Trait Implementations§

Source§

impl Debug for RegionScreen

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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