Skip to main content

Module core

Module core 

Source
Expand description

Core abstractions every prompt implements.

A prompt is three small things:

impl Prompt for MyPrompt {
    type Output = String;
    fn handle(&mut self, key: Key) -> Step<String> { ... }
    fn render(&self, ctx: RenderCtx) -> Frame      { ... }
    fn render_answered(&self, v: &String) -> Frame { ... }
}

The generic run function in core::runner owns everything else: raw mode, the key loop, line-count bookkeeping, the validate → success transition, the answered redraw, and Ctrl+C cleanup. Prompts never touch crossterm or stderr directly.

Structs§

RenderCtx
Information the runner hands to Prompt::render on every frame.

Enums§

Key
Step
The transition a prompt requests after handling one key.

Traits§

Prompt
The contract every interactive prompt implements.

Functions§

run
Run a prompt to completion.

Type Aliases§

Frame
One screen’s worth of prompt output. Each String is exactly one terminal row (newlines are added by the runner). Owning the row split here means the runner can track line counts without re-parsing strings.