Skip to main content

Module widget

Module widget 

Source
Expand description

Widget System: Composable UI components for terminal applications.

This module provides a collection of widgets that implement the Widget trait, allowing them to be composed into complex layouts and rendered to the terminal.

§Available Widgets

  • StreamWidget - Scrolling text viewport for streaming content (LLM output)
  • TextInput - Single-line text input with cursor
  • StatusBar - Three-section status bar (left, center, right)
  • ProgressBar - Horizontal progress indicator

§Widget Trait

All widgets implement the Widget trait, which provides:

  • bounds() / set_bounds() - Layout management
  • render(&mut Buffer) - Draw to the buffer
  • handle_input(&InputEvent) -> bool - Input handling
  • needs_redraw() / clear_redraw() - Dirty tracking

§Example

use flywheel::widget::{Widget, TextInput, StatusBar};
use flywheel::Rect;

let mut input = TextInput::new(Rect::new(0, 23, 80, 1));
let mut status = StatusBar::new(Rect::new(0, 0, 80, 1));

status.set_all("Flywheel", "v0.1.0", "60 FPS");
input.set_content("Hello, world!");

// Render both widgets
input.render(buffer);
status.render(buffer);

Structs§

ProgressBar
A horizontal progress bar widget.
ProgressBarConfig
Configuration for the progress bar widget.
ScrollBuffer
Ring buffer for storing lines with scrollback.
StatusBar
A three-section status bar (left, center, right).
StatusBarConfig
Configuration for the status bar widget.
StreamConfig
Configuration for the stream widget.
StreamWidget
A streaming text widget optimized for LLM token output.
Terminal
A terminal emulator widget.
TextInput
A single-line text input widget with cursor and editing support.
TextInputConfig
Configuration for the text input widget.

Enums§

AppendResult
Result of an append operation.
ProgressStyle
Visual style for the progress bar.

Traits§

Widget
A UI component that can be rendered to a buffer and handle input.