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 into the window this printer should start drawing at.

Size of the area we are allowed to draw on.

Whether the view to draw is currently focused or not.

Currently used theme

Methods

impl<'a> Printer<'a>
[src]

Clear the screen.

It will discard anything drawn before.

Users rarely need to call this directly.

Returns true if nothing has been printed yet.

Prints some text at the given position relative to the window.

Prints a vertical line using the given character.

Prints a horizontal line using the given character.

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

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.

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);

Runs the given function using a color depending on the theme.

  • If the theme's borders is None, return without calling f.
  • If the theme's borders is "outset" and invert is false, use ColorStyle::Tertiary.
  • Otherwise, use ColorStyle::Primary.

Runs the given function using a color depending on the theme.

  • If the theme's borders is None, return without calling f.
  • If the theme's borders is "outset" and invert is true, use ColorStyle::Tertiary.
  • Otherwise, use ColorStyle::Primary.

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.

Prints a horizontal delimiter with side border and .

Returns a printer on a subset of this one's area.

Returns a sub-printer with the given offset.