Struct cursive::Printer [] [src]

pub struct Printer {
    pub offset: Vec2,
    pub size: Vec2,
    pub focused: bool,
    pub theme: Theme,
}

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 Printer
[src]

fn new<T: Into<Vec2>>(size: T, theme: Theme) -> Self

Creates a new printer on the given window.

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!");
});

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)

Prints a rectangular box.

Examples

printer.print_box((0,0), (6,4));

fn with_selection<F: FnOnce(&Printer)>(&self, selection: bool, f: F)

Apply a selection style and call the given function.

  • If selection is false, simply uses ColorStyle::Primary.
  • If selection is true:
    • If the printer currently has the focus, uses ColorStyle::Highlight.
    • Otherwise, uses ColorStyle::HighlightInactive.

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>>(&self, offset: S, size: T, focused: bool) -> Printer

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.

Trait Implementations

impl Clone for Printer
[src]

fn clone(&self) -> Printer

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more