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
3 changed files with 6 additions and 3 deletions

View File

@@ -121,7 +121,7 @@ typedef struct {
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 @@ cocoa_set_global_shortcut(PyObject *self UNUSED, PyObject *args) {
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 @@ cocoa_create_global_menu(void) {
[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 @@ k('toggle_fullscreen', 'kitty_mod+f11', 'toggle_fullscreen', _('Toggle fullscree
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