Expand description
Commands of the grid, as GPUI Actions in the live_grid namespace, and
its default key bindings.
The grid handles them under the key context KEY_CONTEXT, on the
focused grid, together with the shared ones of gpui_kit::base::actions
(SelectUp, SelectPageDown, Confirm, Cancel and the rest).
init binds the default keymap of key_bindings: Excel’s, with Cmd
on macOS. An application rebinds a key in the same context after init
(the later binding wins), unbinds one with NoAction, or binds a
filtered key_bindings itself instead of calling init.
Column commands act on LiveGridState::current_column: the header
cell or band pressed last, or the focused cell’s column. With no current
column they do nothing. They have no default binding: Excel and Windows
ListView bind none of them, and Ctrl+Plus is the application’s zoom.
Nor have the sort commands, ClearAllSorting included: the
application binds them.
Tab is not bound: the grid is one Tab stop and Tab leaves it, as in the WAI-ARIA grid pattern, so the grid never traps the keyboard focus of the window around it. In an open cell editor Tab commits and moves right, Shift+Tab left.
F2 opens the focused cell’s editor, Backspace and Delete open it with an
empty draft; in the editor (EDITOR_KEY_CONTEXT, inside
KEY_CONTEXT) Enter commits and moves down, Shift+Enter and ↑ up, ↓
down, Escape cancels, and every other key of the grid is NoAction, so
the grid’s navigation and commands stay out of the way while the field
has the focus. Space on a focused cell of a Control column
(CELL_CONTENT_KEY == control) presses its element; unhandled, it
goes on to ToggleSelection.
Group captions and tree rows expand with + (Shift+= on a US layout)
and collapse with -; ← and → on a caption collapse, expand and move
along the groups as in the WAI-ARIA treegrid pattern (they stay
SelectPrevColumn and SelectNextColumn). Expand all, collapse all and
captions only have no default binding.
Structs§
- Activate
Cell - Presses the element of the focused cell of a
Controlcolumn, through the handler it registered; without one, the key goes on. - Autofit
Column - Fits the current column to its header and painted rows.
- Autofit
Columns - Fits every visible column to its header and painted rows.
- Cancel
Edit - Closes the open editor without a commit.
- Clear
AllSorting - Clears the whole sort, every column (
SortOrigin::User); does nothing when nothing is sorted. - Clear
Grouping - Takes every level out of the grouping; does nothing when not grouped.
- Clear
Sort - Takes the current column out of the sort; the other sorted columns stay.
- Collapse
All - Collapses every group and tree row: the default depth
Levels(0), every toggle cleared. - Collapse
Row - Collapses the focused group caption or tree row with children; on a data row of a grouped view, its group, and the focus goes to the group’s caption.
- Commit
Edit - Commits the open editor; the focus moves as the edit gesture says for Enter (down by default).
- Commit
Edit Down - Commits the open editor and moves down.
- Commit
Edit Next - Commits the open editor and moves right.
- Commit
Edit Prev - Commits the open editor and moves left.
- Commit
Edit Up - Commits the open editor and moves up.
- Copy
- Copies the selected rows or cells as tab-separated text.
- CopyAll
- Copies every shown row, with column headers, as tab-separated text.
- Expand
All - Expands every group and tree row: the default depth
All, every toggle cleared. - Expand
Row - Expands the focused group caption, or the focused tree row with
children (
GroupOrigin::User). - Extend
Selection Down - Extends the selection to the row below.
- Extend
Selection Next Column - Extends the selection to the visible column on the right.
- Extend
Selection Page Down - Extends the selection a page down.
- Extend
Selection Page Up - Extends the selection a page up.
- Extend
Selection Prev Column - Extends the selection to the visible column on the left.
- Extend
Selection ToFirst - Extends the selection to the first visible column.
- Extend
Selection ToFirst Cell - Extends the selection to the first cell.
- Extend
Selection ToFirst Row - Extends the selection to the first row.
- Extend
Selection ToLast - Extends the selection to the last visible column.
- Extend
Selection ToLast Cell - Extends the selection to the last cell.
- Extend
Selection ToLast Row - Extends the selection to the last row.
- Extend
Selection Up - Extends the selection to the row above.
- Freeze
Column Left - Freezes the current column at the left edge.
- Freeze
Column Right - Freezes the current column at the right edge.
- Group
ByColumn - Groups by the current column: a new last level, ascending. Does nothing for a column already grouped by, one that is not groupable, or in a tree view.
- Hide
Column - Hides the current column (never the last visible one).
- Move
Column Left - Moves the current column one visible place left within its zone, if the column move policy allows it.
- Move
Column Right - Moves the current column one visible place right within its zone, if the column move policy allows it.
- Open
Link - Opens the link of the focused cell (
CellValue::Link); on any other cell, the key goes on. - Reset
Layout - Restores the default layout of the schema
(
LiveGridState::reset_layout, with theUserorigin). - Select
All - Selects every row on screen (in the cell modes, every visible cell); nothing in the single modes.
- Select
First Cell - Focuses the first row and the first visible column.
- Select
First Row - Focuses the first row, in the same column.
- Select
Last Cell - Focuses the last row and the last visible column.
- Select
Last Row - Focuses the last row, in the same column.
- Show
AllColumns - Shows every hidden column at its place.
- Show
Captions Only - Shows the captions of every group level but no data rows: the
default depth
Captions, every toggle cleared. - Show
Column Chooser - Opens the column chooser.
- Show
Context Menu - Opens the context menu at the focused cell
(
LiveGridState::show_context_menu). - Sort
Ascending - Sorts by the current column alone, ascending (
SortOrigin::User), if the column is sortable. - Sort
Descending - Sorts by the current column alone, descending (
SortOrigin::User), if the column is sortable. - Start
Edit - Opens the editor of the focused cell, starting from its value.
- Start
Edit Empty - Opens the editor of the focused cell with an empty draft.
- Toggle
Selection - Toggles the focused row or cell; selects it in the single modes.
- Unfreeze
Column - Moves the current column back to the scrolling columns.
- Ungroup
Column - Takes the current column’s level out of the grouping; on a chip of the group panel, the chip’s level.
Constants§
- CELL_
CONTENT_ KEY - The attribute of
KEY_CONTEXTthat names what the focused data cell’s column paints:text,elementorcontrol(CellContent), orlinkfor a cell whose value is a link; absent without a focused data cell. Space presses a control:LiveGrid && cell == control; Enter opens a link:LiveGrid && cell == link. - COLUMN_
CHOOSER_ KEY_ CONTEXT - The key context of the column chooser: a layer next to the grid root,
outside
KEY_CONTEXT. - EDITOR_
KEY_ CONTEXT - The key context of an open cell editor’s host, inside
KEY_CONTEXT: its bindings are deeper than the grid’s, and every key of the grid without one of its own isNoActionthere. - GROUP_
PANEL_ KEY_ CONTEXT - The key context of the group panel, inside
KEY_CONTEXT: its keys act on the focused chip. - KEY_
CONTEXT - The key context of the grid root.
Functions§
- init
- Binds
key_bindings. Call once, aftergpui_kit::init. Without it the mouse works and the keys do not. - key_
bindings - The default keymap in
KEY_CONTEXT: Excel’s, with Cmd on macOS.secondary-is Cmd on macOS and Ctrl elsewhere, so one entry serves every platform.