Selection & Clipboard
Selection model
rs-grid uses an anchor/focus selection model (like spreadsheets):
- Anchor — the cell where the selection started (click)
- Focus — the cell where the selection ends (shift-click or arrow keys)
The selected range is the rectangle between anchor and focus.
For details on the base selection model, see Selection.
Copy
The selection is serialized as TSV (tab-separated values, RFC 4180):
- Columns separated by
\t - Rows separated by
\n
Copy with headers
Available as a built-in context menu action (BuiltinAction::CopyWithHeaders).
Prepends a header row to the TSV output.
Cut
Same as copy, but also clears the selected cells. The clearing is recorded in the undo history.
Clear (Delete/Backspace)
Clears the selected cells to an empty string, same as the clear step of
CutSelection, but without touching the clipboard — pressing Delete or
Backspace shouldn't overwrite what's on it. No-op without a selection, or
on a full-column selection (same rationale as CutSelection: a header
click carries positional intent, not "clear this entire column"). See
Validation for how a required cell keeps its
value instead of being cleared.
On success, the same success-flash mechanism as Paste below
fires, scoped to exactly the cells CommandOutput::CellsCleared reports
as cleared — not the whole selection, so a cell skipped for being locked
or required doesn't get a misleading "success" flash.
Paste
Pastes TSV text starting at the current selection anchor. Each tab-separated value is written to the corresponding cell. The paste is recorded as a batch undo entry.
On success, rs-grid-web triggers a brief golden-yellow flash
(GridCanvas::flash_cells) on exactly the cells CommandOutput:: PasteApplied reports as written — not the whole target rectangle, so a
cell skipped for being locked or failing validation doesn't get a
misleading "success" flash. Clear reuses the
same mechanism.
Keyboard shortcuts
These are handled by the web layer (rs-grid-web) which listens to
copy, cut, and paste DOM events.
Error handling
If the selection is too large, CopySelection returns
CommandOutput::CopyError(CopyError::TooManyRows) instead of the TSV text.
Context menu
Right-click opens a context menu with clipboard actions. See Context Menu for customization options.

