Skip to main content

RenderContext

Struct RenderContext 

Source
pub struct RenderContext { /* private fields */ }
Expand description

Manages the double-buffered rendering pipeline.

Each frame:

  1. begin_frame() — swap buffers, clear the current buffer
  2. Application writes to the current buffer
  3. end_frame() — optionally compose layers, diff, render, and write to terminal

Implementations§

Source§

impl RenderContext

Source

pub fn new(terminal: &dyn Terminal) -> Result<Self>

Create a new render context for the given terminal.

Source

pub fn with_size(size: Size, renderer: Renderer) -> Self

Create a render context with explicit size and capabilities (for testing).

Source

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.

Source

pub fn compositor(&self) -> Option<&Compositor>

Get a reference to the compositor, if one is set.

Source

pub fn compositor_mut(&mut self) -> Option<&mut Compositor>

Get a mutable reference to the compositor, if one is set.

Source

pub fn size(&self) -> Size

Get the current buffer dimensions.

Source

pub fn buffer_mut(&mut self) -> &mut ScreenBuffer

Get a mutable reference to the current buffer for writing.

Source

pub fn buffer(&self) -> &ScreenBuffer

Get a reference to the current buffer.

Source

pub fn begin_frame(&mut self)

Begin a new frame: swap current → previous and clear the current buffer.

Source

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.

Source

pub fn handle_resize(&mut self, new_size: Size)

Handle a terminal resize: update buffers, size, and compositor dimensions.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.