macOS: Make the global menu shortcut to open kitty website configurable
This allows remapping the key combination shift+cmd+/
This commit is contained in:
parent
a5bd1dcb08
commit
e919857dfc
@ -53,6 +53,9 @@ Detailed list of changes
|
|||||||
|
|
||||||
- A new action :ac:`open_url` to open the specified URL (:pull:`5004`)
|
- A new action :ac:`open_url` to open the specified URL (:pull:`5004`)
|
||||||
|
|
||||||
|
- macOS: Make the global menu shortcut to open kitty website configurable (:pull:`5004`)
|
||||||
|
|
||||||
|
|
||||||
0.25.0 [2022-04-11]
|
0.25.0 [2022-04-11]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@ -1041,6 +1041,7 @@ process_cocoa_pending_actions(void) {
|
|||||||
if (cocoa_pending_actions[RELOAD_CONFIG]) { call_boss(load_config_file, NULL); }
|
if (cocoa_pending_actions[RELOAD_CONFIG]) { call_boss(load_config_file, NULL); }
|
||||||
if (cocoa_pending_actions[TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY]) { call_boss(toggle_macos_secure_keyboard_entry, NULL); }
|
if (cocoa_pending_actions[TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY]) { call_boss(toggle_macos_secure_keyboard_entry, NULL); }
|
||||||
if (cocoa_pending_actions[TOGGLE_FULLSCREEN]) { call_boss(toggle_fullscreen, NULL); }
|
if (cocoa_pending_actions[TOGGLE_FULLSCREEN]) { call_boss(toggle_fullscreen, NULL); }
|
||||||
|
if (cocoa_pending_actions[OPEN_KITTY_WEBSITE]) { call_boss(open_url, "s", "https://sw.kovidgoyal.net/kitty/"); }
|
||||||
if (cocoa_pending_actions_data.wd) {
|
if (cocoa_pending_actions_data.wd) {
|
||||||
if (cocoa_pending_actions[NEW_OS_WINDOW_WITH_WD]) { call_boss(new_os_window_with_wd, "sO", cocoa_pending_actions_data.wd, Py_True); }
|
if (cocoa_pending_actions[NEW_OS_WINDOW_WITH_WD]) { call_boss(new_os_window_with_wd, "sO", cocoa_pending_actions_data.wd, Py_True); }
|
||||||
if (cocoa_pending_actions[NEW_TAB_WITH_WD]) { call_boss(new_tab_with_wd, "sO", cocoa_pending_actions_data.wd, Py_True); }
|
if (cocoa_pending_actions[NEW_TAB_WITH_WD]) { call_boss(new_tab_with_wd, "sO", cocoa_pending_actions_data.wd, Py_True); }
|
||||||
|
|||||||
@ -235,11 +235,7 @@ PENDING(clear_terminal_and_scrollback, CLEAR_TERMINAL_AND_SCROLLBACK)
|
|||||||
PENDING(reload_config, RELOAD_CONFIG)
|
PENDING(reload_config, RELOAD_CONFIG)
|
||||||
PENDING(toggle_macos_secure_keyboard_entry, TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY)
|
PENDING(toggle_macos_secure_keyboard_entry, TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY)
|
||||||
PENDING(toggle_fullscreen, TOGGLE_FULLSCREEN)
|
PENDING(toggle_fullscreen, TOGGLE_FULLSCREEN)
|
||||||
|
PENDING(open_kitty_website, OPEN_KITTY_WEBSITE)
|
||||||
- (void)open_kitty_website_url:(id)sender {
|
|
||||||
(void)sender;
|
|
||||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://sw.kovidgoyal.net/kitty/"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)validateMenuItem:(NSMenuItem *)item {
|
- (BOOL)validateMenuItem:(NSMenuItem *)item {
|
||||||
if (item.action == @selector(toggle_macos_secure_keyboard_entry:)) {
|
if (item.action == @selector(toggle_macos_secure_keyboard_entry:)) {
|
||||||
@ -275,7 +271,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
GlobalShortcut new_os_window, close_os_window, close_tab, edit_config_file, reload_config;
|
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, clear_terminal_and_scrollback;
|
GlobalShortcut previous_tab, next_tab, new_tab, new_window, close_window, reset_terminal, clear_terminal_and_scrollback;
|
||||||
GlobalShortcut toggle_macos_secure_keyboard_entry, toggle_fullscreen;
|
GlobalShortcut toggle_macos_secure_keyboard_entry, toggle_fullscreen, open_kitty_website;
|
||||||
} GlobalShortcuts;
|
} GlobalShortcuts;
|
||||||
static GlobalShortcuts global_shortcuts;
|
static GlobalShortcuts global_shortcuts;
|
||||||
|
|
||||||
@ -290,7 +286,7 @@ cocoa_set_global_shortcut(PyObject *self UNUSED, PyObject *args) {
|
|||||||
Q(new_os_window); else Q(close_os_window); else Q(close_tab); else Q(edit_config_file);
|
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_tab); else Q(next_tab); else Q(previous_tab);
|
||||||
else Q(new_window); else Q(close_window); else Q(reset_terminal); else Q(clear_terminal_and_scrollback); else Q(reload_config);
|
else Q(new_window); else Q(close_window); else Q(reset_terminal); else Q(clear_terminal_and_scrollback); else Q(reload_config);
|
||||||
else Q(toggle_macos_secure_keyboard_entry); else Q(toggle_fullscreen);
|
else Q(toggle_macos_secure_keyboard_entry); else Q(toggle_fullscreen); else Q(open_kitty_website);
|
||||||
#undef Q
|
#undef Q
|
||||||
if (gs == NULL) { PyErr_SetString(PyExc_KeyError, "Unknown shortcut name"); return NULL; }
|
if (gs == NULL) { PyErr_SetString(PyExc_KeyError, "Unknown shortcut name"); return NULL; }
|
||||||
int cocoa_mods;
|
int cocoa_mods;
|
||||||
@ -652,10 +648,8 @@ cocoa_create_global_menu(void) {
|
|||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
NSMenu* helpMenu = [[NSMenu alloc] initWithTitle:@"Help"];
|
NSMenu* helpMenu = [[NSMenu alloc] initWithTitle:@"Help"];
|
||||||
[helpMenuItem setSubmenu:helpMenu];
|
[helpMenuItem setSubmenu:helpMenu];
|
||||||
[[helpMenu addItemWithTitle:[NSString stringWithFormat:@"Visit %@ Website", app_name]
|
|
||||||
action:@selector(open_kitty_website_url:)
|
MENU_ITEM(helpMenu, @"Visit kitty Website", open_kitty_website);
|
||||||
keyEquivalent:@"?"]
|
|
||||||
setTarget:global_menu_target];
|
|
||||||
[NSApp setHelpMenu:helpMenu];
|
[NSApp setHelpMenu:helpMenu];
|
||||||
[helpMenu release];
|
[helpMenu release];
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ from .conf.utils import BadLine
|
|||||||
from .config import cached_values_for
|
from .config import cached_values_for
|
||||||
from .constants import (
|
from .constants import (
|
||||||
appname, beam_cursor_data_file, config_dir, glfw_path, is_macos,
|
appname, beam_cursor_data_file, config_dir, glfw_path, is_macos,
|
||||||
is_wayland, kitty_exe, logo_png_file, running_in_kitty
|
is_wayland, kitty_exe, logo_png_file, running_in_kitty, website_url
|
||||||
)
|
)
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
GLFW_IBEAM_CURSOR, GLFW_MOD_ALT, GLFW_MOD_SHIFT, create_os_window,
|
GLFW_IBEAM_CURSOR, GLFW_MOD_ALT, GLFW_MOD_SHIFT, create_os_window,
|
||||||
@ -163,6 +163,9 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ())
|
|||||||
val = get_macos_shortcut_for(func_map, 'load_config_file', lookup_name='reload_config')
|
val = get_macos_shortcut_for(func_map, 'load_config_file', lookup_name='reload_config')
|
||||||
if val is not None:
|
if val is not None:
|
||||||
global_shortcuts['reload_config'] = val
|
global_shortcuts['reload_config'] = val
|
||||||
|
val = get_macos_shortcut_for(func_map, f'open_url {website_url()}', lookup_name='open_kitty_website')
|
||||||
|
if val is not None:
|
||||||
|
global_shortcuts['open_kitty_website'] = val
|
||||||
if is_macos and opts.macos_custom_beam_cursor:
|
if is_macos and opts.macos_custom_beam_cursor:
|
||||||
set_custom_ibeam_cursor()
|
set_custom_ibeam_cursor()
|
||||||
if not is_wayland() and not is_macos: # no window icons on wayland
|
if not is_wayland() and not is_macos: # no window icons on wayland
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import string
|
import string
|
||||||
from kitty.conf.types import Action, Definition
|
from kitty.conf.types import Action, Definition
|
||||||
|
from kitty.constants import website_url
|
||||||
|
|
||||||
|
|
||||||
definition = Definition(
|
definition = Definition(
|
||||||
@ -3786,5 +3787,10 @@ Some more examples::
|
|||||||
map ctrl+alt+a send_text normal,application some command with arguments\\r
|
map ctrl+alt+a send_text normal,application some command with arguments\\r
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
map('Open kitty Website',
|
||||||
|
f'open_kitty_website shift+cmd+/ open_url {website_url()}',
|
||||||
|
only='macos',
|
||||||
|
)
|
||||||
egr() # }}}
|
egr() # }}}
|
||||||
egr() # }}}
|
egr() # }}}
|
||||||
|
|||||||
1
kitty/options/types.py
generated
1
kitty/options/types.py
generated
@ -922,6 +922,7 @@ if is_macos:
|
|||||||
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=8, key=107), definition='clear_terminal to_cursor active')) # noqa
|
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=8, key=107), definition='clear_terminal to_cursor active')) # noqa
|
||||||
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=12, key=44), definition='load_config_file')) # noqa
|
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=12, key=44), definition='load_config_file')) # noqa
|
||||||
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=10, key=44), definition='debug_config')) # noqa
|
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=10, key=44), definition='debug_config')) # noqa
|
||||||
|
defaults.map.append(KeyDefinition(trigger=SingleKey(mods=9, key=47), definition='open_url https://sw.kovidgoyal.net/kitty/')) # noqa
|
||||||
defaults.mouse_map = [
|
defaults.mouse_map = [
|
||||||
# click_url_or_select
|
# click_url_or_select
|
||||||
MouseMapping(repeat_count=-2, definition='mouse_handle_click selection link prompt'), # noqa
|
MouseMapping(repeat_count=-2, definition='mouse_handle_click selection link prompt'), # noqa
|
||||||
|
|||||||
@ -309,6 +309,7 @@ typedef enum {
|
|||||||
RELOAD_CONFIG,
|
RELOAD_CONFIG,
|
||||||
TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY,
|
TOGGLE_MACOS_SECURE_KEYBOARD_ENTRY,
|
||||||
TOGGLE_FULLSCREEN,
|
TOGGLE_FULLSCREEN,
|
||||||
|
OPEN_KITTY_WEBSITE,
|
||||||
|
|
||||||
NUM_COCOA_PENDING_ACTIONS
|
NUM_COCOA_PENDING_ACTIONS
|
||||||
} CocoaPendingAction;
|
} CocoaPendingAction;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user