mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 12:05:21 +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 The user has to drag at least one character to make a selection
This commit is contained in:
parent
74215bde26
commit
e48c0ba278
2 changed files with 55 additions and 33 deletions
|
@ -66,6 +66,7 @@ public interface ITextCanvasModel {
|
|||
|
||||
void setSelectionAnchor(Point anchor);
|
||||
/**
|
||||
* Sets the selection. A negative startLine clears the selection.
|
||||
* @param startLine
|
||||
* @param endLine
|
||||
* @param startColumn
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TextCanvas extends GridCanvas {
|
|||
private boolean fScrollLock;
|
||||
private Point fDraggingStart;
|
||||
private Point fDraggingEnd;
|
||||
private boolean fHasSelection;
|
||||
private ResizeListener fResizeListener;
|
||||
private int fMinColumns=20;
|
||||
private int fMinLines=4;
|
||||
|
@ -84,6 +85,7 @@ public class TextCanvas extends GridCanvas {
|
|||
public void mouseDown(MouseEvent e) {
|
||||
if(e.button==1) { // left button
|
||||
fDraggingStart=screenPointToCell(e.x, e.y);
|
||||
fHasSelection=false;
|
||||
if((e.stateMask&SWT.SHIFT)!=0) {
|
||||
Point anchor=fCellCanvasModel.getSelectionAnchor();
|
||||
if(anchor!=null)
|
||||
|
@ -96,7 +98,11 @@ public class TextCanvas extends GridCanvas {
|
|||
}
|
||||
public void mouseUp(MouseEvent e) {
|
||||
if(e.button==1) { // left button
|
||||
setSelection(screenPointToCell(e.x, e.y));
|
||||
updateHasSelection(e);
|
||||
if(fHasSelection)
|
||||
setSelection(screenPointToCell(e.x, e.y));
|
||||
else
|
||||
fCellCanvasModel.setSelection(-1,-1,-1,-1);
|
||||
fDraggingStart=null;
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +111,7 @@ public class TextCanvas extends GridCanvas {
|
|||
|
||||
public void mouseMove(MouseEvent e) {
|
||||
if (fDraggingStart != null) {
|
||||
updateHasSelection(e);
|
||||
setSelection(screenPointToCell(e.x, e.y));
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +120,20 @@ public class TextCanvas extends GridCanvas {
|
|||
setHorizontalBarVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has to drag the mouse to at least one character to make a selection.
|
||||
* Once this is done, even a one char selection is OK.
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
private void updateHasSelection(MouseEvent e) {
|
||||
if(fDraggingStart!=null) {
|
||||
Point p=screenPointToCell(e.x, e.y);
|
||||
if(fDraggingStart.x!=p.x||fDraggingStart.y!=p.y)
|
||||
fHasSelection=true;
|
||||
}
|
||||
}
|
||||
|
||||
void setSelection(Point p) {
|
||||
if (fDraggingStart !=null && !p.equals(fDraggingEnd)) {
|
||||
fDraggingEnd = p;
|
||||
|
|
Loading…
Add table
Reference in a new issue