Struct cursive::Printer
[−]
[src]
pub struct Printer<'a> { pub offset: Vec2, pub size: Vec2, pub focused: bool, pub theme: Theme, // some fields omitted }
Convenient interface to draw on a subset of the screen.
Fields
offset: Vec2
Offset into the window this printer should start drawing at.
size: Vec2
Size of the area we are allowed to draw on.
focused: bool
Whether the view to draw is currently focused or not.
theme: Theme
Currently used theme
Methods
impl<'a> Printer<'a>
[src]
fn print<S: Into<Vec2>>(&self, pos: S, text: &str)
Prints some text at the given position relative to the window.
fn print_vline<T: Into<Vec2>>(&self, start: T, len: usize, c: &str)
Prints a vertical line using the given character.
fn print_hline<T: Into<Vec2>>(&self, start: T, len: usize, c: &str)
Prints a horizontal line using the given character.
fn with_color<F>(&self, c: ColorStyle, f: F) where F: FnOnce(&Printer)
Call the given closure with a colored printer, that will apply the given color on prints.
Examples
printer.with_color(theme::ColorStyle::Highlight, |printer| { printer.print((0,0), "This text is highlighted!"); });Run
fn with_effect<F>(&self, effect: Effect, f: F) where F: FnOnce(&Printer)
Same as with_color
, but apply a ncurses style instead,
like ncurses::A_BOLD()
or ncurses::A_REVERSE()
.
Will probably use a cursive enum some day.
fn print_box<T: Into<Vec2>, S: Into<Vec2>>(&self, start: T, size: S, invert: bool)
Prints a rectangular box.
If invert
is true
, and the theme uses Outset
borders, then the
box will use an "inset" style instead.
Examples
printer.print_box((0,0), (6,4), false);Run
fn with_high_border<F>(&self, invert: bool, f: F) where F: FnOnce(&Printer)
Runs the given function using a color depending on the theme.
- If the theme's borders is
None
, return without callingf
. - If the theme's borders is "outset" and
invert
isfalse
, useColorStyle::Tertiary
. - Otherwise, use
ColorStyle::Primary
.
fn with_low_border<F>(&self, invert: bool, f: F) where F: FnOnce(&Printer)
Runs the given function using a color depending on the theme.
- If the theme's borders is
None
, return without callingf
. - If the theme's borders is "outset" and
invert
istrue
, useColorStyle::Tertiary
. - Otherwise, use
ColorStyle::Primary
.
fn with_selection<F: FnOnce(&Printer)>(&self, selection: bool, f: F)
Apply a selection style and call the given function.
- If
selection
isfalse
, simply usesColorStyle::Primary
. - If
selection
istrue
:- If the printer currently has the focus,
uses
ColorStyle::Highlight
. - Otherwise, uses
ColorStyle::HighlightInactive
.
- If the printer currently has the focus,
uses
fn print_hdelim<T: Into<Vec2>>(&self, start: T, len: usize)
Prints a horizontal delimiter with side border ├
and ┤
.
fn sub_printer<S: Into<Vec2>, T: Into<Vec2>>(&'a self, offset: S, size: T, focused: bool) -> Printer<'a>
Returns a printer on a subset of this one's area.
fn offset<S: Into<Vec2>>(&self, offset: S, focused: bool) -> Printer
Returns a sub-printer with the given offset.