pub struct Crossterm<PainterT: Painter = IncrementalPainter> { /* private fields */ }
Expand description

A terminal backend implementation for Zi using crossterm

fn main() -> zi_term::Result<()> {
    zi_term::incremental()?
        .run_event_loop(Text::with(TextProperties::new().content("Hello, world!")))
}

Implementations

Create a new backend instance.

This method initialises the underlying tty device, enables raw mode, hides the cursor and enters alternative screen mode. Additionally, an async event stream with input events from stdin is started.

Starts the event loop. This is the main entry point of a Zi application. It draws and presents the components to the backend, handles user input and delivers messages to components. This method returns either when prompted using the exit method on ComponentLink or on error.

fn main() -> zi_term::Result<()> {
    zi_term::incremental()?
        .run_event_loop(Text::with(TextProperties::new().content("Hello, world!")))
}

Suspends the event stream.

This is used when running something that needs exclusive access to the underlying terminal (i.e. to stdin and stdout). For example spawning an external editor to collect or display text. The resume function is called upon returning to the application.

Recreates the event stream and reinitialises the underlying terminal.

This function is used to return execution to the application after running something that needs exclusive access to the underlying backend. It will only be called after a call to suspend.

In addition to restarting the event stream, this function should perform any other required initialisation of the backend. For ANSI terminals, this typically hides the cursor and saves the current screen content (i.e. “alternative screen mode”) in order to restore the previous terminal content on exit.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.