Skip to main content

Module actions

Module actions 

Source
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§

ActivateCell
Presses the element of the focused cell of a Control column, through the handler it registered; without one, the key goes on.
AutofitColumn
Fits the current column to its header and painted rows.
AutofitColumns
Fits every visible column to its header and painted rows.
CancelEdit
Closes the open editor without a commit.
ClearAllSorting
Clears the whole sort, every column (SortOrigin::User); does nothing when nothing is sorted.
ClearGrouping
Takes every level out of the grouping; does nothing when not grouped.
ClearSort
Takes the current column out of the sort; the other sorted columns stay.
CollapseAll
Collapses every group and tree row: the default depth Levels(0), every toggle cleared.
CollapseRow
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.
CommitEdit
Commits the open editor; the focus moves as the edit gesture says for Enter (down by default).
CommitEditDown
Commits the open editor and moves down.
CommitEditNext
Commits the open editor and moves right.
CommitEditPrev
Commits the open editor and moves left.
CommitEditUp
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.
ExpandAll
Expands every group and tree row: the default depth All, every toggle cleared.
ExpandRow
Expands the focused group caption, or the focused tree row with children (GroupOrigin::User).
ExtendSelectionDown
Extends the selection to the row below.
ExtendSelectionNextColumn
Extends the selection to the visible column on the right.
ExtendSelectionPageDown
Extends the selection a page down.
ExtendSelectionPageUp
Extends the selection a page up.
ExtendSelectionPrevColumn
Extends the selection to the visible column on the left.
ExtendSelectionToFirst
Extends the selection to the first visible column.
ExtendSelectionToFirstCell
Extends the selection to the first cell.
ExtendSelectionToFirstRow
Extends the selection to the first row.
ExtendSelectionToLast
Extends the selection to the last visible column.
ExtendSelectionToLastCell
Extends the selection to the last cell.
ExtendSelectionToLastRow
Extends the selection to the last row.
ExtendSelectionUp
Extends the selection to the row above.
FreezeColumnLeft
Freezes the current column at the left edge.
FreezeColumnRight
Freezes the current column at the right edge.
GroupByColumn
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.
HideColumn
Hides the current column (never the last visible one).
MoveColumnLeft
Moves the current column one visible place left within its zone, if the column move policy allows it.
MoveColumnRight
Moves the current column one visible place right within its zone, if the column move policy allows it.
OpenLink
Opens the link of the focused cell (CellValue::Link); on any other cell, the key goes on.
ResetLayout
Restores the default layout of the schema (LiveGridState::reset_layout, with the User origin).
SelectAll
Selects every row on screen (in the cell modes, every visible cell); nothing in the single modes.
SelectFirstCell
Focuses the first row and the first visible column.
SelectFirstRow
Focuses the first row, in the same column.
SelectLastCell
Focuses the last row and the last visible column.
SelectLastRow
Focuses the last row, in the same column.
ShowAllColumns
Shows every hidden column at its place.
ShowCaptionsOnly
Shows the captions of every group level but no data rows: the default depth Captions, every toggle cleared.
ShowColumnChooser
Opens the column chooser.
ShowContextMenu
Opens the context menu at the focused cell (LiveGridState::show_context_menu).
SortAscending
Sorts by the current column alone, ascending (SortOrigin::User), if the column is sortable.
SortDescending
Sorts by the current column alone, descending (SortOrigin::User), if the column is sortable.
StartEdit
Opens the editor of the focused cell, starting from its value.
StartEditEmpty
Opens the editor of the focused cell with an empty draft.
ToggleSelection
Toggles the focused row or cell; selects it in the single modes.
UnfreezeColumn
Moves the current column back to the scrolling columns.
UngroupColumn
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_CONTEXT that names what the focused data cell’s column paints: text, element or control (CellContent), or link for 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 is NoAction there.
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, after gpui_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.