Struct cursive::view::ScrollBase [] [src]

pub struct ScrollBase {
    pub start_line: usize,
    pub content_height: usize,
    pub view_height: usize,
    pub scrollbar_offset: usize,
    pub right_padding: usize,
}

Provide scrolling functionalities to a view.

You're not supposed to use this directly, but it can be helpful if you create your own Views.

Fields

First line visible

Content height

Number of lines displayed

Padding for the scrollbar

If present, the scrollbar will be shifted scrollbar_offset columns to the left.

(Useful when each item includes its own side borders, to draw the scrollbar inside.)

Blank between the text and the scrollbar.

Methods

impl ScrollBase
[src]

Creates a new, uninitialized scrollbar.

Shifts the scrollbar toward the inside of the view.

Used by views that draw their side borders in the children. Pushing the scrollbar to the left allows it to stay inside the borders.

Sets the number of blank cells between the text and the scrollbar.

Defaults to 1.

Call this method whem the content or the view changes.

Returns TRUE if the view needs to scroll.

Returns TRUE unless we are at the top.

Returns TRUE unless we are at the bottom.

Scroll to the top of the view.

Makes sure that the given line is visible, scrolling if needed.

Scroll to the bottom of the view.

Scroll down by the given number of line.

Never further than the bottom of the view.

Scroll up by the given number of lines.

Never above the top of the view.

Draws the scroll bar and the content using the given drawer.

line_drawer will be called once for each line that needs to be drawn. It will be given the absolute ID of the item to draw.. It will also be given a printer with the correct offset, so it should only print on the first line.

Examples

let lines = ["Line 1", "Line number 2"];
scrollbase.draw(printer, |printer, i| {
    printer.print((0,0), lines[i]);
});

Trait Implementations

impl Default for ScrollBase
[src]

Returns the "default value" for a type. Read more