Struct cursive::Printer[][src]

pub struct Printer<'a, 'b> {
    pub offset: Vec2,
    pub output_size: Vec2,
    pub size: Vec2,
    pub content_offset: Vec2,
    pub focused: bool,
    pub theme: &'a Theme,
    // some fields omitted
}

Convenient interface to draw on a subset of the screen.

The area it can print on is defined by offset and size.

The part of the content it will print is defined by content_offset and size.

Fields

Offset into the window this printer should start drawing at.

A print request at x will really print at x + offset.

Size of the area we are allowed to draw on.

Anything outside of this should be discarded.

Size allocated to the view.

This should be the same value as the one given in the last call to View::layout.

Offset into the view for this printer.

A print request x, will really print at x - content_offset.

Whether the view to draw is currently focused or not.

Currently used theme

Methods

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

Clear the screen.

It will discard anything drawn before.

Users rarely need to call this directly.

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

Prints a vertical line using the given character.

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

Call the given closure with a styled printer, that will apply the given style on prints.

Call the given closure with a modified printer that will apply the given effect on prints.

Call the given closure with a modified printer that will apply the given theme on prints.

Call the given closure with a modified printer that will apply each given effect on prints.

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::highlight_inactive().

Prints a horizontal delimiter with side border and .

Returns a sub-printer with the given offset.

It will print in an area slightly to the bottom/right.

Returns a new sub-printer inheriting the given focus.

If self is focused and focused == true, the child will be focused.

Otherwise, he will be unfocused.

Returns a new sub-printer with a cropped area.

The new printer size will be the minimum of size and its current size.

Any size reduction happens at the bottom-right.

Returns a new sub-printer with a shrinked area.

The printer size will be reduced by the given border from the bottom-right.

Returns a new sub-printer with a content offset.

Returns a sub-printer with a different inner size.

This will not change the actual output size, but will appear bigger to users of this printer.

Useful to give to children who think they're big, but really aren't.

Trait Implementations

impl<'a, 'b> Clone for Printer<'a, 'b>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<'a, 'b> !Send for Printer<'a, 'b>

impl<'a, 'b> !Sync for Printer<'a, 'b>