Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 300809

Summary: [terminal] Missing copy & paste keyboard shortcuts in Terminal
Product: [Tools] Target Management Reporter: Rudolf Adamkovic <salutis>
Component: TerminalAssignee: Max Weninger <max.weninger>
Status: RESOLVED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3 CC: aleherb+eclipse, eclipse, uwe.st, yevshif
Version: unspecified   
Target Milestone: 3.5.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 335021    
Bug Blocks:    
Attachments:
Description Flags
The difference between CTRL, ALT and CMD none

Description Rudolf Adamkovic CLA 2010-01-26 08:47:16 EST
Build Identifier: 20090920-1017

I am not able to perform copy & paste in Terminal window on my Mac OS X box. I tried CTRL+SHIFT+C and also CTRL+CMD+C, but without success. Copy & paste works only via the context menu.

Reproducible: Always

Steps to Reproduce:
1. Create a new connection in Remote systems
2. Connect and launch Terminal window
3. Try to copy & paste functionality
Comment 1 Rudolf Adamkovic CLA 2010-01-26 08:50:53 EST
(In reply to comment #0)
> Build Identifier: 20090920-1017
> 
> I am not able to perform copy & paste in Terminal window on my Mac OS X box.

Ah I forgot "with keyboard only". So, as it should be clear:

I am not able to perform copy & paste in Terminal window on my Mac OS X box with keyboard only.
Comment 2 Michael Scharf CLA 2010-01-26 08:59:53 EST
This is by design! Once the terminal has the focus *all* keyboard events are taken by the terminal. How would you deal with the case where you want to send
CTRL+SHIFT+C or CTRL+META+C to the terminal?

This is *not* mac specific.
Comment 3 Rudolf Adamkovic CLA 2010-01-26 09:05:06 EST
So, it is not possible to work with the clipboard with the keyboard only? I don't know about others, but for me it is an issue. Or am I missing something?
Comment 4 Rudolf Adamkovic CLA 2010-01-26 09:06:51 EST
So, it is not possible to work with the clipboard with the keyboard only? I don't know about others, but for me it is an issue. Shouldn't it be fixed? I think so.
Comment 5 Rudolf Adamkovic CLA 2010-01-26 09:09:19 EST
Sorry for the duplicate comment above.
Comment 6 Uwe Stieber CLA 2010-01-26 09:58:45 EST
The core requirement is that control sequences are passed on to the terminal for handling. Things like CTRL+C/CTRL+D needs to go to the terminal, otherwise there will be complains that you cannot terminate the terminal using this keyboard sequences.

The missing keyboard shortcuts for Copy/Paste in the terminal are inconvenient. There is a second set of standard keyboard shortcuts for Copy (CTRL+Insert) and Paste (Shift+Insert). If these sequences are not associated with common terminal functionality, it might be OK to handle them on the host instead of the terminal to solve this inconvenience.

Michael, comments?
Comment 7 Rudolf Adamkovic CLA 2010-01-26 10:19:22 EST
(In reply to comment #6)
> There is a second set of standard keyboard shortcuts for Copy (CTRL+Insert) and
> Paste (Shift+Insert). If these sequences are not associated with common
> terminal functionality, it might be OK to handle them on the host instead of
> the terminal to solve this inconvenience.

BTW, don't forget that there is no Insert key on Mac.
Comment 8 Uwe Stieber CLA 2010-01-26 10:36:48 EST
That will make it obviously difficult on Mac to use them. Are there alternate keyboard shortcut assignments in the Eclipse keys preferences for Copy/Cut/Paste on Mac? Sorry to ask, I'm not blessed with a Mac :).
Comment 9 Rudolf Adamkovic CLA 2010-01-26 10:43:46 EST
There are only CMD+C, CMD+X and CMD+V as I can see in Keys section.
Comment 10 Martin Oberhuber CLA 2010-01-26 10:44:44 EST
As Michael said, having the Terminal send all key commands to the remote is by
design. I am not aware of any other Terminal program that would interpret such
key sequences locally (thinking about Hyperterm, Teraterm, Putty on Windows;
minicom on Linux; even xterm) but perhaps I am missing something.

If you do want to use the clipboard, you should enable the optional terminal
input line (right-click, toggle command input field). This provides full copy &
paste support, plus local editing and a local history of commands. Also, on
Windows keyboards, the special "show contextmenu" key is available.

Before moving forward with any specific patches / enhancements, I would like to
see an example how another Terminal program handles this with the keyboard. If
such an example does not exist, I'd resolve this as WONTFIX.
Comment 11 Martin Oberhuber CLA 2010-01-26 10:45:27 EST
PS: If you do use the clipboard, where do you copy from? How do you move around? I suppose you'd be using the mouse for this, no?
Comment 12 Rudolf Adamkovic CLA 2010-01-26 10:47:17 EST
BTW, there on Mac CMD is used instead of CTRL for copy/cut/paste shortcuts. So, on the Mac there is no problem to do CTRL+C in Terminal. The problem is with CMD+C, which is not handled in Terminal window  anyway (CMD is used only on Mac).
Comment 13 Uwe Stieber CLA 2010-01-26 11:05:13 EST
Martin,

Putty in example is supporting "copy on mark/select". So you can copy/paste from/to the terminal using a common usage pattern. Eclipse users are used to their keyboard shortcuts (CMD or CTRL or ...), so you inherit a usage pattern a common terminal does not have. The Eclipse integrated terminal on the other hand does not support "copy on mark/select" and "paste on middle mouse button", AFAIK. So the inconvenient is real as neither Eclipse common way nor the external terminal way (Putty) is available.
Comment 14 Martin Oberhuber CLA 2010-01-26 11:08:52 EST
(In reply to comment #13)
Can you explain how the "copy on mark/select" feature works?
And yes, the TM Terminal does support "Paste on middle mouse button" :)

Regarding the concrete case on the Mac: When Cmd is in fact specific for the Mac only such that it never makes any sense sending it to the remote, then there is a case for supporting shortcuts with Cmd.

I would still like to know about one terminal program who does this; and, since
none of the active committers has any Mac to develop / test this on, could you
do some work yourself? Setting up Eclipse for looking at the plugin is easy:

1. Download http://www.eclipse.org/dsdp/tm/development/terminal-anonymous.psf 
   to a local file
2. File > Import > Team > Team Project Set : point to the downloaded file : 
   will import from CVS (takes a while -- enter user:anonyous, passwd: foo@bar)
3. Look at plugin org.eclipse.tm.terminal
   VT100TerminalControl.TerminalFocusListener.focusGained()
4. To test: Run > Debug Configurations... : Select "Eclipse Application", 
   press "New" button : press Run
Comment 15 Rudolf Adamkovic CLA 2010-01-26 11:12:07 EST
On Mac it should be CMD+C/X/V. It is standard and there is no collision with the programs run in terminal, because they don't know about CMD key. About middle-click paste, there is no 3rd (middle) button on many Apple's HW and it is not possible to emulate it with left & right click, because of HW limitations (there is only one HW button in the mouse and a special sensor to detect which finger is clicking). So, on the Apple's HW it should be simple CMD+C/X/V.
Comment 16 Uwe Stieber CLA 2010-01-26 11:17:13 EST
(In reply to comment #14)

>Can you explain how the "copy on mark/select" feature works?

You just select the text to copy in the terminal window and it is immediately available in the application/system clipboard. Open a editor, press CTRL+V, and it is done.

>And yes, the TM Terminal does support "Paste on middle mouse button" :)

Nice :)
Comment 17 Michael Scharf CLA 2010-01-26 11:19:53 EST
(In reply to comment #15)
> On Mac it should be CMD+C/X/V. It is standard and there is no collision with
> the programs run in terminal, because they don't know about CMD key. About
> middle-click paste, there is no 3rd (middle) button on many Apple's HW and it
> is not possible to emulate it with left & right click, because of HW
> limitations (there is only one HW button in the mouse and a special sensor to
> detect which finger is clicking). So, on the Apple's HW it should be simple
> CMD+C/X/V.

Is there a Meta key on a Mac? We need SHIFT, CONTROL and META... I guess the
CMD key is mapped to META on a mac...
Comment 18 Rudolf Adamkovic CLA 2010-01-26 11:21:35 EST
(In reply to comment #17)
> (In reply to comment #15)
> 
> Is there a Meta key on a Mac? We need SHIFT, CONTROL and META... I guess the
> CMD key is mapped to META on a mac...

There are SHIFT, CTRL, ALT and CMD.
Comment 19 Michael Scharf CLA 2010-01-26 11:26:33 EST
> There are SHIFT, CTRL, ALT and CMD.

and eclipse sees all 4 of them as distinct modifiers? (ALT and CMD are not interchangeable within eclipse)
Comment 20 Michael Scharf CLA 2010-01-26 11:29:05 EST
looking into org.eclipse.swt.SWT there is only ALT CTRL and SHIFT. I do not se a way to access the apple CMD modifier...
Comment 21 Rudolf Adamkovic CLA 2010-01-26 11:29:46 EST
(In reply to comment #19)
> > There are SHIFT, CTRL, ALT and CMD.
> 
> and eclipse sees all 4 of them as distinct modifiers? (ALT and CMD are not
> interchangeable within eclipse)

Yes. In Preferences->Keys I can see the difference in CTRL, ALT and CMD when redefining shortcut for Copy, for example. Every key has its own symbol there.
Comment 22 Michael Scharf CLA 2010-01-26 11:30:55 EST
oops there is also org.eclipse.swt.SWT.COMMAND -- that could then be used....
Comment 23 Michael Scharf CLA 2010-01-26 11:31:55 EST
oops there is also org.eclipse.swt.SWT.COMMAND -- that could then be used....
Comment 24 Rudolf Adamkovic CLA 2010-01-26 11:34:00 EST
Created attachment 157285 [details]
The difference between CTRL, ALT and CMD
Comment 25 Martin Oberhuber CLA 2012-01-18 09:56:29 EST
(In reply to comment #16)
> You just select the text to copy in the terminal window and it is immediately
> available in the application/system clipboard. Open a editor, press CTRL+V, and
> it is done.

This doesn't work with latest builds on Windows (maybe due to the changes needed for bug 335021) - and it's actually unexpected on Windows.

I think we should try to enable CMD-C / CMD-V on the Mac unconditionally.

Regarding Ctrl-C / Ctrl-V on Windows it's harder since users may expect that key sequence to be actually sent to the target. It could be a setting in the Terminal widget what happens on Ctrl-C / Ctrl-V . Adopters of the Terminal Widget should be able to influence that setting for a connection, since it depends on the kind of application on the remote whether sending Ctrl-C / Ctrl-V to the target makes more sense, or Copy / Paste makes more sense. A global Preference Setting may also make sense.

At any rate, note that performing "Copy" by keyboard doesn't help very much since the selection needs to be created by keyboard anyways. In that respect, it's always going to remain different than "Copy" in a VNC session or local view / editor.

CQ:WIND00329074
Comment 26 Martin Oberhuber CLA 2013-03-06 07:20:51 EST
See:ELT

Note that this has been implemented in a Fork of the TM Terminal, Google ELT:
http://code.google.com/p/elt/
as well as another fork of the TM Terminal, in Aptana Studio:
http://www.aptana.com/products/studio3/download

It would be great for those forks to contribute back the functionality they have added.
Comment 27 Martin Oberhuber CLA 2013-08-28 17:19:58 EDT
It looks like this has actually been implemented for TM 3.5.1:
http://git.eclipse.org/c/tm/org.eclipse.tm.git/commit/?id=092531d62dc4a53acef4e383fd1c71ec49eae67f

By default, Ctrl+Shift+C is assigned "copy" and Ctrl+Shift+V to "paste".
But Preferences > Keys can be used to change the default assignment;
I have successfully changed "paste" to Shift+Insert.

Max / Uwe can you confirm that the feature is "done" for TM 3.5.1 ?
Comment 28 Uwe Stieber CLA 2013-08-29 03:08:18 EDT
Confirmed.
Comment 29 Martin Oberhuber CLA 2013-08-29 11:10:36 EDT
Marking fixed as per TM 3.5.1 then.