Expand description
§scopekit
Build ratatui viewers with a live wgpu view: a medical image, a globe, a plot. The same app runs in two places:
- in any terminal: the view is rendered offscreen on the GPU and shown with the kitty, iTerm2 or sixel graphics protocol, or as coloured half blocks where the terminal has none;
- in its own window: ratatui-wgpu draws the text, and the view is composited onto the same surface in the same frame, at full resolution.
You write the text UI once with ratatui, handle crossterm events once (the window translates its input into the same types), and implement one trait for the GPU view. scopekit does the rest: the terminal graphics protocols, the window, fonts, colours, the mouse, animation ticks and read-back.
┌──────────── scopekit::App ─────────────┐
│ draw(frame, slot) event(ev) tick() │
└───────────────┬─────────────────────────┘
terminal (crossterm) │ window (winit + ratatui-wgpu)
ratatui text ──► terminal cells │ ratatui text ──► glyph texture ─┐
GpuView ──► offscreen texture │ GpuView ─────────────────────── ┼─► surface
──► kitty/iTerm2/sixel/ │ (same device, same │
half blocks │ frame, no read-back)┘It powers dicomscope-tui, the DICOM viewer of
hl7v2. Start with HOWTO.md; examples/plasma.rs is a
complete app in one file:
cargo run -p scopekit --example plasma # in this terminal
cargo run -p scopekit --example plasma -- --window # in a windowFeatures: terminal and window, both on by default. Leave one out to drop
its dependencies. Built on wgpu 30, ratatui 0.30, ratatui-wgpu 0.6 and
ratatui-image 11; scopekit re-exports wgpu, ratatui and crossterm so
apps use the same versions.
Re-exports§
pub use config::Backend;pub use config::Config;pub use config::Mode;pub use config::Palette;pub use config::Protocol;pub use gesture::DragAction;pub use gesture::Gesture;pub use gesture::GestureKind;pub use gesture::GestureType;pub use gesture::Input;pub use gesture::ScrollAction;pub use gpu::render_to_rgba;pub use gpu::Gpu;pub use gpu::GpuView;pub use gpu::PixelRect;pub use gpu::Target;pub use gpu::Views;pub use crossterm;pub use ratatui;pub use wgpu;
Modules§
- clipboard
- The system clipboard: text and images (feature
clipboard). - config
- Everything a scopekit app can configure, in one struct with sensible defaults. Build it with struct update syntax:
- gesture
- Mouse, trackpad and touch input as gestures on GPU views: tap, double
tap, long press, pan, zoom and rotate, with bindings in
Input. - gpu
- The GPU side: the
GpuViewan app implements, the device it gets, and offscreen rendering with read-back for terminals and exports. - terminal
- Terminal mode: ratatui on crossterm, each GPU view rendered offscreen and sent with the terminal’s graphics protocol.
- window
- Window mode: the same app in a native window. ratatui-wgpu draws the
text into a texture; the
Compositorputs it on the window surface and then lets each placed GPU view draw into its region, on the same device, in the same frame, at the window’s full resolution.
Structs§
- Help
- What an app contributes to the help box: its keys, and what each
gesture does in its views. Return it from
App::help. - View
Slot - Where the GPU views go this frame, and facts about the screen an app needs to map the mouse into a view.
- Waker
- Asks the running app for a redraw from any thread: an emulator’s serial reader, a build, a network client. Cheap to clone; wake-ups that arrive faster than frames are drawn coalesce.
Enums§
- Flow
- What to do after an event.
Traits§
- App
- A scopekit application.