pub struct Buffer {
pub area: Rect,
pub content: Vec<Cell>,
}Expand description
A two-dimensional grid of terminal cells.
The buffer is the primary rendering target. Widgets write into a buffer, and the terminal backend diffs the current buffer against the previous frame to compute minimal screen updates.
Fields§
§area: Rect§content: Vec<Cell>Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn with_lines<'a>(lines: impl IntoIterator<Item = &'a str>) -> Self
pub fn with_lines<'a>(lines: impl IntoIterator<Item = &'a str>) -> Self
Create a buffer filled with a specific string (for testing).
Sourcepub fn cell_mut(&mut self, pos: Position) -> Option<&mut Cell>
pub fn cell_mut(&mut self, pos: Position) -> Option<&mut Cell>
Get a mutable reference to the cell at (x, y).
Sourcepub fn set_string(&mut self, x: u16, y: u16, string: &str, style: Style) -> u16
pub fn set_string(&mut self, x: u16, y: u16, string: &str, style: Style) -> u16
Set a string starting at (x, y) with the given style. Returns the number of columns consumed.
Sourcepub fn set_string_truncated(
&mut self,
x: u16,
y: u16,
string: &str,
max_width: u16,
style: Style,
) -> u16
pub fn set_string_truncated( &mut self, x: u16, y: u16, string: &str, max_width: u16, style: Style, ) -> u16
Set a string with a maximum width, truncating if necessary.
Sourcepub fn set_line(&mut self, x: u16, y: u16, line: &Line, max_width: u16) -> u16
pub fn set_line(&mut self, x: u16, y: u16, line: &Line, max_width: u16) -> u16
Set a styled line at position.
Sourcepub fn set_span(&mut self, x: u16, y: u16, span: &Span, max_width: u16) -> u16
pub fn set_span(&mut self, x: u16, y: u16, span: &Span, max_width: u16) -> u16
Set a single span at position with a maximum width.
Sourcepub fn set_style(&mut self, area: Rect, style: Style)
pub fn set_style(&mut self, area: Rect, style: Style)
Fill an area with a style (without changing symbols).
Sourcepub fn fill(&mut self, area: Rect, symbol: &str, style: Style)
pub fn fill(&mut self, area: Rect, symbol: &str, style: Style)
Fill an area with a character and style.
Trait Implementations§
impl Eq for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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