1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-24 16:53:50 +02:00

bug 205879: [terminal] clicking into the terminal creates a selection of one character

https://bugs.eclipse.org/bugs/show_bug.cgi?id=205879
This commit is contained in:
Michael Scharf 2007-10-11 16:30:42 +00:00
parent ed15760bd9
commit ff7683de7d

View file

@ -1,11 +1,11 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others. * Copyright (c) 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Michael Scharf (Wind River) - initial API and implementation * Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas; package org.eclipse.tm.internal.terminal.textcanvas;
@ -28,7 +28,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
private final ITerminalTextDataSnapshot fSnapshot; private final ITerminalTextDataSnapshot fSnapshot;
private int fLines; private int fLines;
private int fSelectionStartLine; private int fSelectionStartLine=-1;
private int fSeletionEndLine; private int fSeletionEndLine;
private int fSelectionStartCoumn; private int fSelectionStartCoumn;
private int fSelectionEndColumn; private int fSelectionEndColumn;
@ -50,7 +50,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
} }
public void removeCellCanvasModelListener(ITextCanvasModelListener listener) { public void removeCellCanvasModelListener(ITextCanvasModelListener listener) {
fListeners.remove(listener); fListeners.remove(listener);
} }
protected void fireCellRangeChanged(int x, int y, int width, int height) { protected void fireCellRangeChanged(int x, int y, int width, int height) {
@ -64,16 +64,16 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
ITextCanvasModelListener listener = (ITextCanvasModelListener) iter.next(); ITextCanvasModelListener listener = (ITextCanvasModelListener) iter.next();
listener.dimensionsChanged(width,height); listener.dimensionsChanged(width,height);
} }
} }
protected void fireTerminalDataChanged() { protected void fireTerminalDataChanged() {
for (Iterator iter = fListeners.iterator(); iter.hasNext();) { for (Iterator iter = fListeners.iterator(); iter.hasNext();) {
ITextCanvasModelListener listener = (ITextCanvasModelListener) iter.next(); ITextCanvasModelListener listener = (ITextCanvasModelListener) iter.next();
listener.terminalDataChanged(); listener.terminalDataChanged();
} }
} }
public ITerminalTextDataReadOnly getTerminalText() { public ITerminalTextDataReadOnly getTerminalText() {
return fSnapshot; return fSnapshot;
} }
@ -101,7 +101,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
int height=fSnapshot.getLastChangedLine()-y+1; int height=fSnapshot.getLastChangedLine()-y+1;
fireCellRangeChanged(0, y, fSnapshot.getWidth(), height); fireCellRangeChanged(0, y, fSnapshot.getWidth(), height);
} }
} finally { } finally {
fInUpdate=false; fInUpdate=false;
} }
@ -183,7 +183,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
public boolean isCursorEnabled() { public boolean isCursorEnabled() {
return fCursorIsEnabled; return fCursorIsEnabled;
} }
public Point getSelectionEnd() { public Point getSelectionEnd() {
if(fSelectionStartLine<0) if(fSelectionStartLine<0)
return null; return null;
@ -255,7 +255,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
else else
return line >= fSelectionStartLine && line <= fSeletionEndLine; return line >= fSelectionStartLine && line <= fSeletionEndLine;
} }
public String getSelectedText() { public String getSelectedText() {
return fCurrentSelection; return fCurrentSelection;
} }
@ -305,8 +305,8 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
} }
// check if the content of the selection has changed. If the content has // check if the content of the selection has changed. If the content has
// changed, clear the selection // changed, clear the selection
if (fCurrentSelection.length()>0 && fSelectionSnapshot != null if (fCurrentSelection.length()>0 && fSelectionSnapshot != null
&& fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine && fSelectionSnapshot.getFirstChangedLine() <= fSeletionEndLine
&& fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) { && fSelectionSnapshot.getLastChangedLine() >= fSelectionStartLine) {
// has the selected text changed? // has the selected text changed?
if (!fCurrentSelection.equals(extractSelectedText())) { if (!fCurrentSelection.equals(extractSelectedText())) {