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 Components are decoupled. Components 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

pub use components::Component;
pub use components::DrawMode;
pub use crate::builder::Builder;

Modules

Getting started truly from scratch is excessive for every user of superconsole. A small set of starter components are provided, exposed below.

Provides a variety of utilities for working with Lines. In order to work with Component output, one must import LinesExt

Provides stylization for Strings.

Macros

Convenience method for constructing a line from a sequence of spans.

Structs

Denotes an x by y area. Passed to Components 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.

A Span is a segment of text that may or may not have style applied to it. One may think of this as a unit of text. It must be valid to be constructed.

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.

Type Definitions