[−][src]Trait cursive::backend::Backend
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
pub fn poll_event(&mut self) -> Option<Event>
[src]
Polls the backend for any input.
Should return immediately:
None
if no event is currently available.Some(event)
for each event to process.
pub fn refresh(&mut self)
[src]
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.
pub fn has_colors(&self) -> bool
[src]
Should return true
if this backend supports colors.
pub fn screen_size(&self) -> XY<usize>
[src]
Returns the screen size.
pub fn print_at(&self, pos: XY<usize>, text: &str)
[src]
Main method used for printing
pub fn clear(&self, color: Color)
[src]
Clears the screen with the given color.
pub fn set_color(&self, colors: ColorPair) -> ColorPair
[src]
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.
pub fn set_effect(&self, effect: Effect)
[src]
Enables the given effect.
Any call to print_at
from now on should use the given effect.
pub fn unset_effect(&self, effect: Effect)
[src]
Disables the given effect.
Provided methods
pub fn print_at_rep(&self, pos: XY<usize>, repetitions: usize, text: &str)
[src]
Efficient method to print repetitions of the same text.
Usually used to draw horizontal lines/borders.
It is a small optimization to avoid moving the cursor after each step.
pub fn name(&self) -> &str
[src]
Returns a name to identify the backend.
Mostly used for debugging.