Support for an arbitrary number of internal clipboard buffers to copy/paste from
This commit is contained in:
parent
6507fd1ac2
commit
cb2d162bec
@ -7,10 +7,13 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
0.14.0 [future]
|
||||
---------------------
|
||||
|
||||
- macOS: The default behavior of the Option key has changed, to generating
|
||||
- macOS: The default behavior of the Option key has changed. It now generates
|
||||
unicode characters rather than acting as the Alt modifier. See
|
||||
:opt:`macos_option_as_alt`.
|
||||
|
||||
- Support for an arbitrary number of internal clipboard buffers to copy/paste
|
||||
from, see (:ref:`cpbuf`)
|
||||
|
||||
- macOS: Allow opening new kitty tabs/top-level windows from Finder
|
||||
(:pull:`1350`)
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ kitty - the fast, featureful, GPU based terminal emulator
|
||||
separate window using arbitrary programs of your choice. This is useful for
|
||||
browsing the history comfortably in a pager or editor.
|
||||
|
||||
* Has :ref:`multiple copy/paste buffers <cpbuf>`, like vim.
|
||||
|
||||
|
||||
.. figure:: screenshots/screenshot.png
|
||||
:alt: Screenshot, showing three programs in the 'Tall' layout
|
||||
@ -394,6 +396,23 @@ If you wish to store very large amounts of scrollback to view using the piping o
|
||||
:sc:`show_scrollback` features, you can use the :opt:`scrollback_pager_history_size`
|
||||
option.
|
||||
|
||||
.. _cpbuf:
|
||||
|
||||
Multiple copy/paste buffers
|
||||
-----------------------------
|
||||
|
||||
In addition to being able to copy/paste from the system clipboard, in |kitty| you
|
||||
can also setup an arbitrary number of copy paste buffers. To do so, simply add
|
||||
something like the following to your :file:`kitty.conf`::
|
||||
|
||||
map f1 copy_to_buffer a
|
||||
map f2 paste_from_buffer a
|
||||
|
||||
This will allow you to press :kbd:`F1` to copy the current selection to an
|
||||
internal buffer named ``a`` and :kbd:`F2` to paste from that buffer. The buffer
|
||||
names are arbitrary strings, so you can define as many such buffers as you
|
||||
need.
|
||||
|
||||
Frequently Asked Questions
|
||||
---------------------------------
|
||||
|
||||
|
||||
@ -106,6 +106,7 @@ class Boss:
|
||||
|
||||
def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigger):
|
||||
set_draw_minimal_borders(opts)
|
||||
self.clipboard_buffers = {}
|
||||
self.update_check_process = None
|
||||
self.window_id_map = WeakValueDictionary()
|
||||
self.startup_colors = {k: opts[k] for k in opts if isinstance(opts[k], Color)}
|
||||
@ -814,6 +815,28 @@ class Boss:
|
||||
if self.opts.copy_on_select:
|
||||
set_clipboard_string(text)
|
||||
|
||||
def copy_to_buffer(self, buffer_name):
|
||||
w = self.active_window
|
||||
if w is not None and not w.destroyed:
|
||||
text = w.text_for_selection()
|
||||
if text:
|
||||
if buffer_name == 'clipboard':
|
||||
set_clipboard_string(text)
|
||||
elif buffer_name == 'primary':
|
||||
set_primary_selection(text)
|
||||
else:
|
||||
self.clipboard_buffers[buffer_name] = text
|
||||
|
||||
def paste_from_buffer(self, buffer_name):
|
||||
if buffer_name == 'clipboard':
|
||||
text = get_clipboard_string()
|
||||
elif buffer_name == 'primary':
|
||||
text = get_primary_selection()
|
||||
else:
|
||||
text = self.clipboard_buffers.get(buffer_name)
|
||||
if text:
|
||||
self.paste_to_active_window(text)
|
||||
|
||||
def goto_tab(self, tab_num):
|
||||
tm = self.active_tab_manager
|
||||
if tm is not None:
|
||||
|
||||
@ -140,6 +140,16 @@ def clear_terminal(func, rest):
|
||||
return func, args
|
||||
|
||||
|
||||
@func_with_args('copy_to_buffer')
|
||||
def copy_to_buffer(func, rest):
|
||||
return func, [rest]
|
||||
|
||||
|
||||
@func_with_args('paste_from_buffer')
|
||||
def paste_from_buffer(func, rest):
|
||||
return func, [rest]
|
||||
|
||||
|
||||
@func_with_args('neighboring_window')
|
||||
def neighboring_window(func, rest):
|
||||
rest = rest.lower()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user