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

Use both primary and system clipboards #2394

Open
amokfa opened this issue Apr 22, 2023 · 9 comments
Open

Use both primary and system clipboards #2394

amokfa opened this issue Apr 22, 2023 · 9 comments

Comments

@amokfa
Copy link

amokfa commented Apr 22, 2023

Clipboard behavior in zellij is completely different from the rest of linux applications:

  1. Selecting text using mouse
    This is supposed to copy text to the primary selection, which can then be pasted using middle mouse button. If I select some text in zellij using my mouse, I'm unable to paste it to either zellij, or other text fields using middle mouse. By comparison, I can select text using mouse and paste it to transfer it between chrome and any terminal emulator.

  2. Pasting text using middle mouse
    I can select some text using mouse and paste it into both chrome and terminal emulators using middle mouse, but pressing the middle mouse in zellij does nothing.

I can disable copy on select, and set a copy keybinding to get half of the desired behavior. But I see no way of using both primary selection even with this setup.

@amokfa
Copy link
Author

amokfa commented Apr 23, 2023

  1. In every other terminal I can select a word using double click, and a line with a triple click. In zellij, they don't do anything.

@amokfa
Copy link
Author

amokfa commented Apr 27, 2023

@imsnif @jaeheonji I can work on this issue. Here's what I have in mind:

  1. We remove copy_on_select and copy_clipboard options.
  2. Whenever the user makes a selection using the mouse, we copy the selection content to the primary selection.
  3. With content selected, pressing the copy keybinding will copy the contents to the system clipboard.
  4. Middle click will paste the contents of primary selection.
  5. Optionally we could remove the copy_command option as well and copy to the correct system clipboard based on environment. Need to test if it will work in wayland/xwayland setups.

This will make zellij behave like every other linux application I'm aware of as far as clipboard is concerned. Let me know how that sounds.

@tlinford
Copy link
Contributor

Hey @amokfa, I like your proposal, and agree with most things. Also, thanks for volunteering to pick this up, I can try and help you out with this :)

Just for a bit of background, the current default behavior (copy_on_select on) was implemented purposefully to match what tmux does by default I guess (#448 (comment)).

That said here is my take on your plan:

  1. keep the copy_on_select option, when it is enabled keep current behavior (maybe we could copy selection to both primary and system). when off, adopt the new more "standard" approach.
  2. depends on copy_on_select option
  3. same
  4. This is where things get tricky. Unfortunately as a terminal application, there isn't a great way to interact with the system clipboard. A couple of possibilities are:
    • use osc52, but support for reading from the clipboard is limited to only Alacritty AFAIK, because it's considered unsecure.
    • on middle click, paste the contents of the current zellij selection. This is ok, but misses the case of wanting to paste from outside of zellij
    • something similar to copy_command to allow the user to configure the right thing
  5. This can also be problematic, considering that zellij needs to be able to run on servers with no x/wayland, and also mac and win (someday). More context on this in the original mouse support pr: Initial mouse support #448 (comment). But it might be worth figuring out if this is doable in a way that matches these requirements. The way helix handles this seems very smart and might be useful as a reference: https://github.com/helix-editor/helix/blob/8a3ec443f176218384db8c8610bbada9c43a6ea5/helix-view/src/clipboard.rs

Let me know what you think.

cc @imsnif please feel tree to add anything/correct me if I got something wrong here :)

@imsnif
Copy link
Member

imsnif commented Apr 28, 2023

I have not gone into the weeds of this proposal, as I trust @tlinford 's judgement - the only thing I want to stress is that removing existing configuration parameters is a breaking change and that we should really try to avoid it. And also: I'm happy to change the bahavior of Zellij here if you think it's good, but there will always be users who will not like the new behavior and want things to be as they were before. For them we should provide an escape hatch, likely in the form of a new configuration attribute that will allow them to restore the previous behavior.

@ahberg
Copy link

ahberg commented Apr 28, 2023

1 It is possible to use mouse copy/paste if you hold on shift . (it disable mouse mode and isn't optimal ).
2 Bindings "Alt c" should be enabled when copy_on_select=false.

// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }

@grm34
Copy link

grm34 commented May 8, 2023

I use this workaround to get paste working on CTRL+SHIFT+V

copy_command "wl-copy -p"

@popey
Copy link

popey commented Mar 16, 2024

Zellij is lovely (I only just discovered it myself)! Would someone be willing to revisit this issue? It's a shame that on Linux we have inconsistent copy/paste behaviour between the primary terminal and other applications.

@wiraki
Copy link

wiraki commented Jun 1, 2024

Hello, I also just arrived here because I noticed that double-clicking on text in the scroll buffer did not select it. I had not realized but I am quite used to it being the case that this is now bothering me.

Is there any hope this issue is re-visited? :)

@dimyself
Copy link

dimyself commented Jun 18, 2024

1 It is possible to use mouse copy/paste if you hold on shift . (it disable mouse mode and isn't optimal ). 2 Bindings "Alt c" should be enabled when copy_on_select=false.

// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }

I'm new to Zellij

I'm using dropdown xfce-terminal

I can get copy text working by holding +, then to paste

But I would like a way to remove and just copy using double / triple mouse click for copy and middle mouse click for paste.

I assume that is what this open issue is about if I'm reading it right?

Or, is there a setting / option / config I can change to remove the key as necessary for copying?

Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants