terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Feature: add copy on select (per Unix terminals)

Open mikemaccana opened this issue 7 years ago • 42 comments

Similar to #523, except the reverse: selected data in the terminal is not copyable to other apps.

Your Windows build number: (Type ver at a Windows Command Prompt)

Can't tell you, because when I select it it won't paste into this form!

But using another terminal app (and fixing the command to work with Windows default shell):

$ #[Environment]::OSVersion.VersionString
Microsoft Windows NT 10.0.18890.0

What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)

Both:

  • Highlighting text to select it then pasting it fails
  • Highlighting text, pressing Ctrl C (which shouldn't be necessary) and then pasting it fails

What's wrong / what should be happening instead:

Different data is pasted

It should be pasting whatever was selected in the terminal.

Here's the options provided by Fluent Terminal:

Annotation 2019-07-21 175305

mikemaccana avatar May 07 '19 16:05 mikemaccana

@carlos-zamora is working on this currently :)

zadjii-msft avatar May 07 '19 17:05 zadjii-msft

I have no problem doing this. This is how I copy/paste: Mouse left click and hold to select text. Release left click. Mouse right click once on selected text. It is now in your clipboard.


Microsoft Windows [Version 10.0.18362.86]

nizos avatar May 07 '19 18:05 nizos

@nizos Selecting should copy the text to the clipboard immediately per any other terminal. Doing additional steps is a workaround, not a fix.

mikemaccana avatar May 08 '19 08:05 mikemaccana

@mikemaccana I have read the bug report. I just didn’t know that the terminal is supposed to copy anything selected immediately. Where did you read that it is supposed to work that way? I have always used the method I described to copy text in command prompt.

nizos avatar May 08 '19 09:05 nizos

@nizos Copying immediately on select has been default on Unix terminals for at least 21 years, but probably longer than that.

mikemaccana avatar May 08 '19 10:05 mikemaccana

Clearly, lots of people have varying opinions on how they want their text to be copy/pasteable from the terminal. That's why we're hoping to make it a feature that's customizable to however you like :)

zadjii-msft avatar May 08 '19 14:05 zadjii-msft

Yeah. I'm working on the keybindings. Really just need to make sure I send the VT sequence.

As for the copying immediately on selection, I'll be sure to make a setting and add that functionality.

carlos-zamora avatar May 09 '19 18:05 carlos-zamora

Middle mouse button paste would be awesome too.

jberanek avatar Jun 15 '19 15:06 jberanek

@jberanek Right click paste works now, but agreed it would be good to allow it to be middle mouse too. You should probably make a separate issue though!

mikemaccana avatar Jun 17 '19 18:06 mikemaccana

Man what we really need is a way to set mouse-bindings as well as keybindings. I believe @carlos-zamora is working on a spec for that (and I'll let him link the appropriate thread in for that discussion)

zadjii-msft avatar Jun 18 '19 15:06 zadjii-msft

More details from #1332 : Dragging should highlight like console, but automatically put the highlighted text into the clipboard and leave it highlighted.

Selection should NOT include trailing spaces as the current terminal incorrectly does with ctrl-shift-c, It should post multiple lines to the clipboard. The selection should look for characters are actual spaces, and not blanks and not replace blanks with spaces.

Dragging with alt or control held down should select a block instead of rolling lines.

Clicking the middle mouse button should paste the clipboard.

Mouse wheel should scroll, perhaps 3 lines at a time.

This functionality can be compared with xfce4-terminal or gnome-terminal on a Linux box, or on WSL under X servers like VcXsrv. Also compare to MoboXterm support. XTerm is similar but lacks the block select feature.

timriker avatar Jun 19 '19 20:06 timriker

I am happy that there already seems to be some way to do copy/paste. However, I'm not a big fan of right click performing actions. Typically right click would open a context menu. Trying to open a menu and running a set of commands in a terminal by accident sounds like a nightmare.

I did some voluntary work on Freedesktop.org clipboard specification back in 2007. Clipboards seem to be a rather controversial topic and I think unix clipboards are still not consistent. I tried to post an update to the specification back then to fill in some gaps and add some ideas that I gathered from elsewhere. Not sure what happened after I stopped working on it. However, my original mailing list post seems to still be available if someone is interested. https://lists.freedesktop.org/archives/xdg/2007-November/008985.html

cyberixae avatar Jun 22 '19 14:06 cyberixae

regarding highlight and copy, I see some abnormal behavior. left click selects a character and if you click and drag from the tab it marks everything in between and copies. if you double click right, it pastes too. Works for any terminal.

reference video: https://imgur.com/a/jomxTJY

Shorotshishir avatar Jun 24 '19 07:06 Shorotshishir

@nizos Copying immediately on select has been default on Unix terminals for at least 21 years, but probably longer than that.

Yeah, basic functionality that should be available from day one in Windows Terminal.

TCB13 avatar Jun 24 '19 17:06 TCB13

It's clear that different users expect different things. Sorry that the preview release default isn't what you're expecting. :smile:

DHowett-MSFT avatar Jun 24 '19 17:06 DHowett-MSFT

Pointer bindings: #1553

carlos-zamora avatar Jun 24 '19 19:06 carlos-zamora

Comments from #1496:

Please, please (please!) add a setting to enable PuTTY style text selection behavior in the new terminal.

  1. Randomly left clicking on a terminal should not select 1 character, it should just focus (or keep focus if already focused) the window. Nowhere in windows other than terminal does clicking select a character. This is really annoying in multi-monitor scenarios when you are unsure if a window is focused and you click in and it selects a character...
  2. Selecting text with your mouse should automatically copy to the clipboard onmouseup, there are not many scenarios when selecting text in a terminal does not result in copying to the clipboard so it is weird to have to right-click on press enter to copy.
  3. Selected text should automatically be deselected when the clipboard changes, quite helpful to visually see that the selected text is no longer in the clipboard. Surprisingly useful.
  4. Right click should always be paste (not copy!), regardless of if text is currently selected or not. Very annoying, especially with the first issue, if you select a window which was already focused a character is selected, then right clicking to paste ends up copying the selected character.. grr!
  5. Selection should not be lost when typing in the terminal, if you select some text then type a command, it is helpful for the selection to remain selected. This way you know what is in the clipboard (if the 3rd suggestion is implemented).

Please, please, please implement these, thanks! :)


There's a lot of overlap with #524 here. I personally agree with all of it except point 4 (I prefer middle click paste). From discussion on #524 is looks like they're headed towards configurable mouse button mappings, so rather than a single "putty-style" option I would suggest that:

  1. I agree unconditionally; this seems likely just a bug.
  2. Copy-on-select should be an option
  3. I agree; this makes sense when tied to the same copy-on-select option IMO -- if the selection represents the clipboard, then it makes sense to clear it if the clipboard changes
  4. Personally I prefer middle-click paste, right-click context menu. I think that's a mouse button mapping option.
  5. I agree, unconditionally. I suspect the current behaviour stems from legacy conhost which clears the selection when you start typing, but it makes a bit more sense there, because in conhost selecting also suspends new output.

So I'd propose that rather than "putty-style" we have two options: a mouse-binding for what happens when you middle/right-click, and a "copy-on-select" option that enables 2, 3, and maybe 5 above. This is also close to the way these options are broken out in mintty.

DHowett-MSFT avatar Jun 24 '19 20:06 DHowett-MSFT

It's clear that different users expect different things. Sorry that the preview release default isn't what you're expecting. 😄

It's not about "different users expect different things", it's about default, proven to work behavior that has been around for 20 years as stated before. I get why the pointer bindings suggested by @carlos-zamora might be a fix for this, however that kind of feature will take a long time to implement because of it's large scope.

Implementing the default copy-on-selection will be much faster and make this terminal work in a predictable manner.

TCB13 avatar Jun 25 '19 14:06 TCB13

I'm a xshell user, can support right click to popout menu then click copy/paste? I don't like use left select copy, right click paste, for me it always operate incorrectly

xmm1989218 avatar Jun 25 '19 16:06 xmm1989218

Ok. A lot to unpack on this thread. Let me know if I'm missing anything and I'll try and direct traffic appropriately. There's different ways we all expect to copy a selection on a terminal:

  1. This Issue: copy immediately upon making the selection
    • This should be decently easy to implement. We need a setting to enable/disable this. Probably worth making this a global setting, and NOT per profile.
    • Added "Help-Wanted" tag for anybody to try and implement. The team and I can provide support.
  2. Mixed Implementation: classic windows copy/paste
    • If a selection is active, perform <action> to copy the selection to your clipboard.
      • right click: already implemented
      • middle click: Issue #1612
      • ENTER button: Issue #715 (this also includes moving the selection with the keyboard)
  3. The actions from 2 need to be configurable such that people can enable/disable them as they please. To make these actions configurable, we need Pointer Bindings #1553

carlos-zamora avatar Jun 25 '19 17:06 carlos-zamora