pub struct RenderContext { /* private fields */ }Expand description
Manages the double-buffered rendering pipeline.
Each frame:
begin_frame()— swap buffers, clear the current buffer- Application writes to the current buffer
end_frame()— optionally compose layers, diff, render, and write to terminal
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn new(terminal: &dyn Terminal) -> Result<Self>
pub fn new(terminal: &dyn Terminal) -> Result<Self>
Create a new render context for the given terminal.
Sourcepub fn with_size(size: Size, renderer: Renderer) -> Self
pub fn with_size(size: Size, renderer: Renderer) -> Self
Create a render context with explicit size and capabilities (for testing).
Sourcepub fn with_compositor(self, compositor: Compositor) -> Self
pub fn with_compositor(self, compositor: Compositor) -> Self
Set the compositor for this render context (builder pattern).
When a compositor is present, end_frame() will call
compositor.compose() on the current buffer before diffing.
Sourcepub fn compositor(&self) -> Option<&Compositor>
pub fn compositor(&self) -> Option<&Compositor>
Get a reference to the compositor, if one is set.
Sourcepub fn compositor_mut(&mut self) -> Option<&mut Compositor>
pub fn compositor_mut(&mut self) -> Option<&mut Compositor>
Get a mutable reference to the compositor, if one is set.
Sourcepub fn buffer_mut(&mut self) -> &mut ScreenBuffer
pub fn buffer_mut(&mut self) -> &mut ScreenBuffer
Get a mutable reference to the current buffer for writing.
Sourcepub fn buffer(&self) -> &ScreenBuffer
pub fn buffer(&self) -> &ScreenBuffer
Get a reference to the current buffer.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Begin a new frame: swap current → previous and clear the current buffer.
Sourcepub fn end_frame(&mut self, terminal: &mut dyn Terminal) -> Result<()>
pub fn end_frame(&mut self, terminal: &mut dyn Terminal) -> Result<()>
End the frame: optionally compose layers, diff current vs previous, render to escape sequences, write to terminal and flush.
If a compositor is present, it composes all layers into the current buffer before the diff step.
Sourcepub fn handle_resize(&mut self, new_size: Size)
pub fn handle_resize(&mut self, new_size: Size)
Handle a terminal resize: update buffers, size, and compositor dimensions.