Crate superconsole
source · [−]Expand description
The superconsole crate provides a handler and building blocks for powerful, yet minimally intrusive TUIs.
Built on-top of crossterm
, it cross-compiles on Windows 7+, Linux, and MacOS.
Rendering is handled by SuperConsole
, which draws to stdout
.
The caller is responsible for re-rendering whenever necessary.
User input will cause aberrations in output; similarly, one should also not produce output from other sources while superconsole is active.
The rendering can be divided into two principle components:
- In the scratch area, the previous content is overwritten at each render.
- In the emitted area, lines scroll away above the scratch with various diagnostic output. Components live in the scratch area.
State
and Component
s are decoupled. Component
s are stateless, and State
is supplied at render time.
A set of pre-baked composition and testing oriented components are provided in the components
module.
Re-exports
Modules
Getting started truly from scratch is excessive for every user of superconsole. A small set of starter components are provided, exposed below.
Provides stylization for Strings.
Macros
Structs
Denotes an x by y area. Passed to Component
s to give valid drawing area.
A Line
is an abstraction for a collection of stylized or unstylized strings.
Since each Span
denotes a portion of a single line, an ordered collection represents a single line of text.
Each Component
can refer to any piece of state to render itself.
Conceptually, since Components are stateless, this state is used to render them fresh at each step.
States should be given a unique type - this can be used to retrieve them at draw time.
Handles rendering the console using the user-defined Components and emitted messages. A Canvas area at the bottom of the terminal is re-rendered in place at each tick for the components, while a log area of emitted messages is produced above. Producing output from sources other than SuperConsole while break the TUI.
Enums
Denotes a particular axis (x or y). Used for several Components which are generalized over direction.