st terminal: copy on select and right mouse click to paste
Mouse release handling
The routine that turns a mouse event into a paste is brelease()
in x.c
:
void
brelease(XEvent *e)
{
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
mousereport(e);
return;
}
if (e->xbutton.button == Button2)
selpaste(NULL);
else if (e->xbutton.button == Button1)
mousesel(e, 1);
}
If you want the right button to paste, instead of the middle one, simply change Button2
to Button3
then recompile:
if (e->xbutton.button == Button3)
Keyboard shortcut definitions
Keyboard shortcuts are in the shortcuts
array in config.h
. Clipboard-paste is already mapped to Ctrl-Shift-V:
static Shortcut shortcuts[] = {
/* mask keysym function argument */
...
{ TERMMOD, XK_V, clippaste, {.i = 0} },
Ctrl-v already has a special meaning in some shells and editors, so you might not want the terminal to intercept it, and prefer to use the existing shortcut. But if you're really determined to have this new shortcut, you'll have to add/change the line as follows:
{ ControlMask, XK_v, clippaste, {.i = 0} },
Note the XK_v
now has a lowercase "v", because it's without Shift.
Related videos on Youtube
Tuyen Pham
Updated on September 18, 2022Comments
-
Tuyen Pham over 1 year
https://st.suckless.org/patches/clipboard/ makes mousewheel to select and paste but I need copy on select of left mouse and then right mouse click to paste.
and to extend, ctrl-v to paste.
I use xorg, archlinux.
How to achieve this?
-
Tuyen Pham over 5 yearsThanks, but what about copy-on-select?
-
VocalFan over 5 yearsI get copy-on-select without making any changes. Have you applied other patches?
-
Tuyen Pham over 5 yearsYou're right, I missed that one. Work like a charm.
-
Tuyen Pham over 5 years@JiggyNaga: I have another question, should I create new one? But I'll post here first, I try to copy multiple lines of text from firefox and then try to open
vim
in st terminal then pressctrl-v
but it paste the whole into one line, I expect lines are speparated by newline\b
as the original. How to do that with st terminal? -
Tuyen Pham over 5 yearsI mean
\b
-->\n
-
VocalFan over 5 yearsYes, that sounds like a separate question, and the problem may be in Firefox rather than
st
. -
Tuyen Pham over 5 yearsPlease refer new question here: unix.stackexchange.com/q/471643/256195