Skip to main content

ScreenSyntax

Trait ScreenSyntax 

Source
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§

Source

type Text

Represents one styled run of text.

Source

type Line

Represents one composed line.

Source

type Row

Represents one collection row, which may state several lines.

Source

type Body

Represents the content of one page.

Source

type Screen

Represents one whole screen.

Required Methods§

Source

fn text(&self, content: impl Into<String>, emphasis: Emphasis) -> Self::Text

States one run of text carrying one weight.

Source

fn gauge(&self, gauge: Gauge) -> Self::Text

States one completed share as a bar of fixed width.

Source

fn line(&self, runs: impl Iterator<Item = Self::Text>) -> Self::Line

Composes runs into one line.

Source

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.

Source

fn row(&self, lines: impl Iterator<Item = Self::Line>) -> Self::Row

Composes lines into one row.

Source

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.

Source

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.

Source

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.

Source

fn record( &self, title: impl Into<String>, notes: impl Iterator<Item = String>, ) -> Self::Body

States a named record, quiet and read in order.

Source

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.

Source

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.

Source

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".

Implementors§