Skip to main content

frame

Function frame 

Source
pub fn frame(
    backend: &mut impl Backend,
    state: &mut AppState,
    config: &RunConfig,
    events: &[Event],
    f: &mut impl FnMut(&mut Context),
) -> Result<bool>
Expand description

Process a single UI frame with a custom Backend.

This is the low-level entry point for custom backends. For standard terminal usage, prefer run() or run_with() which handle the event loop, terminal setup, and teardown automatically.

Returns Ok(true) to continue, Ok(false) when Context::quit() was called.

§Arguments

  • backend — Your Backend implementation
  • state — Persistent AppState (reuse across frames)
  • configRunConfig (theme, tick rate, etc.)
  • events — Input events for this frame (keyboard, mouse, resize)
  • f — Your UI closure, called once per frame

§Example

let keep_going = slt::frame(
    &mut my_backend,
    &mut state,
    &config,
    &events,
    &mut |ui| { ui.text("hello"); },
)?;