mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
[475267] Added TerminalMouseListener to the VT100TerminalControl
As discussed in bugzilla, this extension allows terminal connectors to implement special features on mouse events (such as clicking on hyperlinks). Feature-request: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475267 Signed-off-by: Davy Landman <davy.landman@cwi.nl>
This commit is contained in:
parent
0efaf9c583
commit
aacd3c61cd
4 changed files with 96 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 CWI. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Davy Landman (CWI) - [475267][api] Initial definition of interface
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.control;
|
||||
|
||||
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
|
||||
|
||||
/**
|
||||
* Terminal specific version of {@link org.eclipse.swt.events.MouseListener}
|
||||
*/
|
||||
public interface ITerminalMouseListener {
|
||||
/**
|
||||
* Invoked when a double-click has happend inside the terminal control.<br>
|
||||
* <br>
|
||||
* <strong>Important:</strong> the event fires for every click, even outside the text region.
|
||||
* @param terminalText a read-only view of the current terminal text
|
||||
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
||||
*/
|
||||
void mouseDoubleClick(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
||||
/**
|
||||
* Invoked when a mouse button is pushed down inside the terminal control.<br>
|
||||
* <br>
|
||||
* <strong>Important:</strong> the event fires for every mouse down, even outside the text region.
|
||||
* @param terminalText a read-only view of the current terminal text
|
||||
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
||||
*/
|
||||
void mouseDown(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
||||
/**
|
||||
* Invoked when a mouse button is released inside the terminal control.<br>
|
||||
* <br>
|
||||
* <strong>Important:</strong> the event fires for every mouse up, even outside the text region.
|
||||
* @param terminalText a read-only view of the current terminal text
|
||||
* @param button see {@link org.eclipse.swt.events.MouseEvent#button} for the meaning of the button values
|
||||
*/
|
||||
void mouseUp(ITerminalTextDataReadOnly terminalText, int line, int column, int button);
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use
|
||||
* Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically
|
||||
* Davy Landman (CWI) - [475267][api] Allow custom mouse listeners
|
||||
******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.control;
|
||||
|
||||
|
@ -118,4 +119,7 @@ public interface ITerminalViewControl {
|
|||
public void setBufferLineLimit(int bufferLineLimit);
|
||||
boolean isScrollLock();
|
||||
void setScrollLock(boolean on);
|
||||
|
||||
void addMouseListener(ITerminalMouseListener listener);
|
||||
void removeMouseListener(ITerminalMouseListener listener);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
* Martin Oberhuber (Wind River) - [436612] Restore Eclipse 3.4 compatibility by using Reflection
|
||||
* Anton Leherbauer (Wind River) - [458398] Add support for normal/application cursor keys mode
|
||||
* Anton Leherbauer (Wind River) - [420928] Terminal widget leaks memory
|
||||
* Davy Landman (CWI) - [475267][api] Allow custom mouse listeners
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.emulator;
|
||||
|
||||
|
@ -90,6 +91,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.tm.internal.terminal.control.ICommandInputField;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalListener2;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
|
||||
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
|
||||
import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages;
|
||||
|
@ -1407,5 +1409,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
|||
public void enableApplicationCursorKeys(boolean enable) {
|
||||
fApplicationCursorKeys = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMouseListener(ITerminalMouseListener listener) {
|
||||
getCtlText().addTerminalMouseListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMouseListener(ITerminalMouseListener listener) {
|
||||
getCtlText().removeTerminalMouseListener(listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,10 +17,14 @@
|
|||
* Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour
|
||||
* Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically
|
||||
* Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty
|
||||
* Davy Landman (CWI) - [475267][api] Allow custom mouse listeners
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.textcanvas;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
|
@ -35,6 +39,7 @@ import org.eclipse.swt.graphics.GC;
|
|||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener;
|
||||
|
||||
/**
|
||||
* A cell oriented Canvas. Maintains a list of "cells".
|
||||
|
@ -50,6 +55,7 @@ public class TextCanvas extends GridCanvas {
|
|||
private Point fDraggingEnd;
|
||||
private boolean fHasSelection;
|
||||
private ResizeListener fResizeListener;
|
||||
private final List<ITerminalMouseListener> fMouseListeners;
|
||||
|
||||
// The minSize is meant to determine the minimum size of the backing store
|
||||
// (grid) into which remote data is rendered. If the viewport is smaller
|
||||
|
@ -116,8 +122,17 @@ public class TextCanvas extends GridCanvas {
|
|||
public void focusLost(FocusEvent e) {
|
||||
fCellCanvasModel.setCursorEnabled(false);
|
||||
}});
|
||||
fMouseListeners = new ArrayList<ITerminalMouseListener>();
|
||||
addMouseListener(new MouseListener(){
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
if (fMouseListeners.size() > 0) {
|
||||
Point pt = screenPointToCell(e.x, e.y);
|
||||
if (pt != null) {
|
||||
for (ITerminalMouseListener l : fMouseListeners) {
|
||||
l.mouseDoubleClick(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void mouseDown(MouseEvent e) {
|
||||
if(e.button==1) { // left button
|
||||
|
@ -132,6 +147,14 @@ public class TextCanvas extends GridCanvas {
|
|||
}
|
||||
fDraggingEnd=null;
|
||||
}
|
||||
if (fMouseListeners.size() > 0) {
|
||||
Point pt = screenPointToCell(e.x, e.y);
|
||||
if (pt != null) {
|
||||
for (ITerminalMouseListener l : fMouseListeners) {
|
||||
l.mouseDown(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void mouseUp(MouseEvent e) {
|
||||
if(e.button==1) { // left button
|
||||
|
@ -142,6 +165,14 @@ public class TextCanvas extends GridCanvas {
|
|||
fCellCanvasModel.setSelection(-1,-1,-1,-1);
|
||||
fDraggingStart=null;
|
||||
}
|
||||
if (fMouseListeners.size() > 0) {
|
||||
Point pt = screenPointToCell(e.x, e.y);
|
||||
if (pt != null) {
|
||||
for (ITerminalMouseListener l : fMouseListeners) {
|
||||
l.mouseUp(fCellCanvasModel.getTerminalText(), pt.y, pt.x, e.button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
addMouseMoveListener(new MouseMoveListener() {
|
||||
|
@ -428,5 +459,12 @@ public class TextCanvas extends GridCanvas {
|
|||
|
||||
}
|
||||
|
||||
public void addTerminalMouseListener(final ITerminalMouseListener listener) {
|
||||
fMouseListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeTerminalMouseListener(ITerminalMouseListener listener) {
|
||||
fMouseListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue