macOS: Make the global keybinding used for preferences also configurable

This commit is contained in:
Kovid Goyal 2021-02-25 06:58:20 +05:30
parent 5fd6c6b9a1
commit 52347ced85
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 3 deletions

View file

@ -121,7 +121,7 @@ + (GlobalMenuTarget *) shared_instance
NSEventModifierFlags mods;
} GlobalShortcut;
typedef struct {
GlobalShortcut new_os_window, close_os_window, close_tab;
GlobalShortcut new_os_window, close_os_window, close_tab, edit_config_file;
} GlobalShortcuts;
static GlobalShortcuts global_shortcuts;
@ -135,6 +135,7 @@ + (GlobalMenuTarget *) shared_instance
if (strcmp(name, "new_os_window") == 0) gs = &global_shortcuts.new_os_window;
else if (strcmp(name, "close_os_window") == 0) gs = &global_shortcuts.close_os_window;
else if (strcmp(name, "close_tab") == 0) gs = &global_shortcuts.close_tab;
else if (strcmp(name, "edit_config_file") == 0) gs = &global_shortcuts.edit_config_file;
if (gs == NULL) { PyErr_SetString(PyExc_KeyError, "Unknown shortcut name"); return NULL; }
int cocoa_mods;
get_cocoa_key_equivalent(key, mods, gs->key, 32, &cocoa_mods);
@ -374,7 +375,7 @@ - (BOOL)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {
[appMenu addItem:[NSMenuItem separatorItem]];
[[appMenu addItemWithTitle:@"Preferences..."
action:@selector(show_preferences:)
keyEquivalent:@","]
keyEquivalent:@(global_shortcuts.edit_config_file.key)]
setTarget:global_menu_target];
NSMenuItem* new_os_window_menu_item =

View file

@ -1572,6 +1572,8 @@ def macos_option_as_alt(x: str) -> int:
k('toggle_maximized', 'kitty_mod+f10', 'toggle_maximized', _('Toggle maximized'))
k('input_unicode_character', 'kitty_mod+u', 'kitten unicode_input', _('Unicode input'))
k('edit_config_file', 'kitty_mod+f2', 'edit_config_file', _('Edit config file'))
if is_macos:
k('edit_config_file', 'cmd+,', 'edit_config_file', _('Edit config file'), add_to_docs=False)
k('kitty_shell', 'kitty_mod+escape', 'kitty_shell window', _('Open the kitty command shell'), long_text=_('''
Open the kitty shell in a new window/tab/overlay/os_window to control kitty using commands.'''))
k('increase_background_opacity', 'kitty_mod+a>m', 'set_background_opacity +0.1', _('Increase background opacity'))

View file

@ -130,7 +130,7 @@ def set_x11_window_icon() -> None:
def _run_app(opts: OptionsStub, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
global_shortcuts: Dict[str, SingleKey] = {}
if is_macos:
for ac in ('new_os_window', 'close_os_window', 'close_tab'):
for ac in ('new_os_window', 'close_os_window', 'close_tab', 'edit_config_file'):
val = get_macos_shortcut_for(opts, ac)
if val is not None:
global_shortcuts[ac] = val