microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.23k stars 8.27k forks source link

Simulate the X11 select buffer #6250

Open davidchisnall opened 4 years ago

davidchisnall commented 4 years ago

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:

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).

DHowett commented 4 years ago

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 commented 4 years ago

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.

TrentonAdams commented 4 years ago

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 commented 3 years ago

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:

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 commented 2 years ago

Seems similar to #1553