From 81b5d2c4f27bbd158cbd5736d0dc8dcae93978d6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 12 Jan 2018 07:33:21 +0530 Subject: [PATCH] Option to copy to clipboard on mouse select --- CHANGELOG.rst | 2 ++ kitty/boss.py | 7 +++++-- kitty/config.py | 1 + kitty/kitty.conf | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4fae592fd..71b6e5b20 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ version 0.7.0 [future] - Sessions: Allow setting titles and working directories for individual windows +- Option to copy to clipboard on mouse select + - Fix incorrect reporting of mouse move events when using the SGR protocol - Make alt+backspace delete the previous word diff --git a/kitty/boss.py b/kitty/boss.py index d891a8d3a..2f65fae68 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -12,8 +12,9 @@ from .constants import appname, set_boss, wakeup from .fast_data_types import ( ChildMonitor, create_os_window, current_os_window, destroy_global_data, destroy_sprite_map, get_clipboard_string, glfw_post_empty_event, - layout_sprite_map, mark_os_window_for_close, set_dpi_from_os_window, - show_window, toggle_fullscreen, viewport_for_window + layout_sprite_map, mark_os_window_for_close, set_clipboard_string, + set_dpi_from_os_window, show_window, toggle_fullscreen, + viewport_for_window ) from .fonts.render import prerender, resize_fonts, set_font_family from .keys import get_shortcut @@ -415,6 +416,8 @@ class Boss: text = w.text_for_selection() if text: set_primary_selection(text) + if self.opts.copy_on_select: + set_clipboard_string(text) def goto_tab(self, tab_num): tm = self.active_tab_manager diff --git a/kitty/config.py b/kitty/config.py index d5d98175d..01d68ae93 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -281,6 +281,7 @@ type_map = { 'inactive_text_alpha': unit_float, 'url_style': url_style, 'prefer_color_emoji': to_bool, + 'copy_on_select': to_bool, } for name in ( diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 4a8ba7320..a0546f999 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -369,6 +369,13 @@ map ctrl+shift+f11 toggle_fullscreen # OS specific tweaks +# Copy to clipboard on select. With this enabled, simply selecting text with +# the mouse will cause the text to be copied to clipboard. Useful on platforms +# such as macOS/Wayland that do not have the concept of primary selections. Note +# that this is a security risk, as all programs, including websites open in your +# browser can read the contents of the clipboard. +copy_on_select no + # Hide the kitty window's title bar on macOS. macos_hide_titlebar no