Lines 13-18
Link Here
|
13 |
* Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 |
13 |
* Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 |
14 |
* Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043 |
14 |
* Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043 |
15 |
* Tom Eicher (Avaloq Evolution AG) - block selection mode |
15 |
* Tom Eicher (Avaloq Evolution AG) - block selection mode |
|
|
16 |
* Luke Gumbley <luke.gumbley@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=19825 |
16 |
*******************************************************************************/ |
17 |
*******************************************************************************/ |
17 |
package org.eclipse.ui.texteditor; |
18 |
package org.eclipse.ui.texteditor; |
18 |
|
19 |
|
Lines 2196-2201
Link Here
|
2196 |
*/ |
2197 |
*/ |
2197 |
public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$ |
2198 |
public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$ |
2198 |
|
2199 |
|
|
|
2200 |
/** |
2201 |
* A named preference that controls the behaviour of the caret when the right mouse button |
2202 |
* is clicked. |
2203 |
* <p> |
2204 |
* Value is of type <code>Integer</code> and is interpreted as follows: |
2205 |
* </p> |
2206 |
* <ul> |
2207 |
* <li>0: "Never" - No effect (default).</li> |
2208 |
* <li>1: "No Selection" - If there is a selection, no effect. If there is no selection, |
2209 |
* move the caret to the current mouse position.<li> |
2210 |
* <li>2: "Always" - If there is a selection but it was not clicked, or if there is no |
2211 |
* selection, clear the selection and move the caret to the current mouse position. |
2212 |
* If there is a selection and it was clicked, no effect.</li> |
2213 |
* </ul> |
2214 |
* |
2215 |
* @since 3.5 |
2216 |
*/ |
2217 |
public static final String PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE="mouseRightClickCaretMode"; //$NON-NLS-1$ |
2218 |
|
2199 |
/** Menu id for the editor context menu. */ |
2219 |
/** Menu id for the editor context menu. */ |
2200 |
public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$ |
2220 |
public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$ |
2201 |
/** Menu id for the ruler context menu. */ |
2221 |
/** Menu id for the ruler context menu. */ |
Lines 2576-2582
Link Here
|
2576 |
*/ |
2596 |
*/ |
2577 |
private KeyBindingSupportForAssistant fKeyBindingSupportForContentAssistant; |
2597 |
private KeyBindingSupportForAssistant fKeyBindingSupportForContentAssistant; |
2578 |
|
2598 |
|
2579 |
|
2599 |
/** |
|
|
2600 |
* Current setting of the right mouse button mode. |
2601 |
* |
2602 |
* @since 3.5 |
2603 |
*/ |
2604 |
private int rightMouseMode=-1; |
2605 |
|
2580 |
/** |
2606 |
/** |
2581 |
* Creates a new text editor. If not explicitly set, this editor uses |
2607 |
* Creates a new text editor. If not explicitly set, this editor uses |
2582 |
* a <code>SourceViewerConfiguration</code> to configure its |
2608 |
* a <code>SourceViewerConfiguration</code> to configure its |
Lines 3044-3049
Link Here
|
3044 |
} |
3070 |
} |
3045 |
|
3071 |
|
3046 |
public void mouseDown(MouseEvent e) { |
3072 |
public void mouseDown(MouseEvent e) { |
|
|
3073 |
handleMouseDown(e); |
3047 |
} |
3074 |
} |
3048 |
|
3075 |
|
3049 |
public void mouseUp(MouseEvent e) { |
3076 |
public void mouseUp(MouseEvent e) { |
Lines 4541-4546
Link Here
|
4541 |
return; |
4568 |
return; |
4542 |
} |
4569 |
} |
4543 |
|
4570 |
|
|
|
4571 |
if (PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE.equals(property)) { |
4572 |
IPreferenceStore store = getPreferenceStore(); |
4573 |
if(store != null) { |
4574 |
rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE); |
4575 |
} |
4576 |
} |
4577 |
|
4544 |
} |
4578 |
} |
4545 |
|
4579 |
|
4546 |
/** |
4580 |
/** |
Lines 6495-6500
Link Here
|
6495 |
} |
6529 |
} |
6496 |
|
6530 |
|
6497 |
/** |
6531 |
/** |
|
|
6532 |
* Handles a mouse event on the editor (currently only right-clicks) as per user |
6533 |
* preferences. See {@link #PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE}. |
6534 |
* |
6535 |
* @param e The MouseEvent to be handled. |
6536 |
* |
6537 |
* @since 3.5 |
6538 |
*/ |
6539 |
protected void handleMouseDown(MouseEvent e) { |
6540 |
|
6541 |
if(e.button!=3) |
6542 |
return; |
6543 |
|
6544 |
// If the mode is -1 it has not yet been set |
6545 |
if(rightMouseMode == -1) { |
6546 |
IPreferenceStore store = getPreferenceStore(); |
6547 |
if(store != null) { |
6548 |
rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE); |
6549 |
} |
6550 |
} |
6551 |
|
6552 |
if(rightMouseMode == 0) |
6553 |
return; |
6554 |
|
6555 |
StyledText textWidget = null; |
6556 |
ISourceViewer viewer = fSourceViewer; |
6557 |
if (viewer != null) |
6558 |
textWidget = viewer.getTextWidget(); |
6559 |
|
6560 |
if(textWidget == null) |
6561 |
return; |
6562 |
|
6563 |
int mouseOffset=-1; |
6564 |
try { |
6565 |
mouseOffset = textWidget.getOffsetAtLocation(new Point(e.x,e.y)); |
6566 |
} |
6567 |
catch (IllegalArgumentException ex) { |
6568 |
|
6569 |
} |
6570 |
|
6571 |
if(mouseOffset == -1) |
6572 |
{ |
6573 |
int lineIndex=textWidget.getLineIndex(e.y)+1; |
6574 |
|
6575 |
if(lineIndex >= textWidget.getLineCount()) |
6576 |
mouseOffset = textWidget.getCharCount(); |
6577 |
else |
6578 |
mouseOffset = textWidget.getOffsetAtLine(lineIndex)-1; |
6579 |
} |
6580 |
|
6581 |
if(textWidget.getSelectionCount() > 0) |
6582 |
{ |
6583 |
if(rightMouseMode == 1) |
6584 |
return; |
6585 |
|
6586 |
Point textSelection = textWidget.getSelection(); |
6587 |
boolean withinSelection = (mouseOffset >= textSelection.x) && (mouseOffset < textSelection.y); |
6588 |
|
6589 |
if(withinSelection) |
6590 |
return; |
6591 |
} |
6592 |
|
6593 |
textWidget.setCaretOffset(mouseOffset); |
6594 |
} |
6595 |
|
6596 |
/** |
6498 |
* Handles a potential change of the cursor position. |
6597 |
* Handles a potential change of the cursor position. |
6499 |
* Subclasses may extend. |
6598 |
* Subclasses may extend. |
6500 |
* |
6599 |
* |