pub trait ScreenSyntax {
type Text;
type Line;
type Row;
type Body;
type Screen;
// Required methods
fn text(&self, content: impl Into<String>, emphasis: Emphasis) -> Self::Text;
fn gauge(&self, gauge: Gauge) -> Self::Text;
fn line(&self, runs: impl Iterator<Item = Self::Text>) -> Self::Line;
fn edited_line(
&self,
prefix: impl Into<String>,
text: &str,
cursor: usize,
emphasis: Emphasis,
) -> Self::Line;
fn row(&self, lines: impl Iterator<Item = Self::Line>) -> Self::Row;
fn rows(
&self,
title: impl Into<String>,
focused: Option<usize>,
rows: impl Iterator<Item = Self::Row>,
) -> Self::Body;
fn message(
&self,
title: impl Into<String>,
message: impl Into<String>,
emphasis: Emphasis,
) -> Self::Body;
fn draft(
&self,
title: impl Into<String>,
placeholder: impl Into<String>,
text: &str,
cursor: usize,
examples: impl Iterator<Item = (String, String)>,
) -> Self::Body;
fn record(
&self,
title: impl Into<String>,
notes: impl Iterator<Item = String>,
) -> Self::Body;
fn verbatim(&self, text: impl Into<String>) -> Self::Body;
fn screen(
&self,
header: Self::Line,
body: Self::Body,
status: impl Into<String>,
footer: Self::Line,
) -> Self::Screen;
fn screen_text(&self, screen: &Self::Screen) -> impl Iterator<Item = String>;
}Expand description
Specifies the presentation vocabulary every renderer supplies.
A composition states what a screen says by naming these constructors; a renderer states what they look like. Nothing here names a color, a widget, a border, or a terminal.
Required Associated Types§
Required Methods§
Sourcefn text(&self, content: impl Into<String>, emphasis: Emphasis) -> Self::Text
fn text(&self, content: impl Into<String>, emphasis: Emphasis) -> Self::Text
States one run of text carrying one weight.
Sourcefn gauge(&self, gauge: Gauge) -> Self::Text
fn gauge(&self, gauge: Gauge) -> Self::Text
States one completed share as a bar of fixed width.
Sourcefn line(&self, runs: impl Iterator<Item = Self::Text>) -> Self::Line
fn line(&self, runs: impl Iterator<Item = Self::Text>) -> Self::Line
Composes runs into one line.
Sourcefn edited_line(
&self,
prefix: impl Into<String>,
text: &str,
cursor: usize,
emphasis: Emphasis,
) -> Self::Line
fn edited_line( &self, prefix: impl Into<String>, text: &str, cursor: usize, emphasis: Emphasis, ) -> Self::Line
States one line whose text is being edited in place, with its cursor.
Sourcefn row(&self, lines: impl Iterator<Item = Self::Line>) -> Self::Row
fn row(&self, lines: impl Iterator<Item = Self::Line>) -> Self::Row
Composes lines into one row.
Sourcefn rows(
&self,
title: impl Into<String>,
focused: Option<usize>,
rows: impl Iterator<Item = Self::Row>,
) -> Self::Body
fn rows( &self, title: impl Into<String>, focused: Option<usize>, rows: impl Iterator<Item = Self::Row>, ) -> Self::Body
States a named, ordered collection of rows, and which one the cursor rests on.
A renderer with less room than the rows need keeps the one the cursor rests on in view, which it can only do by being told which that is.
Sourcefn message(
&self,
title: impl Into<String>,
message: impl Into<String>,
emphasis: Emphasis,
) -> Self::Body
fn message( &self, title: impl Into<String>, message: impl Into<String>, emphasis: Emphasis, ) -> Self::Body
States one named message standing in for content there is none of yet.
Sourcefn draft(
&self,
title: impl Into<String>,
placeholder: impl Into<String>,
text: &str,
cursor: usize,
examples: impl Iterator<Item = (String, String)>,
) -> Self::Body
fn draft( &self, title: impl Into<String>, placeholder: impl Into<String>, text: &str, cursor: usize, examples: impl Iterator<Item = (String, String)>, ) -> Self::Body
States a named text draft under edit, with its cursor, what to write in it, and the shapes of what may be written.
The examples stand beside the draft rather than inside it: they are read while writing, not written over.
Sourcefn record(
&self,
title: impl Into<String>,
notes: impl Iterator<Item = String>,
) -> Self::Body
fn record( &self, title: impl Into<String>, notes: impl Iterator<Item = String>, ) -> Self::Body
States a named record, quiet and read in order.
Sourcefn verbatim(&self, text: impl Into<String>) -> Self::Body
fn verbatim(&self, text: impl Into<String>) -> Self::Body
States one text a reader takes away, with nothing drawn around it.
A reader copies this the way they copy anything else in a terminal, by selecting it, so nothing is drawn beside it that selecting would take along: no border, no label, and no break the text did not already have. What does not fit is left to the terminal to wrap.
Sourcefn screen(
&self,
header: Self::Line,
body: Self::Body,
status: impl Into<String>,
footer: Self::Line,
) -> Self::Screen
fn screen( &self, header: Self::Line, body: Self::Body, status: impl Into<String>, footer: Self::Line, ) -> Self::Screen
Composes one page from what names it, what it holds, and what can be done to it.
Sourcefn screen_text(&self, screen: &Self::Screen) -> impl Iterator<Item = String>
fn screen_text(&self, screen: &Self::Screen) -> impl Iterator<Item = String>
Observes what one composed screen states, one entry per stated line.
Every renderer can say what its screen reads as, which is what makes a presentation law checkable against the renderer that will actually draw it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".