diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2021-06-26 09:48:31 +0200 |
---|---|---|
committer | Sören Tempel <soeren+git@soeren-tempel.net> | 2021-06-26 09:48:31 +0200 |
commit | a182cda98ba3c840638dce7e1d51825455d7f5b9 (patch) | |
tree | 8fa6508869b03611274c81cf373c9d882fce66a2 | |
parent | 715f322bcd79a47cf113bdf812cba90e6051a3d9 (diff) |
Add Shift-Insert keybinding to paste primary clipboard
This is basically yet another workaround for a bug in Gtk since Gtk pastes the secondary clipboard by default. However, since every terminal emulator I have used in the past pastes the primary clipboard on Shift-Insert saneterm should too.
-rw-r--r-- | TODO.txt | 1 | ||||
-rw-r--r-- | saneterm/keys.py | 1 | ||||
-rw-r--r-- | saneterm/termview.py | 8 |
3 files changed, 9 insertions, 1 deletions
diff --git a/TODO.txt b/TODO.txt index 773ba9d..6b5aeb6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -21,7 +21,6 @@ * ssh forces echo (see previous entry) * Make sure no input is lost in-between output points * For example, when text is typed before the prompt is redrawn -* <shift>Insert key binding (should paste primary) * When text is entered before output point, cursor_at_end doesn't work * Configure vertical scrollbar (and other stuff that may come up) via Gtk properties? * Allows changing this setting via dconf-editor / gsettings diff --git a/saneterm/keys.py b/saneterm/keys.py index 44bfd9a..02eaa9d 100644 --- a/saneterm/keys.py +++ b/saneterm/keys.py @@ -31,6 +31,7 @@ class Bindings(): bind "Down" { "history-entry" (-1) }; bind "Tab" { "tab-completion" () }; + bind "<shift>Insert" { "paste-primary" () }; /* Since <ctrl>c is used for VINTR, unbind <ctrl>v */ unbind "<ctrl>v"; diff --git a/saneterm/termview.py b/saneterm/termview.py index 5835abd..c697fae 100644 --- a/saneterm/termview.py +++ b/saneterm/termview.py @@ -87,6 +87,7 @@ class TermView(Gtk.TextView): self._textbuffer.connect("end-user-action", self.__end_user_action) self.set_buffer(self._textbuffer) + self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) self._tabcomp = completion.TabComp(self._textbuffer, compfunc) self.set_monospace(True) @@ -102,6 +103,7 @@ class TermView(Gtk.TextView): "move-input-end": self.__move_input_end, "clear-view": self.__clear_view, "tab-completion": self.__tabcomp, + "paste-primary": self.__paste_primary, } for name, func in signals.items(): @@ -238,3 +240,9 @@ class TermView(Gtk.TextView): cur.assign(out) self._tabcomp.next(cur) + + # See https://gitlab.gnome.org/GNOME/gtk/-/issues/352 + def __paste_primary(self, textview): + buf = textview.get_buffer() + buf.paste_clipboard(self._clipboard, None, + textview.props.editable) |