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>
impl<W: Write> Renderer<W>
pub fn new(writer: W, rng: Box<dyn Rng>, ctx: RenderContext) -> Self
pub fn ctx(&self) -> &RenderContext
pub fn panel(&self) -> LayoutPanel
Sourcepub fn frame<F>(&mut self, ctx: RenderContext, f: F) -> Result<()>
pub fn frame<F>(&mut self, ctx: RenderContext, f: F) -> 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.
Sourcepub fn draw(
&mut self,
component: &impl Component,
panel: LayoutPanel,
) -> Result<u16>
pub fn draw( &mut self, component: &impl Component, panel: LayoutPanel, ) -> Result<u16>
Set the active panel and render a component.
Sourcepub fn with_panel<F>(&mut self, f: F) -> Result<u16>
pub fn with_panel<F>(&mut self, f: F) -> 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> 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