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
impl Grid
Sourcepub fn from_text(text: &str, tsv: bool) -> Self
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.
Sourcepub fn row_scroll(&self) -> usize
pub fn row_scroll(&self) -> usize
The first visible row (vertical scroll offset).
Sourcepub fn col_scroll(&self) -> usize
pub fn col_scroll(&self) -> usize
The first visible column (horizontal scroll offset).
Sourcepub fn is_editing(&self) -> bool
pub fn is_editing(&self) -> bool
Whether a cell is currently being edited.
Sourcepub fn is_finding(&self) -> bool
pub fn is_finding(&self) -> bool
Whether a search query is currently being typed.
Sourcepub fn edit_buffer(&self) -> &str
pub fn edit_buffer(&self) -> &str
The in-progress edit text (valid while Grid::is_editing).
Sourcepub fn find_buffer(&self) -> &str
pub fn find_buffer(&self) -> &str
The in-progress find text (valid while Grid::is_finding).
Sourcepub fn to_text(&self) -> String
pub fn to_text(&self) -> String
Serialize the grid back to delimited text (TSV or CSV per the source).
Sourcepub fn mark_saved(&mut self)
pub fn mark_saved(&mut self)
Mark the grid as saved (called by the host after a successful write).
Sourcepub fn ensure_row_visible(&mut self, height: usize)
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.
Sourcepub fn set_col_scroll(&mut self, first_visible: usize)
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.
Sourcepub fn handle_key(&mut self, key: KeyEvent, page: usize) -> Outcome
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.