Commit graph

16 commits

Author SHA1 Message Date
Kovid Goyal
c3d1665fa6
run go modernizer 2026-04-16 19:12:31 +05:30
Daniel M German
640225315a Fix ruff E731: replace lambda assignment with def 2026-04-06 09:54:56 -07:00
Daniel M German
3d89cb267c Add alias and combine support to the command palette
Users who define action_alias or kitten_alias in kitty.conf had no way
to discover or trigger these custom commands from the command palette.
Aliased keybindings were miscategorized (landing in "Miscellaneous"
with no help text), and combine bindings had the same problem.

Changes:

- Resolve aliases via opts.alias_map to get correct action names,
  categories, and help text for aliased keybindings
- Add dedicated "Action aliases" and "Kitten aliases" sections that
  list all user-defined aliases, with bound aliases showing their key
  and unbound aliases browsable as unmapped entries
- Add a "Combined actions" section for combine keybindings
- Make alias names searchable in the Go TUI so users can find
  bindings by typing the alias name
- Fix action column highlight positions to match the scored text,
  preventing visual corruption when searching for alias names

Also refactors collect_keys_data into focused single-responsibility
functions and reduces nesting depth across both Python and Go.
2026-04-06 09:45:39 -07:00
Павел Мешалкин
8ffdf7d7ee feat: add per-mapping --allow-fallback for layout-independent shortcuts
Add --allow-fallback option to the map command that controls shifted
and ascii (alternate_key) fallback for individual key mappings.

For non-Latin keyboard layouts, when the current layout key is
non-ascii (codepoint > 127 and < 0xE000), the alternate_key from
the base layout is used for matching if the mapping opts in via
--allow-fallback=shifted,ascii.

Default kitty bindings use --allow-fallback=shifted,ascii so they
work out of the box with non-Latin layouts. User custom mappings
default to --allow-fallback=shifted (preserving existing shifted_key
behavior without ascii fallback).

--allow-fallback=none disables all fallback for a mapping.

Python side: parse_options_for_map() in options/utils.py handles flag
parsing, ShortcutMapping uses it in __init__. get_shortcut() filters
candidates by per-mapping allow_fallback.

Go side: ParseMap() handles --allow-fallback, KeyAction stores
AllowFallback, ShortcutTracker.Match passes it to matching.
MatchesParsedShortcut defaults to shifted,ascii for hardcoded shortcuts.

Migrated kittens (themes, command_palette, diff, choose_files) to
use ShortcutTracker with configurable map entries.

Tests added for Python (5 test methods) and Go (ParseMap + key matching).
2026-03-25 19:34:13 +03:00
Daniel M German
9619571dd3 Command palette: fix gofmt struct field alignment in tests 2026-03-22 17:59:42 -07:00
Daniel M German
6a3fe6ae01 Command palette: word-level search with multi-token cross-column matching
Implement a word-level scoring engine for the command palette that replaces
the previous FZF-based approach. Query tokens are matched against pre-tokenized
words in each column (key, action, category) with exact, prefix, and
edit-distance scoring. Multiple search terms are supported with cross-column
matching — items matching more tokens rank higher. Compound query tokens
containing delimiters (e.g. mouse_selection) are matched as units.

Add comprehensive tests using a Go builder API instead of raw JSON blobs,
covering single-token, multi-token, partial-match, ranking, mouse binding,
and unmapped action scenarios.

Add documentation for the command palette kitten.
2026-03-22 17:28:28 -07:00
Kovid Goyal
eddaaed3e3
Modernize Go code 2026-03-21 08:41:47 +05:30
Kovid Goyal
9aa938c6cd
Make the error message a bit more clear 2026-03-11 21:13:24 +05:30
Kovid Goyal
ebbfb206e6
Run command palette action after event loop tick 2026-03-03 15:44:08 +05:30
Kovid Goyal
ab40d41609
Make gofmt happy 2026-03-03 15:37:55 +05:30
copilot-swe-agent[bot]
5638d20921
Make showing of unmapped actions a runtime cached setting
Fixes #9591
2026-03-03 15:24:26 +05:30
copilot-swe-agent[bot]
f13c8cd44d
Allow optionally showing unmapped actions in the command palette
Also highlight letters matching the search query.
Fixes #9589
2026-03-03 14:29:10 +05:30
Kovid Goyal
4ec1fa5168
Prevent invocation of command-palette from command line 2026-03-03 13:13:20 +05:30
copilot-swe-agent[bot]
347c829156
Cleanup previous PR
Various fixes and improvements to the command palette kitten

Fixes #9585
2026-03-03 13:04:26 +05:30
Daniel M German
6fa122af11 Fix action triggering by using kitten output instead of remote control
The RC approach sent actions targeting the overlay window itself rather
than the underlying window. Switch to the standard kitten output pattern:
the Go kitten outputs the selected action definition via
KittenOutputSerializer, and handle_result in Python calls boss.combine()
with the correct target window after the overlay closes.
2026-02-22 21:12:36 -08:00
Daniel M German
33b5b0a339 Add command_palette command to display bound keys
Add a Go-based command_palette kitten that provides a searchable,
interactive overlay for browsing and triggering keyboard shortcuts
and actions.

- New Go kitten at kittens/command_palette/ with FZF fuzzy search,
  grouped/flat views, and remote control action triggering
- Python collect_keys_data() does data collection, passed via stdin
- Navigation: arrows, ctrl+j/k (vim), ctrl+n/p (emacs), page up/down
- Enter triggers the selected action via RC command
- Help text displayed in footer for selected binding
- Added Go tests (main_test.go) and Python tests (command_palette.py)
2026-02-22 20:46:47 -08:00