Skip to main content

Grid

Struct Grid 

Source
pub struct Grid { /* private fields */ }
Expand description

A spreadsheet-like grid of string cells with a cell cursor and edit history.

Implementations§

Source§

impl Grid

Source

pub fn from_text(text: &str, tsv: bool) -> Self

Build a grid from delimited text. tsv selects the tab-separated parser; otherwise RFC 4180 CSV is used. The grid is normalized to a rectangle (short rows are padded with empty cells) and always has at least one row and one column.

Source

pub fn row_count(&self) -> usize

Number of rows (including the header).

Source

pub fn col_count(&self) -> usize

Number of columns.

Source

pub fn cell(&self, r: usize, c: usize) -> &str

The cell at (r, c), or "" when out of range.

Source

pub fn row(&self) -> usize

The selected row index.

Source

pub fn col(&self) -> usize

The selected column index.

Source

pub fn row_scroll(&self) -> usize

The first visible row (vertical scroll offset).

Source

pub fn col_scroll(&self) -> usize

The first visible column (horizontal scroll offset).

Source

pub fn is_dirty(&self) -> bool

Whether the grid has unsaved edits.

Source

pub fn is_editing(&self) -> bool

Whether a cell is currently being edited.

Source

pub fn is_finding(&self) -> bool

Whether a search query is currently being typed.

Source

pub fn edit_buffer(&self) -> &str

The in-progress edit text (valid while Grid::is_editing).

Source

pub fn find_buffer(&self) -> &str

The in-progress find text (valid while Grid::is_finding).

Source

pub fn to_text(&self) -> String

Serialize the grid back to delimited text (TSV or CSV per the source).

Source

pub fn mark_saved(&mut self)

Mark the grid as saved (called by the host after a successful write).

Source

pub fn ensure_row_visible(&mut self, height: usize)

Adjust the vertical scroll so the selected data row stays within the body window of height rows. Row 0 is a pinned header rendered separately, so the body always starts at row 1 or later. Called before drawing.

Source

pub fn set_col_scroll(&mut self, first_visible: usize)

Set the horizontal scroll so the selected column is visible. The renderer computes first_visible from the variable column widths and the viewport.

Source

pub fn handle_key(&mut self, key: KeyEvent, page: usize) -> Outcome

Interpret a key event, mutating the grid, and report what the host should do next. page is the number of rows to move for PageUp/PageDown.

Auto Trait Implementations§

§

impl Freeze 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> 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, 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.