pub struct DoubleBuffer {
pub buf: Vec<u8>,
/* private fields */
}Expand description
Double-buffered terminal output with differential rendering.
Maintains two buffers to compute minimal updates between frames, reducing flicker and bandwidth.
§Examples
use extui::{DoubleBuffer, Terminal, TerminalFlags};
let mut term = Terminal::open(TerminalFlags::RAW_MODE)?;
let (w, h) = term.size()?;
let mut buf = DoubleBuffer::new(w, h);
// Draw to buf, then render
buf.render(&mut term);Fields§
§buf: Vec<u8>The output byte buffer containing VT escape sequences.
Implementations§
Source§impl DoubleBuffer
impl DoubleBuffer
Sourcepub fn set_style(&mut self, area: Rect, style: Style)
pub fn set_style(&mut self, area: Rect, style: Style)
Applies a style to all cells within the given area.
Sourcepub fn set_string(
&mut self,
x: u16,
y: u16,
string: &str,
style: Style,
) -> (u16, u16)
pub fn set_string( &mut self, x: u16, y: u16, string: &str, style: Style, ) -> (u16, u16)
Writes a styled string at the given position.
Returns the cursor position after writing.
Sourcepub fn set_stringn(
&mut self,
x: u16,
y: u16,
string: &str,
max_width: usize,
style: Style,
) -> (u16, u16)
pub fn set_stringn( &mut self, x: u16, y: u16, string: &str, max_width: usize, style: Style, ) -> (u16, u16)
Writes a styled string with a maximum width.
Returns the cursor position after writing.
Sourcepub fn new(width: u16, height: u16) -> DoubleBuffer
pub fn new(width: u16, height: u16) -> DoubleBuffer
Creates a new double buffer with the given dimensions.
Sourcepub fn resize(&mut self, width: u16, height: u16)
pub fn resize(&mut self, width: u16, height: u16)
Resizes the buffer if dimensions have changed.
Sourcepub fn last_write_size(&self) -> usize
pub fn last_write_size(&self) -> usize
Returns the size of the last rendered output in bytes.
Sourcepub fn write_buffer(&self) -> &[u8] ⓘ
pub fn write_buffer(&self) -> &[u8] ⓘ
Returns the rendered output buffer.
Sourcepub fn scroll(&mut self, amount: i16)
pub fn scroll(&mut self, amount: i16)
Queues a scroll operation for the next render.
Positive values scroll up, negative values scroll down.
Sourcepub fn render_internal(&mut self)
pub fn render_internal(&mut self)
Renders the current buffer to the internal byte buffer.
Use write_buffer to access the output.