From f9a4da348dc5f3dd4f0f5730abd2244bf009725d Mon Sep 17 00:00:00 2001 From: Max Weninger Date: Thu, 1 Aug 2013 16:44:04 +0200 Subject: [PATCH] Terminal: Added support for Copy/Paste shortcuts Signed-off-by: Max Weninger --- .../org.eclipse.tm.terminal/plugin.properties | 1 + plugins/org.eclipse.tm.terminal/plugin.xml | 35 ++++++++- .../control/actions/TerminalActionCopy.java | 2 + .../control/actions/TerminalActionPaste.java | 2 + .../emulator/EditActionAccelerators.java | 72 +++++++++++++++++++ .../emulator/VT100TerminalControl.java | 29 ++++++-- 6 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/EditActionAccelerators.java diff --git a/plugins/org.eclipse.tm.terminal/plugin.properties b/plugins/org.eclipse.tm.terminal/plugin.properties index 2120813cbe7..d7efc1837f0 100644 --- a/plugins/org.eclipse.tm.terminal/plugin.properties +++ b/plugins/org.eclipse.tm.terminal/plugin.properties @@ -27,6 +27,7 @@ terminal.context.description=Override ALT+x menu access keys terminal.insertion.description=Terminal view insertion terminal.insertion.name=Terminal view insert terminal.insertion.category.name=Terminal view commands +terminal.view.insertion.description = Terminal view commands terminal.preferences.name = Terminal terminal.font.description = The font for the terminal console. diff --git a/plugins/org.eclipse.tm.terminal/plugin.xml b/plugins/org.eclipse.tm.terminal/plugin.xml index 1115912c7e6..65846803309 100644 --- a/plugins/org.eclipse.tm.terminal/plugin.xml +++ b/plugins/org.eclipse.tm.terminal/plugin.xml @@ -21,10 +21,16 @@ description="%terminal.context.description" id="org.eclipse.tm.terminal.TerminalContext" /> + + + + + - - - @@ -32,11 +38,24 @@ categoryId="org.eclipse.tm.terminal.category1" id="org.eclipse.tm.terminal.command1" name="%terminal.insertion.name"/> + + + + + + + + + true, the Terminal widget will pick up settings + * @param useCommonPrefs If true, the Terminal widget will pick up settings * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. * Otherwise, clients need to maintain settings themselves. * @since 3.2 @@ -620,7 +622,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC } private void onTerminalFontChanged() { - // set the font for all + // set the font for all setFont(ITerminalConstants.FONT_DEFINITION); } @@ -790,6 +792,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC } protected class TerminalFocusListener implements FocusListener { private IContextActivation contextActivation = null; + private IContextActivation contextActivation1 = null; protected TerminalFocusListener() { super(); @@ -815,6 +818,9 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC .getWorkbench().getAdapter(IContextService.class); contextActivation = contextService .activateContext("org.eclipse.tm.terminal.TerminalContext"); //$NON-NLS-1$ + contextActivation1 = contextService + .activateContext("org.eclipse.tm.terminal.EditContext"); //$NON-NLS-1$ + } public void focusLost(FocusEvent event) { @@ -829,6 +835,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC IContextService contextService = (IContextService) PlatformUI .getWorkbench().getAdapter(IContextService.class); contextService.deactivateContext(contextActivation); + contextService.deactivateContext(contextActivation1); } } @@ -837,6 +844,16 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC if (getState()==TerminalState.CONNECTING) return; + int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); + if (editActionAccelerators.isCopyAction(accelerator)) { + copy(); + return; + } + if (editActionAccelerators.isPasteAction(accelerator)) { + paste(); + return; + } + // We set the event.doit to false to prevent any further processing of this // key event. The only reason this is here is because I was seeing the F10 // key both send an escape sequence (due to this method) and switch focus