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

Simulate the X11 select buffer #6250

Open
davidchisnall opened this issue May 29, 2020 · 5 comments
Open

Simulate the X11 select buffer #6250

davidchisnall opened this issue May 29, 2020 · 5 comments
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@davidchisnall
Copy link

X11 provides multiple buffers (clipboards / pasteboards) with different semantics. The copy buffer is used for things that persist in the buffer. The select buffer shares some of the behaviour of copy-and-paste and some of drag-and-drop. Like drag-and-drop, the source is responsible for the storage of the buffer contents and the buffer goes away when the source changes this. Like copy-and-paste, copying (select) and pasting (middle click) are distinct operations that do not capture the mouse in the middle.

It is very useful to have access to both in a terminal. This works well in X11 terminals on Windows with VcXsrv:

  • The select buffer (filled when you select text) is not copied to the Windows clipboard.
  • The copy buffer (filled when you do a copy operation) is copied to the Windows clipboard.
  • Changes to the Windows clipboard are mirrored into the X11 copy buffer.
  • Middle click pastes from the select buffer if the select buffer contains anything, otherwise it pastes from the copy buffer.

This behaviour could be emulated by having a buffer that is internal to WT that is filled on select and used for a special paste option (which could be bound to middle-click once #1553 is resolved).

@davidchisnall davidchisnall added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 29, 2020
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 29, 2020
@DHowett
Copy link
Member

DHowett commented Jun 2, 2020

You know, I don't hate this idea. I'm worried, though, that it'll have to be opt-in for people who understand it (opt-in because Windows users may not immediately take to the idea, and will shout us down for having this "weird copy that doesn't go to the clipboard") and that uptake will therefore be relatively low...

@davidchisnall
Copy link
Author

I honk it would have to be an explicitly named option with something like X11SelectBufferCopy so that only people who like and want that behaviour will see it. Even on X11, people initially find it confusing, but once you’re used to it, it’s very useful.

@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 3, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 3, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jun 3, 2020
@TrentonAdams
Copy link

Another feature of this in Linux is that you can press ctrl-shift-v to paste the normal clipboard buffer, and ctrl-shift-c to copy to the normal clipboard buffer.

I feel these features are essential, if you're adopting a Linux system in Windows it should feel the same.

@chenzhiwei
Copy link

More details on PRIMARY and CLIPBOARD: https://specifications.freedesktop.org/clipboards-spec/clipboards-latest.txt

Application authors should follow the following guidelines to get
correct behavior:

  • selecting but with no explicit copy should only set PRIMARY,
    never CLIPBOARD

  • middle mouse button should paste PRIMARY, never CLIPBOARD

  • explicit cut/copy commands (i.e. menu items, toolbar buttons)
    should always set CLIPBOARD to the currently-selected data (i.e.
    conceptually copy PRIMARY to CLIPBOARD)

  • explicit cut/copy commands should always set both CLIPBOARD and
    PRIMARY, even when copying doesn't involve a selection (e.g. a
    "copy url" -option which explicitly copies an url without the
    url being selected first)

  • explicit paste commands should paste CLIPBOARD, not PRIMARY

  • a selection becoming unselected should never unset PRIMARY

  • possibly contradicting the ICCCM, clients don't need to support
    SECONDARY, though if anyone can figure out what it's good
    for they should feel free to use it for that

  • cut buffers are evil; they only support ASCII, they don't
    work with many clients, and they require data to be
    copied to the X server. Therefore clients should avoid
    using cut buffers and use only selections.

https://unix.stackexchange.com/a/178401

The only exception is gnome-terminal. After long debates, the devs have decided (for consistency with other terminals) that, in gnome-terminal, Shift+Insert should paste from PRIMARY and Ctrl+Shift+V should paste from CLIPBOARD (although you have the options to customize some shortcuts).

@lindhe
Copy link

lindhe commented Jul 13, 2022

Seems similar to #1553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

6 participants