Struct cursive::Printer
[−]
[src]
pub struct Printer<'a> { pub offset: Vec2, pub size: Vec2, pub focused: bool, pub theme: &'a 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: &'a Theme
Currently used theme
Methods
impl<'a> Printer<'a>
[src]
fn clear(&self)
[src]
Clear the screen.
It will discard anything drawn before.
Users rarely need to call this directly.
fn is_new(&self) -> bool
[src]
Returns true
if nothing has been printed yet.
fn print<S: Into<Vec2>>(&self, pos: S, text: &str)
[src]
Prints some text at the given position relative to the window.
fn print_vline<T: Into<Vec2>>(&self, start: T, len: usize, c: &str)
[src]
Prints a vertical line using the given character.
fn print_hline<T: Into<Vec2>>(&self, start: T, len: usize, c: &str)
[src]
Prints a horizontal line using the given character.
fn with_color<F>(&self, c: ColorStyle, f: F) where
F: FnOnce(&Printer),
[src]
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!"); });
fn with_effect<F>(&self, effect: Effect, f: F) where
F: FnOnce(&Printer),
[src]
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
)
[src]
&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);
fn with_high_border<F>(&self, invert: bool, f: F) where
F: FnOnce(&Printer),
[src]
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),
[src]
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)
[src]
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)
[src]
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>
[src]
&'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
[src]
Returns a sub-printer with the given offset.