Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer<W: Write> {
    pub writer: W,
    pub rng: Box<dyn Rng>,
    /* private fields */
}
Expand description

Bundles writer, RNG, per-frame context, and current panel for rendering.

Created once at wizard startup. Per-frame context is updated via frame(), which scopes each render pass. The active LayoutPanel is set by draw().

Fields§

§writer: W§rng: Box<dyn Rng>

Implementations§

Source§

impl<W: Write> Renderer<W>

Source

pub fn new(writer: W, rng: Box<dyn Rng>, ctx: RenderContext) -> Self

Source

pub fn ctx(&self) -> &RenderContext

Source

pub fn panel(&self) -> LayoutPanel

Source

pub fn frame<F>(&mut self, ctx: RenderContext, f: F) -> Result<()>
where F: FnOnce(&mut Self) -> Result<()>,

Scope a render frame: update the context, clear the screen, run f, then flush.

Analogous to the shellops with_cursor pattern — scoped mutation with a single point of context update.

Source

pub fn draw( &mut self, component: &impl Component, panel: LayoutPanel, ) -> Result<u16>

Set the active panel and render a component.

Source

pub fn with_panel<F>(&mut self, f: F) -> Result<u16>
where F: FnOnce(&mut W, LayoutPanel, &mut Box<dyn Rng>) -> Result<u16>,

Destructure the renderer for a component render at the active panel.

Positions the cursor, then passes writer, panel, and RNG to the closure. The panel is read from the renderer (set by draw).

Auto Trait Implementations§

§

impl<W> Freeze for Renderer<W>
where W: Freeze,

§

impl<W> !RefUnwindSafe for Renderer<W>

§

impl<W> !Send for Renderer<W>

§

impl<W> !Sync for Renderer<W>

§

impl<W> Unpin for Renderer<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Renderer<W>
where W: UnsafeUnpin,

§

impl<W> !UnwindSafe for Renderer<W>

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.