Skip to main content

Module piece

Module piece 

Source
Expand description

A meter, a badge, a control, a figure and a form field.

The pieces below the level table works at. Not feature-gated, on table’s footing: PieceStyle carries the tones, and a caller with a loaded theme reaches for PieceStyle::from_theme. The pieces every terminal app draws, drawn once.

§Called widget until 0.19.0

Renamed because makeover-layout 0.20.0 took the word for something else, and the two meanings do not sit together. A Region::Widget there is host-agnostic: a named assembly of primitives that every renderer draws its own way. What is in this module is the opposite end — renderer-local, the answer to what a meter looks like in cells, taking a description plus what only a terminal knows.

One word for both would have made the tier unreadable in the crate that implements it. This half moved because the other half is the ecosystem-facing one: a second or third party naming a widget is naming the layout kind, and nothing outside this tree ever needed a word for a drawing routine.

WidgetStyle went with it and is PieceStyle.

Arrived in 0.16.0 out of quasi-tui, which had written all of them and was the second consumer to do so. A meter, a badge, a control, a figure and a form field are what a screen is made of below the level table works at, and every one of them had been hand-rolled at least twice in this tree before it was lifted.

§What these take, and what they leave alone

Each takes a makeover-layout description, a [PieceStyle], and whatever the host knows that a description never carries. That last part is the shape worth copying: [field] takes what is currently typed in the box as a separate argument, because [Field] deliberately does not carry a value and is not going to. makeover-immediate reached the same seam from the other side with its Filling, and [Held] is that seam here.

Focus is the other one. Nothing in a description says which control the user is on, so every drawing here takes focused as an argument and the caller is what counts. What focus looks like is this crate’s answer and not the caller’s, which is the point of it being here: see [PieceStyle::focused].

§What they do not do

No layout. Each answers rows for a width, or draws into the rect it is given, top-aligned, and never below it. Nothing here measures twice and nothing here places anything relative to anything else, because the moment it did it would be a layout engine with one consumer’s flow baked into it.

Structs§

PieceStyle
The colours and marks the drawings below use.

Enums§

Held
What a field currently holds, which a description never carries.

Functions§

act
A control as one line.
field
A question: its label, the box, and its standing help or what is wrong now.
field_height
The rows field wants at width.
figure
A figure: the number, then what it counts under it.
figure_height
The rows figure wants at width.
filled_act
A control filled with the action colour, for the one press a screen is about.
meter
A proportion as one line: the bar, then the reading beside it.
token
A badge or a chip as one span.