mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Bug 434294 - [terminal] Make Mac COMMAND key to always act locally
On Mac, the COMMAND key is expected to always perform keyboard shortcuts on the local host, or emulate keys like HOME and END. This change now supports the COMMAND key as expected. Also, - configured the VT100TerminalControl.java to forced use of UTF-8 encoding since one comment has non-US-ASCII characters - added the CTRL+INSERT binding for "Copy", - converted CTRL+SHIFT in the bindings into M1+M2 which is the preferred syntax according to the org.eclipse.ui.bindings extension point description ("sequence" section). Change-Id: I49321e3855b9ccf53fcb49a5346cfedff4c0c8c0 Signed-off-by: Martin Oberhuber <martin.oberhuber@windriver.com>
This commit is contained in:
parent
81e25e6d70
commit
f1e9724565
3 changed files with 60 additions and 5 deletions
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java=UTF-8
|
|
@ -12,6 +12,7 @@
|
|||
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
# Michael Scharf (Wind River) - [237425] undefined tm.terminal command
|
||||
# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget
|
||||
# Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND
|
||||
-->
|
||||
<plugin>
|
||||
<extension-point id="terminalConnectors" name="Terminal Connectors" schema="schema/terminalConnectors.exsd"/>
|
||||
|
@ -125,21 +126,64 @@
|
|||
contextId="org.eclipse.tm.terminal.TerminalContext"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="Alt+W"/> <!-- Window -->
|
||||
<!--
|
||||
For Copy and Paste, we need replacements since the default Ctrl+C / Ctrl+V
|
||||
need to go to the terminal and thus are not available for local Copy and Paste.
|
||||
This is not an issue on Mac, where COMMAND+C / COMMAND+V works fine.
|
||||
|
||||
We add both CTRL+INSERT and CTRL+SHIFT+C since on some keyboards, an INSERT key
|
||||
may not be available. Note: we want the "least surprising" and "most available"
|
||||
of all bindings to be shown in the context menu according to the algorithm in
|
||||
IBindingService#getBestActiveBindingFor().
|
||||
Therefore, we do not want these extra bindings to be shown on the Mac.
|
||||
|
||||
Unfortunately, there is no way in Bindings to say "NOT Platforms X,Y,Z"
|
||||
We would really like one of the following here but it doesnt work with Eclipse 4.3:
|
||||
platforms="!carbon,!cocoa"
|
||||
platforms="win32,motif,gtk,photon,wpf"
|
||||
Since Eclipse doesnt support this, we will redefine the original Mac bindings below,
|
||||
just to make them show up in the context menu.
|
||||
-->
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.copy"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="CTRL+SHIFT+C"/>
|
||||
sequence="M1+INSERT"/><!-- Ctrl+Insert -->
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.copy"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="M1+M2+C"><!-- Ctrl+Shift+C -->
|
||||
</key>
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.paste"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="CTRL+SHIFT+V"/>
|
||||
sequence="M2+INSERT"/><!-- Shift+Insert -->
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.paste"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="SHIFT+INSERT"/>
|
||||
sequence="M1+M2+V"/><!-- Ctrl+Shift+V -->
|
||||
<!--
|
||||
Mac shortcuts need to be redefined with Platform Filter, in order to make
|
||||
them "better" than the bindings above and thus show up in the menu.
|
||||
See the algorithm in IBindingService#getBestActiveBindingFor().
|
||||
It looks like the "carbon" entry is also valid for "cocoa" automatically.
|
||||
-->
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.copy"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
platform="carbon"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="M1+C">
|
||||
</key>
|
||||
<key
|
||||
commandId="org.eclipse.tm.terminal.paste"
|
||||
contextId="org.eclipse.tm.terminal.EditContext"
|
||||
platform="carbon"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="M1+V"/>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
* Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget
|
||||
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
|
||||
* Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers
|
||||
* Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.emulator;
|
||||
|
||||
|
@ -877,6 +878,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
char character = event.character;
|
||||
boolean ctrlKeyPressed = (event.stateMask & SWT.CTRL) != 0;
|
||||
boolean altKeyPressed = (event.stateMask & SWT.ALT) != 0;
|
||||
boolean macCmdKeyPressed = (event.stateMask & SWT.COMMAND) != 0;
|
||||
|
||||
// To fix SPR 110341, we consider the Alt key to be pressed only when the
|
||||
// Control key is _not_ also pressed. This works around a bug in SWT where,
|
||||
|
@ -913,8 +915,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
// because Control-@ (i.e., NUL) invokes Emacs' set-mark-command when Emacs
|
||||
// is running on a terminal. When the user presses Control-@, the keyCode
|
||||
// is 50.
|
||||
// On a Mac, the Cmd key is always used for local commands.
|
||||
|
||||
if (character == '\u0000' && event.keyCode != 50) {
|
||||
if (macCmdKeyPressed || (character == '\u0000' && event.keyCode != 50)) {
|
||||
// A special key was pressed. Figure out which one it was and send the
|
||||
// appropriate ANSI escape sequence.
|
||||
//
|
||||
|
@ -941,6 +944,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
escSeq = "\u001b[1;5D"; //$NON-NLS-1$
|
||||
} else if (!anyModifierPressed) {
|
||||
escSeq = "\u001b[D"; //$NON-NLS-1$
|
||||
} else if (macCmdKeyPressed) {
|
||||
// Cmd-Left is "Home" on the Mac
|
||||
escSeq = "\u001b[H"; //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -949,6 +955,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
escSeq = "\u001b[1;5C"; //$NON-NLS-1$
|
||||
} else if (!anyModifierPressed) {
|
||||
escSeq = "\u001b[C"; //$NON-NLS-1$
|
||||
} else if (macCmdKeyPressed) {
|
||||
// Cmd-Right is "End" on the Mac
|
||||
escSeq = "\u001b[F"; //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -956,7 +965,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
if (!anyModifierPressed)
|
||||
escSeq = "\u001b[5~"; //$NON-NLS-1$
|
||||
break;
|
||||
|
||||
|
||||
case 0x1000006: // PgDn key.
|
||||
if (!anyModifierPressed)
|
||||
escSeq = "\u001b[6~"; //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue