A new option to clear selections when they no longer reflect the contents of the clipboard

This commit is contained in:
Kovid Goyal
2025-03-12 11:41:27 +05:30
parent b34a88065b
commit 96d5c9c7c6
7 changed files with 37 additions and 1 deletions

View File

@@ -603,6 +603,17 @@ clipboard.
'''
)
opt('clear_selection_on_clipboard_loss', 'no', option_type='to_bool', long_text='''
When the contents of the clipboard no longer reflect the current selection, clear it.
This is primarily useful on platforms such as Linux where selecting text automatically
copies it to a special "primary selection" clipboard or if you have :opt:`copy_on_select`
set to :code:`clipboard`.
Note that on macOS the system does not provide notifications when the clipboard owner
is changed, so there, copying to clipboard in a non-kitty application will not clear
selections even if :opt:`copy_on_select` is enabled.
''')
opt('paste_actions', 'quote-urls-at-prompt,confirm',
option_type='paste_actions',
long_text='''

View File

@@ -119,6 +119,9 @@ class Parser:
def clear_all_shortcuts(self, val: str, ans: dict[str, typing.Any]) -> None:
clear_all_shortcuts(val, ans)
def clear_selection_on_clipboard_loss(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['clear_selection_on_clipboard_loss'] = to_bool(val)
def click_interval(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['click_interval'] = float(val)

View File

@@ -63,6 +63,7 @@ option_names = (
'box_drawing_scale',
'clear_all_mouse_actions',
'clear_all_shortcuts',
'clear_selection_on_clipboard_loss',
'click_interval',
'clipboard_control',
'clipboard_max_size',
@@ -500,6 +501,7 @@ class Options:
box_drawing_scale: tuple[float, float, float, float] = (0.001, 1.0, 1.5, 2.0)
clear_all_mouse_actions: bool = False
clear_all_shortcuts: bool = False
clear_selection_on_clipboard_loss: bool = False
click_interval: float = -1.0
clipboard_control: tuple[str, ...] = ('write-clipboard', 'write-primary', 'read-clipboard-ask', 'read-primary-ask')
clipboard_max_size: float = 512.0