Skip to main content

Scrollback

Struct Scrollback 

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

A handle for publishing content into the terminal scrollback above a split footer.

Cloneable and Send + Sync: background producers keep a clone and publish from their own thread or task. Queued blocks are rendered and committed by the runner on its next loop iteration — at most one tick_rate away — and each block is committed whole, so a block never interleaves with another producer’s.

A block is not a frame: it is written into the terminal’s scrollback once and never repainted. Views that animate, scroll, or depend on later state belong in the footer.

In ScreenMode::Alternate there is no scrollback to write to; the runners discard queued blocks rather than let the queue grow without bound.

Implementations§

Source§

impl Scrollback

Source

pub const MAX_BLOCK_ROWS: u16 = 4096

Rows a single block may occupy. A measured or requested height past this is clamped, bounding the scratch buffer one block can allocate; publish genuinely long output as several blocks.

Source

pub fn new() -> Self

An empty queue.

Source

pub fn write(&self, build: impl FnOnce(u16) -> Element + Send + 'static)

Queue a view, built at the render width and sized by its own measure.

Source

pub fn write_rows( &self, rows: u16, build: impl FnOnce(u16) -> Element + Send + 'static, )

Queue a view that occupies exactly rows rows, skipping measurement. Content past rows is clipped, as it would be in any other area.

Source

pub fn write_lines(&self, lines: Vec<Line<'static>>)

Queue pre-styled lines — the common case for logs and transcripts.

Source

pub fn is_empty(&self) -> bool

Whether anything is waiting to be published.

Source

pub fn clear(&self)

Drop every queued block without rendering it.

Source

pub fn flush<B: Backend>( &self, terminal: &mut Terminal<B>, theme: &Theme, ) -> Result<bool, B::Error>

Render and commit every queued block above terminal’s inline viewport, returning whether anything was written.

Committing scrolls the terminal, and without the scrolling-regions feature it also clears the viewport, so a true return means the caller must repaint the footer before waiting for input again.

Only an inline viewport has a scrollback to commit into. Against any other viewport the queue is still drained but the blocks go nowhere, which is why the runners call clear instead of this in ScreenMode::Alternate.

Trait Implementations§

Source§

impl Clone for Scrollback

Source§

fn clone(&self) -> Scrollback

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Scrollback

Source§

fn default() -> Scrollback

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.