Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middle click paste and primary clipboard #532

Closed
dsseng opened this issue Jul 30, 2021 · 8 comments · Fixed by #548
Closed

Middle click paste and primary clipboard #532

dsseng opened this issue Jul 30, 2021 · 8 comments · Fixed by #548
Labels
C-enhancement Category: Improvements

Comments

@dsseng
Copy link
Contributor

dsseng commented Jul 30, 2021

Describe your feature request

Copy-on-select + middle click paste is a quite common feature on Linux, browsers and toolkits like GTK implement it. This is pretty convenient to use, should work great with mouse selection as well. It should be available as an option on any system with no-op backend (copy-paste inside the editor), but can be backed by supporting clipboard provider implementation.

This is supported at least by wl-copy/wl-paste with -p on Wayland. xsel should also be able to do this when run without -b. New options will be added to Helix's clipboard support to work with primary selection as well. Also if no provider is available with primary selection capabilities, those functions will work, backed by in-memory string without system integration, so it will only be available inside the Helix editor.

I can work on adding this feature after it is considered good to go.

@dsseng dsseng added the C-enhancement Category: Improvements label Jul 30, 2021
@cessen
Copy link
Contributor

cessen commented Aug 4, 2021

Can't speak for @archseer, but I'm fine with it as long as it can be disabled in config. I personally find both behaviors really annoying, and really wish I could disable them in all of my Linux applications (especially terminal emulators...). But I understand why some people like it, and it matches the behavior of many terminal emulators, so it seems worth supporting as an option.

@archseer
Copy link
Member

archseer commented Aug 4, 2021

I think this used to work before #509 which enabled mouse events. The terminal automatically handled it, but it looks like we might need to do it manually now.

@dsseng
Copy link
Contributor Author

dsseng commented Aug 4, 2021

Exactly. There were some problems though as terminal simply types on the keyboard and so closing brackets were often duplicated.

@archseer
Copy link
Member

archseer commented Aug 4, 2021

Oh, I'm specifically talking about copy on select. The clipboard is already supported via space+y/p/R etc.

Pasting via ctrl+v/middle click needs to use the bracketed paste mode which isn't supported yet in crossterm (crossterm-rs/crossterm#557), but it's supported in termwiz which I've been evaluating as a possible replacement.

@dsseng
Copy link
Contributor Author

dsseng commented Aug 4, 2021

Copy on select is done to the primary selection, not the clipboard. The feature is for convenience of some users (like me e.g.) who like having 2 copy-paste buffers.

Why is that a requirement, can't we just run our typical functions as with space+p?

@archseer
Copy link
Member

archseer commented Aug 4, 2021

Typically, when we paste code snippet into a terminal application, it can not tell whether we are typing the text or we are pasting it. This may have unintended side affects for some application. For example, Vim will auto-indent the code pasted into it when it sees a newline, breaking the code structure.

https://jdhao.github.io/2021/02/01/bracketed_paste_mode/

@archseer
Copy link
Member

archseer commented Aug 4, 2021

Copy on select is done to the primary selection

Yeah, so this worked for me and copied to the middle click clipboard when mouse events were off because dragging with the mouse made a real terminal selection. We're handling events manually now so this also has to be implemented inside helix now.

@dsseng
Copy link
Contributor Author

dsseng commented Aug 4, 2021

Typically, when we paste code snippet into a terminal application, it can not tell whether we are typing the text or we are pasting it. This may have unintended side affects for some application. For example, Vim will auto-indent the code pasted into it when it sees a newline, breaking the code structure.

https://jdhao.github.io/2021/02/01/bracketed_paste_mode/

This seems to be required when mouse events are disabled and terminal 'types' for us. Middle click paste built into Helix should work fine by executing internal commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants