pub struct ScreenBuffer {
pub width: usize,
pub height: usize,
/* private fields */
}Fields§
§width: usize§height: usizeImplementations§
Source§impl ScreenBuffer
impl ScreenBuffer
pub fn new(width: usize, height: usize, style: Option<Style>) -> Self
pub fn get(&self, x: usize, y: usize) -> &Cell
pub fn get_mut(&mut self, x: usize, y: usize) -> &mut Cell
pub fn as_plain_lines(&self) -> Vec<String>
Sourcepub fn from_renderable(
console: &Console,
options: &ConsoleOptions,
renderable: &dyn Renderable,
style: Option<Style>,
) -> Self
pub fn from_renderable( console: &Console, options: &ConsoleOptions, renderable: &dyn Renderable, style: Option<Style>, ) -> Self
Render a renderable to a ScreenBuffer.
This uses Console::render_lines and then converts the rendered lines to cells.
Sourcepub fn from_lines(
lines: &[Vec<Segment>],
width: usize,
height: usize,
default_style: Option<Style>,
) -> Self
pub fn from_lines( lines: &[Vec<Segment>], width: usize, height: usize, default_style: Option<Style>, ) -> Self
Build a ScreenBuffer from pre-rendered lines.
The caller is expected to provide lines already padded/cropped to width × height.
Sourcepub fn blit_lines(
&mut self,
x: usize,
y: usize,
width: usize,
lines: &[Vec<Segment>],
)
pub fn blit_lines( &mut self, x: usize, y: usize, width: usize, lines: &[Vec<Segment>], )
Blit pre-rendered lines into the buffer at an offset.
Lines should be padded/cropped to the region width. This method will clip to the screen bounds.
Sourcepub fn to_styled_lines(&self) -> Vec<Vec<Segment>>
pub fn to_styled_lines(&self) -> Vec<Vec<Segment>>
Convert the buffer to styled lines (no newlines).
Sourcepub fn diff_to_segments(&self, previous: &ScreenBuffer) -> Segments
pub fn diff_to_segments(&self, previous: &ScreenBuffer) -> Segments
Compute an update sequence that transforms previous into self.
The returned segments:
- Start with
Home(cursor to 0,0) - Use cursor controls (no
\n) for positioning - Emit styled text for changed spans
Sourcepub fn diff_to_segments_from_origin(&self, previous: &ScreenBuffer) -> Segments
pub fn diff_to_segments_from_origin(&self, previous: &ScreenBuffer) -> Segments
Compute an update sequence relative to the current cursor origin.
Unlike diff_to_segments, this does not emit Home and is intended for
embedding in larger cursor-positioned render flows (e.g. Live updates).
Trait Implementations§
Source§impl Clone for ScreenBuffer
impl Clone for ScreenBuffer
Source§fn clone(&self) -> ScreenBuffer
fn clone(&self) -> ScreenBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScreenBuffer
impl Debug for ScreenBuffer
Source§impl PartialEq for ScreenBuffer
impl PartialEq for ScreenBuffer
impl Eq for ScreenBuffer
impl StructuralPartialEq for ScreenBuffer
Auto Trait Implementations§
impl Freeze for ScreenBuffer
impl RefUnwindSafe for ScreenBuffer
impl Send for ScreenBuffer
impl Sync for ScreenBuffer
impl Unpin for ScreenBuffer
impl UnwindSafe for ScreenBuffer
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.