csvtool/commands.go
exe.dev user df8ade2c4d Replace Match Row with Match Cell (Cmd+M)
- New 'Match Cell' command selects all cells in the sheet whose value
  equals the current cell's value (non-contiguous selection)
- Added state.selectedCells (Set of 'r,c' keys) for scatter selection
- isCellSelected checks selectedCells first, then falls back to
  rectangular selection
- getSelectedData/clearSelectedCells handle non-contiguous selections
- Cmd+M keyboard shortcut mapped
- Match selection cleared on click, arrow movement, or Escape

Co-authored-by: Shelley <shelley@exe.dev>
2026-03-05 03:06:03 +00:00

40 lines
1.5 KiB
Go

package main
// Command represents a command that can be executed in the application.
type Command struct {
ID string `json:"ID"`
Name string `json:"Name"`
Shortcut string `json:"Shortcut"`
}
// CommandRegistry provides command metadata to the frontend.
type CommandRegistry struct{}
// NewCommandRegistry creates a new CommandRegistry.
func NewCommandRegistry() *CommandRegistry {
return &CommandRegistry{}
}
// GetCommands returns the list of all available commands.
func (c *CommandRegistry) GetCommands() []Command {
return []Command{
{ID: "copy", Name: "Copy", Shortcut: "Cmd+C"},
{ID: "cut", Name: "Cut", Shortcut: "Cmd+X"},
{ID: "copy-markdown", Name: "Copy as Markdown", Shortcut: ""},
{ID: "copy-jira", Name: "Copy as Jira", Shortcut: ""},
{ID: "paste", Name: "Paste", Shortcut: "Cmd+V"},
{ID: "resize-all", Name: "Resize All Columns", Shortcut: ""},
{ID: "open", Name: "Open File", Shortcut: "Cmd+O"},
{ID: "save", Name: "Save File", Shortcut: "Cmd+S"},
{ID: "open-up", Name: "Insert Row Above", Shortcut: ""},
{ID: "open-down", Name: "Insert Row Below", Shortcut: ""},
{ID: "open-left", Name: "Insert Column Left", Shortcut: ""},
{ID: "open-right", Name: "Insert Column Right", Shortcut: ""},
{ID: "sort-asc", Name: "Sort A-Z", Shortcut: ""},
{ID: "sort-desc", Name: "Sort Z-A", Shortcut: ""},
{ID: "sort-advanced", Name: "Sort Advanced", Shortcut: ""},
{ID: "match-cell", Name: "Match Cell", Shortcut: "Cmd+M"},
{ID: "delete-row", Name: "Delete Row", Shortcut: "Cmd+Backspace"},
}
}