[][src]Trait cursive::backend::Backend

pub trait Backend {
    fn poll_event(&mut self) -> Option<Event>;
fn finish(&mut self);
fn refresh(&mut self);
fn has_colors(&self) -> bool;
fn screen_size(&self) -> Vec2;
fn print_at(&self, pos: Vec2, text: &str);
fn clear(&self, color: Color);
fn set_color(&self, colors: ColorPair) -> ColorPair;
fn set_effect(&self, effect: Effect);
fn unset_effect(&self, effect: Effect); fn print_at_rep(&self, pos: Vec2, repetitions: usize, text: &str) { ... }
fn name(&self) -> &str { ... } }

Trait defining the required methods to be a backend.

A backend is the interface between the abstract view tree and the actual input/output, like a terminal.

It usually delegates the work to a terminal-handling library like ncurses or termion, or it can entirely simulate a terminal and show it as a graphical window (BearLibTerminal).

When creating a new cursive tree with Cursive::new(), you will need to provide a backend initializer - usually their init() function.

Backends are responsible for handling input and converting it to Event. Input must be non-blocking, it will be polled regularly.

Required methods

fn poll_event(&mut self) -> Option<Event>

Polls the backend for any input.

Should return immediately.

fn finish(&mut self)

Prepares to close the backend.

This should clear any state in the terminal.

fn refresh(&mut self)

Refresh the screen.

This will be called each frame after drawing has been done.

A backend could, for example, buffer any print command, and apply everything when refresh() is called.

fn has_colors(&self) -> bool

Should return true if this backend supports colors.

fn screen_size(&self) -> Vec2

Returns the screen size.

fn print_at(&self, pos: Vec2, text: &str)

Main method used for printing

fn clear(&self, color: Color)

Clears the screen with the given color.

fn set_color(&self, colors: ColorPair) -> ColorPair

Starts using a new color.

This should return the previously active color.

Any call to print_at from now on should use the given color.

fn set_effect(&self, effect: Effect)

Enables the given effect.

Any call to print_at from now on should use the given effect.

fn unset_effect(&self, effect: Effect)

Disables the given effect.

Loading content...

Provided methods

fn print_at_rep(&self, pos: Vec2, repetitions: usize, text: &str)

First positions the cursor, similar to print_at, and then prints the given number of repetitions of text.

fn name(&self) -> &str

Returns a name to identify the backend.

Mostly used for debugging.

Loading content...

Implementors

impl Backend for cursive::backend::curses::n::Backend[src]

impl Backend for cursive::backend::dummy::Backend[src]

impl Backend for cursive::backend::puppet::Backend[src]

Loading content...