macOS: Add reload config to kitty global menu

This commit is contained in:
Kovid Goyal 2021-06-13 20:34:27 +05:30
parent c7b91e5f19
commit ebff343a55
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 9 additions and 2 deletions

View File

@ -1009,6 +1009,7 @@ process_global_state(void *data) {
if (cocoa_pending_actions & NEW_WINDOW) { call_boss(new_window, NULL); }
if (cocoa_pending_actions & CLOSE_WINDOW) { call_boss(close_window, NULL); }
if (cocoa_pending_actions & RESET_TERMINAL) { call_boss(clear_terminal, "sO", "reset", Py_True ); }
if (cocoa_pending_actions & RELOAD_CONFIG) { call_boss(load_config_file, NULL); }
if (cocoa_pending_actions_data.wd) {
if (cocoa_pending_actions & NEW_OS_WINDOW_WITH_WD) { call_boss(new_os_window_with_wd, "s", cocoa_pending_actions_data.wd); }
if (cocoa_pending_actions & NEW_TAB_WITH_WD) { call_boss(new_tab_with_wd, "s", cocoa_pending_actions_data.wd); }

View File

@ -91,6 +91,7 @@ PENDING(previous_tab, PREVIOUS_TAB)
PENDING(new_window, NEW_WINDOW)
PENDING(close_window, CLOSE_WINDOW)
PENDING(reset_terminal, RESET_TERMINAL)
PENDING(reload_config, RELOAD_CONFIG)
- (void)open_kitty_website_url:(id)sender {
(void)sender;
@ -117,7 +118,7 @@ typedef struct {
NSEventModifierFlags mods;
} GlobalShortcut;
typedef struct {
GlobalShortcut new_os_window, close_os_window, close_tab, edit_config_file;
GlobalShortcut new_os_window, close_os_window, close_tab, edit_config_file, reload_config;
GlobalShortcut previous_tab, next_tab, new_tab, new_window, close_window, reset_terminal;
} GlobalShortcuts;
static GlobalShortcuts global_shortcuts;
@ -132,7 +133,7 @@ cocoa_set_global_shortcut(PyObject *self UNUSED, PyObject *args) {
#define Q(x) if (strcmp(name, #x) == 0) gs = &global_shortcuts.x
Q(new_os_window); else Q(close_os_window); else Q(close_tab); else Q(edit_config_file);
else Q(new_tab); else Q(next_tab); else Q(previous_tab);
else Q(new_window); else Q(close_window); else Q(reset_terminal);
else Q(new_window); else Q(close_window); else Q(reset_terminal); else Q(reload_config);
#undef Q
if (gs == NULL) { PyErr_SetString(PyExc_KeyError, "Unknown shortcut name"); return NULL; }
int cocoa_mods;
@ -380,6 +381,7 @@ cocoa_create_global_menu(void) {
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
MENU_ITEM(appMenu, @"Preferences…", edit_config_file);
MENU_ITEM(appMenu, @"Reload preferences", reload_config);
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", app_name]
action:@selector(hide:)

View File

@ -143,6 +143,9 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ())
val = get_macos_shortcut_for(opts, 'clear_terminal', args=('reset', True), lookup_name='reset_terminal')
if val is not None:
global_shortcuts['reset_terminal'] = val
val = get_macos_shortcut_for(opts, 'load_config_file', args=(), lookup_name='reload_config')
if val is not None:
global_shortcuts['reload_config'] = val
if is_macos and opts.macos_custom_beam_cursor:
set_custom_ibeam_cursor()
if not is_wayland() and not is_macos: # no window icons on wayland

View File

@ -278,6 +278,7 @@ typedef enum {
NEW_WINDOW = 2048,
CLOSE_WINDOW = 4096,
RESET_TERMINAL = 8192,
RELOAD_CONFIG = 16384,
} CocoaPendingAction;
void set_cocoa_pending_action(CocoaPendingAction action, const char*);
#endif