mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
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).
This commit is contained in:
@@ -192,21 +192,21 @@ egr() # }}}
|
||||
agr('shortcuts', 'Keyboard shortcuts')
|
||||
|
||||
map('Quit',
|
||||
'quit q quit',
|
||||
'quit --allow-fallback=shifted,ascii q quit',
|
||||
)
|
||||
map('Quit',
|
||||
'quit esc quit',
|
||||
)
|
||||
|
||||
map('Scroll down',
|
||||
'scroll_down j scroll_by 1',
|
||||
'scroll_down --allow-fallback=shifted,ascii j scroll_by 1',
|
||||
)
|
||||
map('Scroll down',
|
||||
'scroll_down down scroll_by 1',
|
||||
)
|
||||
|
||||
map('Scroll up',
|
||||
'scroll_up k scroll_by -1',
|
||||
'scroll_up --allow-fallback=shifted,ascii k scroll_by -1',
|
||||
)
|
||||
map('Scroll up',
|
||||
'scroll_up up scroll_by -1',
|
||||
@@ -227,41 +227,41 @@ map('Scroll to next page',
|
||||
'scroll_page_down space scroll_to next-page',
|
||||
)
|
||||
map('Scroll to next page',
|
||||
'scroll_page_down ctrl+f scroll_to next-page',
|
||||
'scroll_page_down --allow-fallback=shifted,ascii ctrl+f scroll_to next-page',
|
||||
)
|
||||
|
||||
map('Scroll to previous page',
|
||||
'scroll_page_up page_up scroll_to prev-page',
|
||||
)
|
||||
map('Scroll to previous page',
|
||||
'scroll_page_up ctrl+b scroll_to prev-page',
|
||||
'scroll_page_up --allow-fallback=shifted,ascii ctrl+b scroll_to prev-page',
|
||||
)
|
||||
|
||||
map('Scroll down half page',
|
||||
'scroll_half_page_down ctrl+d scroll_to next-half-page',
|
||||
'scroll_half_page_down --allow-fallback=shifted,ascii ctrl+d scroll_to next-half-page',
|
||||
)
|
||||
map('Scroll up half page',
|
||||
'scroll_half_page_up ctrl+u scroll_to prev-half-page',
|
||||
'scroll_half_page_up --allow-fallback=shifted,ascii ctrl+u scroll_to prev-half-page',
|
||||
)
|
||||
|
||||
map('Scroll to next change',
|
||||
'next_change n scroll_to next-change',
|
||||
'next_change --allow-fallback=shifted,ascii n scroll_to next-change',
|
||||
)
|
||||
|
||||
map('Scroll to previous change',
|
||||
'prev_change p scroll_to prev-change',
|
||||
'prev_change --allow-fallback=shifted,ascii p scroll_to prev-change',
|
||||
)
|
||||
|
||||
map('Scroll to next file',
|
||||
'next_file shift+j scroll_to next-file',
|
||||
'next_file --allow-fallback=shifted,ascii shift+j scroll_to next-file',
|
||||
)
|
||||
|
||||
map('Scroll to previous file',
|
||||
'prev_file shift+k scroll_to prev-file',
|
||||
'prev_file --allow-fallback=shifted,ascii shift+k scroll_to prev-file',
|
||||
)
|
||||
|
||||
map('Show all context',
|
||||
'all_context a change_context all',
|
||||
'all_context --allow-fallback=shifted,ascii a change_context all',
|
||||
)
|
||||
|
||||
map('Show default context',
|
||||
@@ -299,15 +299,17 @@ map('Scroll to previous search match',
|
||||
)
|
||||
|
||||
map('Search forward (no regex)',
|
||||
'search_forward_simple f start_search substring forward',
|
||||
'search_forward_simple --allow-fallback=shifted,ascii f start_search substring forward',
|
||||
)
|
||||
|
||||
map('Search backward (no regex)',
|
||||
'search_backward_simple b start_search substring backward',
|
||||
'search_backward_simple --allow-fallback=shifted,ascii b start_search substring backward',
|
||||
)
|
||||
|
||||
map('Copy selection to clipboard', 'copy_to_clipboard y copy_to_clipboard')
|
||||
map('Copy selection to clipboard or exit if no selection is present', 'copy_to_clipboard_or_exit ctrl+c copy_to_clipboard_or_exit')
|
||||
map('Copy selection to clipboard', 'copy_to_clipboard --allow-fallback=shifted,ascii y copy_to_clipboard')
|
||||
map('Copy selection to clipboard or exit if no selection is present',
|
||||
'copy_to_clipboard_or_exit --allow-fallback=shifted,ascii ctrl+c copy_to_clipboard_or_exit',
|
||||
)
|
||||
|
||||
egr() # }}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user