Skip to main content

Grid

Struct Grid 

Source
pub struct Grid {
    pub cursor: Option<(u16, u16)>,
    pub caret: Option<Bounds>,
    pub paint: Vec<Paint>,
    pub bands: Vec<u16>,
    /* private fields */
}

Fields§

§cursor: Option<(u16, u16)>§caret: Option<Bounds>

The caret’s exact place on the pixel tiers, when text isn’t on whole cells.

§paint: Vec<Paint>

Drawn over the cells on the pixel tiers, in order.

§bands: Vec<u16>

Columns where a new band starts, in order. Each band of a row is its own tile, so text that scrolls isn’t tied to whatever the sidebar or minimap shows at that height.

Implementations§

Source§

impl Grid

Source

pub fn scroll_rows(&mut self, top: u16, bottom: u16, by: i32)

Moves rows top..=bottom up by by rows, or down if negative, across the whole width, as a terminal’s scroll region does. The rows left behind hold nothing any real cell matches, so the next diff draws them.

Source

pub fn new(width: u16, height: u16, style: Style) -> Self

Source

pub fn label( &mut self, x: u16, y: u16, text: &str, style: Style, max_x: u16, ) -> u16

Text in the interface font on the pixel tiers, and ordinary cells on the cell tier.

Source

pub fn painted_so_far(&self) -> usize

How much has been painted so far, to lift_since later.

Source

pub fn keep_to_rows(&mut self, from: usize, top: u16, bottom: u16)

Keeps what was painted since from to the rows from top up to bottom: on any other row none of it is drawn, however far it reaches.

Source

pub fn insert_paint(&mut self, index: usize, paint: Paint)

Puts paint in under what’s already painted from index on, as a mark under words is.

Source

pub fn lift_since(&mut self, from: usize, rows: f32)

Moves what was painted since from up by rows, which only the pixel tiers can show: the cells under it stay in their rows, and so does where a click lands.

Source

pub fn label_at( &mut self, x_px: f32, x: u16, y: u16, text: &str, style: Style, max_x: u16, size: u8, ) -> u16

A label starting between cells, at a size relative to the interface font.

Source

pub fn text_run( &mut self, (x, y): (f32, f32), max_x: f32, text: &str, (color, underline): (Rgb, bool), font: Font, )

Paints a run of text with no cells behind it, at a place in cells and rows.

Source

pub fn set_caret(&mut self, x: f32, y: u16, height: f32)

Puts the caret at a place between cells, height rows tall and centred on y.

Source

pub fn label_right( &mut self, right: u16, y: u16, text: &str, style: Style, size: u8, )

A label whose right edge sits at right, since proportional text is narrower than its cells and would otherwise leave a gap at the end.

Source

pub fn field(&mut self, rect: Rect, behind: Rgb, fill: Rgb, border: Rgb)

A rounded box inside rect, with square corners cleaned up behind it.

Source

pub fn button( &mut self, x: u16, y: u16, cells: &str, label: &str, fill: Rgb, style: Style, )

A rounded button in a row of its own. The cell tier shows cells, which may be wider than the label.

Source

pub fn large_button( &mut self, x: u16, y: u16, cells: &str, label: &str, fill: Rgb, style: Style, )

A button that stands past its row, for where there’s air around it.

Source

pub fn large_button_between( &mut self, x: u16, y: u16, cells: &str, label: &str, fill: Rgb, style: Style, )

A large button centred between y and the row below it.

Source

pub fn drop_last(&mut self, by: f32)

Moves what was painted last down by part of a row.

Source

pub fn centred_text(&mut self, x: f32, y: f32, text: &str, color: Rgb, size: u8)

Paints text centred on x, at a place in rows.

Source

pub fn panel( &mut self, bounds: Bounds, radius: u8, fill: Option<Rgb>, border: Option<Rgb>, )

Source

pub fn dashed_panel( &mut self, bounds: Bounds, radius: u8, fill: Option<Rgb>, border: Rgb, )

A panel with its border in dashes, for something offered rather than settled.

Source

pub fn popup(&mut self, bounds: Bounds, radius: u8, fill: Rgb, border: Rgb)

A panel floating above the page, with a soft shadow.

Source

pub fn wash( &mut self, bounds: Bounds, radius: u8, (color, alpha): (Rgb, u8), border: Option<Rgb>, )

A see-through wash of color over bounds, alpha out of 255, with a border.

Source

pub fn hairline(&mut self, bounds: Bounds, color: Rgb)

Source

pub fn glyph( &mut self, x: f32, y: u16, icon: Icon, color: Rgb, fallback: &str, style: Style, )

A small icon, one row tall, with its left edge at x. fallback is what the cell tier shows there.

Source

pub fn corners(&mut self, bounds: Bounds, radius: u8, color: Rgb, which: u8)

Paint that touches row y, in drawing order.

Source

pub fn paint_on_row(&self, y: u16) -> impl Iterator<Item = &Paint>

Source

pub fn width(&self) -> u16

Source

pub fn height(&self) -> u16

Source

pub fn area(&self) -> Rect

Source

pub fn cell(&self, x: u16, y: u16) -> &Cell

Source

pub fn row(&self, y: u16) -> &[Cell]

Source

pub fn fill(&mut self, rect: Rect, style: Style)

Source

pub fn put_str( &mut self, x: u16, y: u16, text: &str, style: Style, max_x: u16, ) -> u16

Writes text stopping before max_x, and returns the column after it. A wide character that doesn’t fit becomes a space.

Source

pub fn put_icon( &mut self, x: u16, y: u16, icon: Icon, size: (u8, u8), style: Style, )

Places a multi-cell icon with its top-left corner at x, y.

Source

pub fn set_style(&mut self, rect: Rect, f: impl Fn(Style) -> Style)

Overrides the style of existing cells, keeping their text.

Source

pub fn diff(&self, prev: &Grid) -> Vec<Run>

Spans that differ from prev. A size change makes the whole grid differ.

Source

pub fn row_text(&self, y: u16) -> String

The text of a row, for tests and copy.

Source

pub fn text(&self) -> String

Everything on screen, one line per row with trailing spaces removed.

Trait Implementations§

Source§

impl Clone for Grid

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Grid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Grid

Source§

impl PartialEq for Grid

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Grid

Auto Trait Implementations§

§

impl Forget for Grid

§

impl Freeze for Grid

§

impl Move for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.