macOS: Add macOS standard shortcuts
For copy, paste and new OS window (⌘+C, ⌘+V, ⌘+N) Only defined on macOS, not Linux, thanks to the new config infrastructure.
This commit is contained in:
parent
faa5443d43
commit
23d089b4be
@ -50,6 +50,9 @@ Changelog
|
|||||||
- macOS: Keep kitty running even when the last window is closed. This is in
|
- macOS: Keep kitty running even when the last window is closed. This is in
|
||||||
line with how applications are supposed to behave on macOS (:iss:`543`)
|
line with how applications are supposed to behave on macOS (:iss:`543`)
|
||||||
|
|
||||||
|
- macOS: Add macOS standard shortcuts for copy, paste and new OS window
|
||||||
|
(⌘+C, ⌘+V, ⌘+N)
|
||||||
|
|
||||||
- Add a config option (:opt:`editor`) to set the EDITOR kitty uses (:iss:`580`)
|
- Add a config option (:opt:`editor`) to set the EDITOR kitty uses (:iss:`580`)
|
||||||
|
|
||||||
- Add a config option (:opt:`x11_hide_window_decorations`) to hide window
|
- Add a config option (:opt:`x11_hide_window_decorations`) to hide window
|
||||||
|
|||||||
@ -138,7 +138,7 @@ Windows
|
|||||||
Action Shortcut
|
Action Shortcut
|
||||||
======================== =======================
|
======================== =======================
|
||||||
New window :sc:`new_window`
|
New window :sc:`new_window`
|
||||||
New OS window :sc:`new_os_window`
|
New OS window :sc:`new_os_window` (also :kbd:`⌘+n` on macOS)
|
||||||
Close window :sc:`close_window`
|
Close window :sc:`close_window`
|
||||||
Next window :sc:`next_window`
|
Next window :sc:`next_window`
|
||||||
Previous window :sc:`previous_window`
|
Previous window :sc:`previous_window`
|
||||||
@ -156,8 +156,8 @@ Other keyboard shortcuts
|
|||||||
================================== =======================
|
================================== =======================
|
||||||
Action Shortcut
|
Action Shortcut
|
||||||
================================== =======================
|
================================== =======================
|
||||||
Copy to clipboard :sc:`copy_to_clipboard`
|
Copy to clipboard :sc:`copy_to_clipboard` (also :kbd:`⌘+c` on macOS)
|
||||||
Paste from clipboard :sc:`paste_from_clipboard`
|
Paste from clipboard :sc:`paste_from_clipboard` (also :kbd:`⌘+v` on macOS)
|
||||||
Paste from selection :sc:`paste_from_selection`
|
Paste from selection :sc:`paste_from_selection`
|
||||||
Increase font size :sc:`increase_font_size`
|
Increase font size :sc:`increase_font_size`
|
||||||
Decrease font size :sc:`decrease_font_size`
|
Decrease font size :sc:`decrease_font_size`
|
||||||
|
|||||||
@ -10,6 +10,7 @@ from .conf.definition import option_func
|
|||||||
from .conf.utils import (
|
from .conf.utils import (
|
||||||
choices, positive_float, positive_int, to_cmdline, to_color, unit_float
|
choices, positive_float, positive_int, to_cmdline, to_color, unit_float
|
||||||
)
|
)
|
||||||
|
from .constants import is_macos
|
||||||
from .fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
from .fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
||||||
from .layout import all_layouts
|
from .layout import all_layouts
|
||||||
from .rgb import color_as_int, color_as_sharp, color_from_int
|
from .rgb import color_as_int, color_as_sharp, color_from_int
|
||||||
@ -690,6 +691,9 @@ You can have kitty remove all shortcut definition seen up to this point. Useful,
|
|||||||
instance, to remove the default shortcuts.'''))
|
instance, to remove the default shortcuts.'''))
|
||||||
|
|
||||||
g('shortcuts.clipboard') # {{{
|
g('shortcuts.clipboard') # {{{
|
||||||
|
if is_macos:
|
||||||
|
k('copy_to_clipboard', 'cmd+c', 'copy_to_clipboard', _('Copy to clipboard'), add_to_docs=False)
|
||||||
|
k('paste_from_clipboard', 'cmd+v', 'paste_from_clipboard', _('Paste from clipboard'), add_to_docs=False)
|
||||||
k('copy_to_clipboard', 'kitty_mod+c', 'copy_to_clipboard', _('Copy to clipboard'))
|
k('copy_to_clipboard', 'kitty_mod+c', 'copy_to_clipboard', _('Copy to clipboard'))
|
||||||
k('paste_from_clipboard', 'kitty_mod+v', 'paste_from_clipboard', _('Paste from clipboard'))
|
k('paste_from_clipboard', 'kitty_mod+v', 'paste_from_clipboard', _('Paste from clipboard'))
|
||||||
k('paste_from_selection', 'kitty_mod+s', 'paste_from_selection', _('Paste from selection'))
|
k('paste_from_selection', 'kitty_mod+s', 'paste_from_selection', _('Paste from selection'))
|
||||||
@ -741,6 +745,8 @@ working directory of the current window using::
|
|||||||
|
|
||||||
map ctrl+alt+enter new_window_with_cwd
|
map ctrl+alt+enter new_window_with_cwd
|
||||||
'''))
|
'''))
|
||||||
|
if is_macos:
|
||||||
|
k('new_os_window', 'cmd+n', 'new_os_window', _('New OS window'))
|
||||||
k('new_os_window', 'kitty_mod+n', 'new_os_window', _('New OS window'))
|
k('new_os_window', 'kitty_mod+n', 'new_os_window', _('New OS window'))
|
||||||
k('close_window', 'kitty_mod+w', 'close_window', _('Close window'))
|
k('close_window', 'kitty_mod+w', 'close_window', _('Close window'))
|
||||||
k('next_window', 'kitty_mod+]', 'next_window', _('Next window'))
|
k('next_window', 'kitty_mod+]', 'next_window', _('Next window'))
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from .constants import (
|
|||||||
)
|
)
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
create_os_window, free_font_data, glfw_init, glfw_terminate,
|
create_os_window, free_font_data, glfw_init, glfw_terminate,
|
||||||
set_default_window_icon, set_options
|
set_default_window_icon, set_options, GLFW_MOD_SUPER
|
||||||
)
|
)
|
||||||
from .fonts.box_drawing import set_scale
|
from .fonts.box_drawing import set_scale
|
||||||
from .fonts.render import set_font_family
|
from .fonts.render import set_font_family
|
||||||
@ -42,16 +42,29 @@ def init_graphics(debug_keyboard=False):
|
|||||||
return glfw_module
|
return glfw_module
|
||||||
|
|
||||||
|
|
||||||
def _run_app(opts, args):
|
def prefer_cmd_shortcuts(x):
|
||||||
|
return x[0] == GLFW_MOD_SUPER
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_os_window_trigger(opts):
|
||||||
new_os_window_trigger = None
|
new_os_window_trigger = None
|
||||||
if is_macos:
|
if is_macos:
|
||||||
|
new_os_window_shortcuts = []
|
||||||
for k, v in opts.keymap.items():
|
for k, v in opts.keymap.items():
|
||||||
if v.func == 'new_os_window':
|
if v.func == 'new_os_window':
|
||||||
new_os_window_trigger = k
|
new_os_window_shortcuts.append(k)
|
||||||
from .fast_data_types import cocoa_set_new_window_trigger
|
if new_os_window_shortcuts:
|
||||||
if not cocoa_set_new_window_trigger(*new_os_window_trigger):
|
from .fast_data_types import cocoa_set_new_window_trigger
|
||||||
new_os_window_trigger = None
|
new_os_window_shortcuts.sort(key=prefer_cmd_shortcuts, reverse=True)
|
||||||
|
for candidate in new_os_window_shortcuts:
|
||||||
|
if cocoa_set_new_window_trigger(*candidate):
|
||||||
|
new_os_window_trigger = candidate
|
||||||
|
break
|
||||||
|
return new_os_window_trigger
|
||||||
|
|
||||||
|
|
||||||
|
def _run_app(opts, args):
|
||||||
|
new_os_window_trigger = get_new_os_window_trigger(opts)
|
||||||
with cached_values_for(run_app.cached_values_name) as cached_values:
|
with cached_values_for(run_app.cached_values_name) as cached_values:
|
||||||
with startup_notification_handler(extra_callback=run_app.first_window_callback) as pre_show_callback:
|
with startup_notification_handler(extra_callback=run_app.first_window_callback) as pre_show_callback:
|
||||||
window_id = create_os_window(
|
window_id = create_os_window(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user