Merge branch 'hints-kitten-copy-to-buffer' of https://github.com/page-down/kitty
This commit is contained in:
commit
8ad39332c9
@ -65,6 +65,8 @@ Detailed list of changes
|
|||||||
- ssh kitten: Change the syntax of glob patterns slightly to match common usage
|
- ssh kitten: Change the syntax of glob patterns slightly to match common usage
|
||||||
elsewhere. Now the syntax is the same a "extendedglob" in most shells.
|
elsewhere. Now the syntax is the same a "extendedglob" in most shells.
|
||||||
|
|
||||||
|
- hints kitten: Allow copying matches to named buffers (:disc:`6073`)
|
||||||
|
|
||||||
|
|
||||||
0.27.1 [2023-02-07]
|
0.27.1 [2023-02-07]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@ -545,6 +545,9 @@ for the operating system. Various special values are supported:
|
|||||||
:code:`*`
|
:code:`*`
|
||||||
copy the match to the primary selection (on systems that support primary selections)
|
copy the match to the primary selection (on systems that support primary selections)
|
||||||
|
|
||||||
|
:code:`#NAME`
|
||||||
|
copy the match to the specified buffer, e.g. :code:`#a`
|
||||||
|
|
||||||
:code:`default`
|
:code:`default`
|
||||||
run the default open program.
|
run the default open program.
|
||||||
|
|
||||||
@ -746,7 +749,7 @@ def linenum_handle_result(args: List[str], data: Dict[str, Any], target_window_i
|
|||||||
|
|
||||||
if action == 'self':
|
if action == 'self':
|
||||||
if w is not None:
|
if w is not None:
|
||||||
is_copy_action = cmd[0] in ('-', '@', '*')
|
is_copy_action = cmd[0] in ('-', '@', '*') or cmd[0].startswith('#')
|
||||||
if is_copy_action:
|
if is_copy_action:
|
||||||
text = ' '.join(cmd[1:])
|
text = ' '.join(cmd[1:])
|
||||||
if cmd[0] == '-':
|
if cmd[0] == '-':
|
||||||
@ -755,6 +758,8 @@ def linenum_handle_result(args: List[str], data: Dict[str, Any], target_window_i
|
|||||||
set_clipboard_string(text)
|
set_clipboard_string(text)
|
||||||
elif cmd[0] == '*':
|
elif cmd[0] == '*':
|
||||||
set_primary_selection(text)
|
set_primary_selection(text)
|
||||||
|
elif cmd[0].startswith('#'):
|
||||||
|
boss.set_clipboard_buffer(cmd[0].lstrip('#'), text)
|
||||||
else:
|
else:
|
||||||
import shlex
|
import shlex
|
||||||
text = ' '.join(shlex.quote(arg) for arg in cmd)
|
text = ' '.join(shlex.quote(arg) for arg in cmd)
|
||||||
@ -815,6 +820,8 @@ def handle_result(args: List[str], data: Dict[str, Any], target_window_id: int,
|
|||||||
set_clipboard_string(joined_text())
|
set_clipboard_string(joined_text())
|
||||||
elif program == '*':
|
elif program == '*':
|
||||||
set_primary_selection(joined_text())
|
set_primary_selection(joined_text())
|
||||||
|
elif program.startswith('#'):
|
||||||
|
boss.set_clipboard_buffer(program.lstrip('#'), joined_text())
|
||||||
else:
|
else:
|
||||||
from kitty.conf.utils import to_cmdline
|
from kitty.conf.utils import to_cmdline
|
||||||
cwd = data['cwd']
|
cwd = data['cwd']
|
||||||
|
|||||||
@ -1998,6 +1998,16 @@ class Boss:
|
|||||||
return w.has_selection()
|
return w.has_selection()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def set_clipboard_buffer(self, buffer_name: str, text: Optional[str] = None) -> None:
|
||||||
|
if buffer_name:
|
||||||
|
if text is not None:
|
||||||
|
self.clipboard_buffers[buffer_name] = text
|
||||||
|
elif buffer_name in self.clipboard_buffers:
|
||||||
|
del self.clipboard_buffers[buffer_name]
|
||||||
|
|
||||||
|
def get_clipboard_buffer(self, buffer_name: str) -> Optional[str]:
|
||||||
|
return self.clipboard_buffers.get(buffer_name)
|
||||||
|
|
||||||
@ac('cp', '''
|
@ac('cp', '''
|
||||||
Copy the selection from the active window to the specified buffer
|
Copy the selection from the active window to the specified buffer
|
||||||
|
|
||||||
@ -2013,7 +2023,7 @@ class Boss:
|
|||||||
elif buffer_name == 'primary':
|
elif buffer_name == 'primary':
|
||||||
set_primary_selection(text)
|
set_primary_selection(text)
|
||||||
else:
|
else:
|
||||||
self.clipboard_buffers[buffer_name] = text
|
self.set_clipboard_buffer(buffer_name, text)
|
||||||
|
|
||||||
@ac('cp', '''
|
@ac('cp', '''
|
||||||
Paste from the specified buffer to the active window
|
Paste from the specified buffer to the active window
|
||||||
@ -2026,7 +2036,7 @@ class Boss:
|
|||||||
elif buffer_name == 'primary':
|
elif buffer_name == 'primary':
|
||||||
text = get_primary_selection()
|
text = get_primary_selection()
|
||||||
else:
|
else:
|
||||||
text = self.clipboard_buffers.get(buffer_name)
|
text = self.get_clipboard_buffer(buffer_name)
|
||||||
if text:
|
if text:
|
||||||
self.paste_to_active_window(text)
|
self.paste_to_active_window(text)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user