0

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?

2

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.

7
  • Thanks, but what about copy-on-select? – Tuyen Pham Sep 26 '18 at 13:46
  • I get copy-on-select without making any changes. Have you applied other patches? – JigglyNaga Sep 26 '18 at 13:51
  • You're right, I missed that one. Work like a charm. – Tuyen Pham Sep 26 '18 at 13:59
  • @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 press ctrl-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 Sep 26 '18 at 16:18
  • I mean \b --> \n – Tuyen Pham Sep 26 '18 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.