repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 91cc921f88027032ea9dbf01896fa54b73cb2740: path_to: revision_to:
commit 91cc921f88027032ea9dbf01896fa54b73cb2740 Author: Emanuele GiaquintaDate: Sat Apr 26 14:07:36 2014 +0000 Add bindings to interact with the CLIPBOARD selection. diff --git a/Changes b/Changes
--- a/Changes
+++ b/Changes
@@ -42,6 +42,8 @@ TODO IMPL: recalc bg always on bg colour change
and holding the scrollbar up or down button, gentoo bug #493992.
- increase the maximum length of a command sequence to 32k bytes,
to allow longer OSC sequences (previous limit was 2k).
+ - new Ctrl-Meta-c and Ctrl-Meta-v bindings to interact with
+ the CLIPBOARD selection.
- new extension: selection-to-clipboard.
9.19 Sun Oct 27 17:16:07 CET 2013
diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod
--- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -1378,6 +1378,12 @@ B modifier) to be inserted as if it had been typed on the keyboard. Pressing Bcauses the value of the PRIMARY selection to be inserted too. +rxvt-unicode also provides the bindings B and + to interact with the CLIPBOARD selection. The first +binding causes the value of the internal selection to be copied to the +CLIPBOARD selection, while the second binding causes the value of the +CLIPBOARD selection to be inserted. + =back =head1 CHANGING FONTS diff --git a/src/command.C b/src/command.C
--- a/src/command.C
+++ b/src/command.C
@@ -402,6 +402,15 @@ map_function_key (KeySym keysym)
return param;
}
+static inline wchar_t *
+rxvt_wcsdup (const wchar_t *str, int len)
+{
+ wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t));
+ memcpy (r, str, len * sizeof (wchar_t));
+ r[len] = 0;
+ return r;
+}
+
void ecb_cold
rxvt_term::key_press (XKeyEvent &ev)
{
@@ -580,6 +589,21 @@ rxvt_term::key_press (XKeyEvent &ev)
}
}
+ if (ctrl && meta && (keysym == XK_c || keysym == XK_v))
+ {
+ if (keysym == XK_v)
+ selection_request (ev.time, Sel_Clipboard);
+ else if (selection.len > 0)
+ {
+ free (selection.clip_text);
+ selection.clip_text = rxvt_wcsdup (selection.text, selection.len);
+ selection.clip_len = selection.len;
+ selection_grab (CurrentTime, true);
+ }
+
+ return;
+ }
+
#if ENABLE_FRILLS || ISO_14755
// ISO 14755 support
if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51))
-----END OF PAGE-----