Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-02-25 04:12:31 -0500
committerAnton Leherbauer2015-02-25 04:17:34 -0500
commit69bfa09f38a5fab8df814e8bcd6140b12eab5f97 (patch)
tree2521f93428b9701d99ecede04f89fb623f4cb4f1
parent9c1200cf4173a604a6118a4a6bd4754347a56a88 (diff)
downloadorg.eclipse.tcf-69bfa09f38a5fab8df814e8bcd6140b12eab5f97.tar.gz
org.eclipse.tcf-69bfa09f38a5fab8df814e8bcd6140b12eab5f97.tar.xz
org.eclipse.tcf-69bfa09f38a5fab8df814e8bcd6140b12eab5f97.zip
Bug 460703 - [terminals] Add support for middle mouse button paste
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java
index 42b05528b..ab04d4d87 100644
--- a/terminals/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java
@@ -29,8 +29,12 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionListener;
@@ -274,6 +278,8 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
((ITerminalControl)terminal).setConnectOnEnterIfClosed(!noReconnect);
}
+ // Add middle mouse button paste support
+ addMiddleMouseButtonPasteSupport(terminal);
// Add the "selection" listener to the terminal control
new TerminalControlSelectionListener(terminal);
// Configure the terminal encoding
@@ -385,6 +391,9 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
Assert.isTrue(terminal instanceof ITerminalControl);
((ITerminalControl)terminal).setupTerminal(composite);
+ // Add middle mouse button paste support
+ addMiddleMouseButtonPasteSupport(terminal);
+
item.setData(terminal);
// Associate the custom data node with the tab item (if any)
@@ -437,6 +446,26 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
}
+ protected void addMiddleMouseButtonPasteSupport(final ITerminalViewControl terminal) {
+ terminal.getControl().addMouseListener(new MouseAdapter(){
+ @Override
+ public void mouseDown(MouseEvent e) {
+ // paste when the middle button is clicked
+ if (e.button == 2) {
+ Clipboard clipboard = terminal.getClipboard();
+ if (clipboard.isDisposed()) return;
+ int clipboardType = DND.SELECTION_CLIPBOARD;
+ if (clipboard.getAvailableTypes(clipboardType).length == 0)
+ // use normal clipboard if selection clipboard is not available
+ clipboardType = DND.CLIPBOARD;
+ String text = (String) clipboard.getContents(TextTransfer.getInstance(), clipboardType);
+ if (text != null && text.length() > 0)
+ terminal.pasteString(text);
+ }
+ }
+ });
+ }
+
/**
* Generate a unique title string based on the given proposal.
*

Back to the top