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>,
    pub edge: Option<Rgb>,
    pub roomy: bool,
    pub row_air: u16,
    pub foot: u16,
    pub row_bands: Option<(u16, Vec<u16>)>,
    pub turn: Option<u8>,
    pub spinning: bool,
    /* 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.

§edge: Option<Rgb>

The colour past the grid’s right edge, where a terminal lets a row’s picture run on over the window’s padding. Unset, it’s the colour of the row’s last cell.

§roomy: bool

Whether a row here is tall enough for a control to stand in it with its words in its middle: rows of Cellix’s own, well taller than the terminal’s line. What draws into the grid says so. Where it is, a button on a row’s wash stands inside the wash.

§row_air: u16

How tall one of these rows is in hundredths of the terminal’s line, which words are sized for: 100 unless Cellix lays out rows taller than that line. What draws into the grid says so.

§foot: u16

How many rows at the grid’s foot are bars under the sheets: one, unless what draws says there are two, as where the workspaces have a row of their own under the status bar. A backend that fills the window under its last row stands them evenly in what’s there.

§row_bands: Option<(u16, Vec<u16>)>

A row cut into bands of its own, in place of bands, as (the row, where each band after the first starts): the status bar, where a spinner is a tile by itself, so its steps don’t send the rest of the bar again, nor the bar’s other changes the spinner.

§turn: Option<u8>

The step of its turn every spinner drawn here stands at, from the clock in spinner, or none where motion is off: a spinner is then a still dot.

§spinning: bool

Whether anything drawn here is turning, so whatever shows the grid draws it again at the next step. Nothing turning, nothing asks for a frame.

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 spinner(&mut self, x: f32, y: u16, size: f32, color: Rgb, style: Style)

Something under way, in the colour of what it means: a faint ring with a quarter of it turning where there are pictures, a turning braille letter on cells, and with motion off a still dot. Its box is size rows of the terminal’s line square, as an icon’s is, starting at x and standing in the middle of row y; on cells it’s the one letter at x.

Source

pub fn spinner_in( &mut self, (x, cell): (f32, u16), y: u16, size: f32, color: Rgb, style: Style, )

The same, its letter on the cell tier in column cell rather than the one its paint starts in: where painted words are narrower than their letters, the cells keep what they can of the words before it.

Source

pub fn turn_to(&mut self, step: u8)

Takes every spinner on the grid to step of its turn, as drawing it again at that step would: when nothing else has changed, a step is this and not the whole interface laid out again. Still ones stay still.

Source

pub fn dot(&mut self, x: f32, y: u16, size: f32, color: Rgb, style: Style)

A still dot in the colour of what it means, sized and placed as a spinner is: a state that wants seeing, as an agent that needs you or one that’s done.

Source

pub fn dot_in( &mut self, (x, cell): (f32, u16), y: u16, size: f32, color: Rgb, style: Style, )

The same, its letter on the cell tier in column cell, as spinner_in’s.

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 clear_paint_in(&mut self, area: Rect)

Takes away what was painted that starts inside area, for a surface of cells laid over it: paint can’t go under text, so cells can’t cover it, and it would show through.

Source

pub fn pictures_again_in(&mut self, before: usize, area: Rect)

Paints again, clipped to area, the pictures painted before before that reach into it, for a surface that hides its edge rows’ cells whole, so no words show half covered, though its panel covers only part of their pixels: painted over that ground, a picture shows whole up to the surface’s line, and the panel painted next hides what it covers. The Ask card’s last row hid 29 px of an equation under the card’s foot (the release review of 0.12.0, q4-ask-follow-up). Fills (exact_fill) aren’t pictures and stay hidden with the words, and a picture kept to some rows (keep_to_rows) stays on them.

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 nudge_since(&mut self, from: usize, columns: f32)

Moves what was painted since from right by columns, which only the pixel tiers can show: the cells under it stay in their columns, 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 label_right_at( &mut self, right: f32, cell: u16, y: u16, text: &str, style: Style, size: u8, )

The same, its painted words ending at right, between cells, and its letters in the cells ending at cell.

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 row_button( &mut self, (x, y): (u16, u16), cells: &str, label: &str, fill: Rgb, style: Style, )

A button at the end of a row of words, which may be washed under the pointer. Where a row has room, it’s the height it has on the terminal’s line, 32 px in a row of 50 and inside a pointed row’s wash: as tall as the wash, the two read as one shape with a step in it, and taller, as a button too big for its row. Its words’ span, a capital’s top to a tail’s foot, stands in its middle as every button’s does (at 27 px a “p”’s tail ended on its foot), and it goes down with its words onto the row’s baseline (beside_words). On the terminal’s line a button and the wash have the row between them and nothing to spare, and it’s a button like any other.

Source

pub fn row_chip(&mut self, (left, right): (f32, f32), y: u16, fill: Rgb)

The chip of a button at a row’s end, from left to right between cells, behind words its caller sets where they stand with the row at rest: as tall as row_button‘s and in the middle of the row, so in the middle of a pointed row’s wash, where a row has room. Gone down onto the words’ baseline, as a row_button goes, it stood 10 px under the wash’s top and 8 over its foot.

Source

pub fn beside_words(&mut self, from: usize)

Moves a button painted since from down onto the baseline of the words beside it in its row, chip and words together (WORDS_BASELINE), where a row has room. On the terminal’s line a button has the row to itself and nothing to spare.

Source

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

A fill of color exactly where bounds is. A panel shorter than a row is stood as a control is on a taller row (raster::stood), grown or shrunk about its middle, which a surface reaching part way into a row mustn’t be: peek’s card reaching into the pane’s last row stood 4 px clear of its own cells.

Source

pub fn exact_fill_under(&mut self, index: usize, bounds: Bounds, color: Rgb)

exact_fill, put in under what’s been painted from index on.

Source

pub fn chip(&mut self, x: f32, y: u16, wide: f32, fill: Rgb)

A button’s chip by itself, as wide as asked and not a whole number of cells, for one whose words and marks are placed by what draws it.

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 button_words(&mut self, middle: f32, y: u16, label: &str, color: Rgb)

A button’s words by themselves, centred on middle in row y and standing in it as a button’s do, for a control that paints its own chip.

Source

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

Words centred on x that stand in the middle of the row starting at y as a button’s do: their font’s span, a capital’s top to a tail’s foot, in its middle, whatever their letters, so a row of buttons has one baseline. The font’s line in the row’s middle put “Show Source” 5 px under its button’s top and 10 over its foot, and the tails of “Accept Rewrite” 6 px over its foot with its capitals 9 under its top.

Source

pub fn centre_span_since(&mut self, from: usize)

Has the words painted since from stand as a button’s words do (button_label), for a button that places its own words.

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 exact_popup( &mut self, bounds: Bounds, radius: u8, fill: Rgb, border: Rgb, )

A panel floating above the page drawn exactly over bounds, however much shorter than its row: popup‘s is stood as a control is on a taller row (raster::stood), grown or shrunk about its middle, and a tip’s box sized for its words’ ink mustn’t be.

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 in the row, 16 pt in a terminal set to 14 pt, as VS Code’s are beside a name. It stands about x: its middle is where it was when it was a sixth smaller, so what’s placed after it needn’t move. fallback is what the cell tier shows there.

Source

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

The same, fallback on the cell tier in column cell, as spinner_in’s letter.

Source

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

The same icon at SMALL_GLYPH, for inside a text box or a chip, its left edge at x.

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 spans(&self, y: u16) -> Vec<(u16, u16)>

The bands of row y, as (first column, column past the last), each a tile of its own: bands, or row_bands on its own row. The last row is the status bar, which nothing scrolls in, and is one.

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.