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
impl Scrollback
Sourcepub const MAX_BLOCK_ROWS: u16 = 4096
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.
Sourcepub fn write(&self, build: impl FnOnce(u16) -> Element + Send + 'static)
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.
Sourcepub fn write_rows(
&self,
rows: u16,
build: impl FnOnce(u16) -> Element + Send + 'static,
)
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.
Sourcepub fn write_lines(&self, lines: Vec<Line<'static>>)
pub fn write_lines(&self, lines: Vec<Line<'static>>)
Queue pre-styled lines — the common case for logs and transcripts.
Sourcepub fn flush<B: Backend>(
&self,
terminal: &mut Terminal<B>,
theme: &Theme,
) -> Result<bool, B::Error>
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
impl Clone for Scrollback
Source§fn clone(&self) -> Scrollback
fn clone(&self) -> Scrollback
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for Scrollback
impl Default for Scrollback
Source§fn default() -> Scrollback
fn default() -> Scrollback
Auto Trait Implementations§
impl Freeze for Scrollback
impl RefUnwindSafe for Scrollback
impl Send for Scrollback
impl Sync for Scrollback
impl Unpin for Scrollback
impl UnsafeUnpin for Scrollback
impl UnwindSafe for Scrollback
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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