43 Commits

Author SHA1 Message Date
Kovid Goyal
80ad647336 Start work on config watcher kitten 2026-04-16 12:37:43 +05:30
copilot-swe-agent[bot]
6a0efbfdba Refactor ShortcutTracker.Match() to respect AllowFallback priority order
Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/85fbf706-4688-4901-9a23-907cebc91da3
2026-03-26 04:31:37 +00:00
Kovid Goyal
88ee80b327 Cleanup previous PR
Actually respect the fallback order when finding matching shortcuts
2026-03-26 09:30:14 +05:30
Павел Мешалкин
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
Kovid Goyal
6f588a0c29 run modernize 2025-11-11 17:09:37 +05:30
Eng Zer Jun
d5455ab072 Update github.com/shirou/gopsutil to v4
v4 is the latest version with bug fixes and enhancements, notably the
removal of CGO implementations on Darwin in v4.24.9 [1].

Note: Due to the library's versioning policy, v4.24.5 is the first v4
release [2].

[1]: https://github.com/shirou/gopsutil/releases/tag/v4.24.9
[2]: https://github.com/shirou/gopsutil/releases/tag/v4.24.5

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-10-31 23:14:38 +08:00
Kovid Goyal
c861259e3b Rename go module from kitty -> github.com/kovidgoyal/kitty
Makes the code more easily re-useable in other projects
2025-05-16 08:43:39 +05:30
Kovid Goyal
341df0dccb More CodeQL fixes 2025-04-20 22:13:45 +05:30
Kovid Goyal
237bb35ee9 More CodeQL fixes 2025-04-20 21:53:11 +05:30
Kovid Goyal
1eeea70c7a Allow dynamically generating configuration by running an arbitrary program using the new geninclude directive 2025-01-06 19:00:01 +05:30
Kovid Goyal
795bf7fb52 Dont use a global var for mocking 2025-01-05 20:58:33 +05:30
Kovid Goyal
86a6685446 Add mock for failing test 2025-01-05 20:36:32 +05:30
Kovid Goyal
2d02ff1c5f Implement using effective kitty config options for kittens
Also centralise reading of kitty options
2025-01-05 20:16:43 +05:30
Kovid Goyal
8b7cd98a0e When running a kitten that modifies the kitty config file if no config file exists create a commented out default config file and then modify it
Fixes #7991
2024-10-28 14:01:42 +05:30
Kovid Goyal
e74188fcf0 Switch to using ps to get all processes
The Go process module is very slow to get Exe() on non-Linux systems
without CGO as it works by calling lsof on the pid. So we anyway have to
filter by command line first. So might as well just use ps in that case.
2024-08-19 20:54:54 +05:30
Kovid Goyal
9708959438 When reloading in all kitty instances, only use readlink on processes that contain "kitty" in the image name
Apparently there are some machines where a few hundred/thousand readlink calls
take 30 seconds! See #7744
2024-08-19 19:18:37 +05:30
Kovid Goyal
c906314974 change the atomic write functions to work with readers 2024-07-22 15:01:19 +05:30
Kovid Goyal
da9a36d918 Fix reload of kitty config not working if kitty launched via symlink not named kitty 2024-07-04 19:07:15 +05:30
Kovid Goyal
f15eebec02 Refactor config patching code to make it re-useable 2024-06-24 07:54:17 +05:30
Kovid Goyal
405f5ce148 Use stdlib maps/slices 2024-06-24 07:54:13 +05:30
Kovid Goyal
2b751f56bd Port test 2023-11-22 10:50:05 +05:30
Kovid Goyal
882d471c90 Make config line parsing in Go use same algorithm as in python 2023-11-22 10:01:45 +05:30
Kovid Goyal
fc64ef41b3 when parsing conf files in go accept both space and tab as key separators 2023-11-22 09:49:33 +05:30
Kovid Goyal
1a32e62ebf More linter fixes 2023-09-18 21:07:39 +05:30
Kovid Goyal
4ffb22199b Cleanup previous PR 2023-09-03 18:59:37 +05:30
Jake Stewart
8754d80832 add tests for go config parser 2023-09-03 16:39:27 +08:00
Jake Stewart
0aa4c850ba add line break syntax to go config parser 2023-09-03 16:39:13 +08:00
Kovid Goyal
4f72bb9894 Replace utils.Once with stdlib sync.OnceValue 2023-08-09 12:08:42 +05:30
Kovid Goyal
49ea26968c Bump go version to 1.21
Allows us to use the much faster builtin min/max functions
for two variable min/max
2023-08-09 11:58:16 +05:30
Kovid Goyal
e59e42a6c2 simplify API of utils.Once 2023-05-26 22:42:07 +05:30
Kovid Goyal
7803b07e7f Ignore leading and trailing space around values when parsing config lines 2023-04-06 10:45:34 +05:30
Kovid Goyal
912aa17594 ... 2023-04-05 08:08:54 +05:30
Kovid Goyal
708267d229 Fix parsing of actions in map directives in Go 2023-04-05 07:55:18 +05:30
Kovid Goyal
3ee77a3a57 Fix #6154 2023-04-04 21:18:27 +05:30
Kovid Goyal
14b58ba015 Fix overrides not being parsed correctly 2023-03-27 07:53:56 +05:30
Kovid Goyal
425ab4f6d8 Start implementing shortcut handling 2023-03-27 07:53:55 +05:30
Kovid Goyal
d208670172 Abstract typical config file loading with path and cli overrides 2023-03-27 07:53:54 +05:30
Kovid Goyal
5329546f21 Implement parsing of map 2023-03-27 07:53:54 +05:30
Kovid Goyal
da38cb3254 Add support for more option types to Go conf file parsing 2023-03-15 15:17:38 +05:30
Kovid Goyal
f42090766a Use the new string scanner everywhere 2023-03-08 13:31:27 +05:30
Kovid Goyal
7ce64fcde0 Support include when loading themes from dirs 2023-02-26 21:16:29 +05:30
Kovid Goyal
07f4adbab5 Also add tests for bad lines 2023-02-26 08:01:02 +05:30
Kovid Goyal
7b4738125b Move config code into its own package 2023-02-26 08:01:02 +05:30