Author: koen.aers(a)jboss.com
Date: 2011-10-06 04:17:01 -0400 (Thu, 06 Oct 2011)
New Revision: 35414
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
Log:
JBIDE-9804: Fix the Mouse Down Event in the Console View
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java 2011-10-06
07:54:43 UTC (rev 35413)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java 2011-10-06
08:17:01 UTC (rev 35414)
@@ -71,6 +71,7 @@
private ForgeRuntime runtime;
private Document document;
private StyleRange currentStyleRange = null;
+ private int caretOffset = 0;
public ForgeTextViewer(Composite parent, ForgeRuntime runtime) {
super(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
@@ -106,10 +107,10 @@
}
}
});
- getTextWidget().addListener(SWT.MouseDown, new Listener() {
+ getTextWidget().addListener(SWT.MouseUp, new Listener() {
@Override
public void handleEvent(Event event) {
- event.doit = false;
+ getTextWidget().setCaretOffset(caretOffset);
}
});
}
@@ -161,9 +162,8 @@
public void run() {
try {
String filteredOutput = output.replaceAll("\r", "");
- int caretOffset = getTextWidget().getCaretOffset();
document.replace(caretOffset, document.getLength() - caretOffset,
filteredOutput);
- getTextWidget().setCaretOffset(caretOffset + filteredOutput.length());
+ getTextWidget().setCaretOffset(caretOffset = caretOffset +
filteredOutput.length());
if (currentStyleRange != null) {
currentStyleRange.length = currentStyleRange.length + filteredOutput.length();
getTextWidget().setStyleRange(currentStyleRange);
@@ -227,8 +227,8 @@
private void moveCursorAbsoluteInLine(final String command) {
try {
int column = Integer.valueOf(command.substring(2, command.length() - 1));
- int lineStart =
document.getLineOffset(document.getLineOfOffset(getTextWidget().getCaretOffset()));
- getTextWidget().setCaretOffset(lineStart + column - 1);
+ int lineStart = document.getLineOffset(document.getLineOfOffset(caretOffset));
+ getTextWidget().setCaretOffset(caretOffset = lineStart + column - 1);
} catch (BadLocationException e) {
ForgeUIPlugin.log(e);
}
@@ -236,7 +236,6 @@
private void clearCurrentLine(String command) {
try {
- int caretOffset = getTextWidget().getCaretOffset();
document.replace(caretOffset, document.getLength() - caretOffset,
"");
} catch (BadLocationException e) {
ForgeUIPlugin.log(e);
@@ -284,7 +283,7 @@
int offset = textWidget.getOffsetAtLine(line);
int maxColumn = textWidget.getLine(line).length();
offset += Math.min(maxColumn, column);
- getTextWidget().setCaretOffset(offset);
+ getTextWidget().setCaretOffset(caretOffset = offset);
}
private void clearCurrentScreenPage(String command) {
Show replies by date