Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 130504 Details for
Bug 19825
[misc] Right clicking in an editor window should operate where clicked
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for AbstractTextEdit right-click behaviour against HEAD 1/4/08
rightclickpatch3.5.txt (text/plain), 9.98 KB, created by
Luke Gumbley
on 2009-04-01 00:04:09 EDT
(
hide
)
Description:
patch for AbstractTextEdit right-click behaviour against HEAD 1/4/08
Filename:
MIME Type:
Creator:
Luke Gumbley
Created:
2009-04-01 00:04:09 EDT
Size:
9.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.editors >Index: src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties,v >retrieving revision 1.75 >diff -u -r1.75 TextEditorMessages.properties >--- src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties 15 May 2008 10:35:17 -0000 1.75 >+++ src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties 1 Apr 2009 03:52:22 -0000 >@@ -39,6 +39,12 @@ > TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end > TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow whitespace characters > TextEditorDefaultsPreferencePage_textDragAndDrop= Enable drag and dro&p of text >+ >+TextEditorDefaultsPreferencePage_rightMouseMode= Right-click moves c&aret when: >+TextEditorDefaultsPreferencePage_rightMouseMode_never=Never >+TextEditorDefaultsPreferencePage_rightMouseMode_noSelection=No Selection >+TextEditorDefaultsPreferencePage_rightMouseMode_always=Always >+ > TextEditorPreferencePage_colorsAndFonts_link= More colors can be configured on the <a>Colors and Fonts</a> preference page. > TextEditorPreferencePage_colorsAndFonts_link_tooltip= Show the Colors and Fonts preferences > >Index: src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java,v >retrieving revision 1.47 >diff -u -r1.47 TextEditorDefaultsPreferencePage.java >--- src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java 18 Mar 2009 10:50:30 -0000 1.47 >+++ src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java 1 Apr 2009 03:52:22 -0000 >@@ -449,6 +449,7 @@ > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED)); > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END)); > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED)); >+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractTextEditor.PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE)); > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE)); > >@@ -570,6 +571,14 @@ > Preference textDragAndDrop= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null); > addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0); > >+ label=TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode; >+ Preference rightMouse= new Preference(AbstractTextEditor.PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE, label, null); >+ EnumeratedDomain rightMouseDomain= new EnumeratedDomain(); >+ rightMouseDomain.addValue(new EnumValue(0, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_never)); >+ rightMouseDomain.addValue(new EnumValue(1, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_noSelection)); >+ rightMouseDomain.addValue(new EnumValue(2, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_always)); >+ addCombo(appearanceComposite, rightMouse, rightMouseDomain, 0); >+ > label= TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived; > Preference warnIfDerived= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null); > addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0); >Index: src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java,v >retrieving revision 1.31 >diff -u -r1.31 TextEditorMessages.java >--- src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java 15 May 2008 10:35:17 -0000 1.31 >+++ src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java 1 Apr 2009 03:52:22 -0000 >@@ -131,6 +131,10 @@ > public static String TextEditorDefaultsPreferencePage_warn_if_derived; > public static String TextEditorDefaultsPreferencePage_showWhitespaceCharacters; > public static String TextEditorDefaultsPreferencePage_textDragAndDrop; >+ public static String TextEditorDefaultsPreferencePage_rightMouseMode; >+ public static String TextEditorDefaultsPreferencePage_rightMouseMode_never; >+ public static String TextEditorDefaultsPreferencePage_rightMouseMode_noSelection; >+ public static String TextEditorDefaultsPreferencePage_rightMouseMode_always; > public static String LinkedModeConfigurationBlock_annotationPresentationOptions; > public static String LinkedModeConfigurationBlock_SQUIGGLES; > public static String LinkedModeConfigurationBlock_UNDERLINE; >#P org.eclipse.ui.workbench.texteditor >Index: src/org/eclipse/ui/texteditor/AbstractTextEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java,v >retrieving revision 1.305 >diff -u -r1.305 AbstractTextEditor.java >--- src/org/eclipse/ui/texteditor/AbstractTextEditor.java 19 Mar 2009 16:31:17 -0000 1.305 >+++ src/org/eclipse/ui/texteditor/AbstractTextEditor.java 1 Apr 2009 03:52:25 -0000 >@@ -13,6 +13,7 @@ > * Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 > * 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 > * Tom Eicher (Avaloq Evolution AG) - block selection mode >+ * Luke Gumbley <luke.gumbley@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=19825 > *******************************************************************************/ > package org.eclipse.ui.texteditor; > >@@ -2196,6 +2197,25 @@ > */ > public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$ > >+ /** >+ * A named preference that controls the behaviour of the caret when the right mouse button >+ * is clicked. >+ * <p> >+ * Value is of type <code>Integer</code> and is interpreted as follows: >+ * </p> >+ * <ul> >+ * <li>0: "Never" - No effect (default).</li> >+ * <li>1: "No Selection" - If there is a selection, no effect. If there is no selection, >+ * move the caret to the current mouse position.<li> >+ * <li>2: "Always" - If there is a selection but it was not clicked, or if there is no >+ * selection, clear the selection and move the caret to the current mouse position. >+ * If there is a selection and it was clicked, no effect.</li> >+ * </ul> >+ * >+ * @since 3.5 >+ */ >+ public static final String PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE="mouseRightClickCaretMode"; //$NON-NLS-1$ >+ > /** Menu id for the editor context menu. */ > public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$ > /** Menu id for the ruler context menu. */ >@@ -2576,7 +2596,13 @@ > */ > private KeyBindingSupportForAssistant fKeyBindingSupportForContentAssistant; > >- >+ /** >+ * Current setting of the right mouse button mode. >+ * >+ * @since 3.5 >+ */ >+ private int rightMouseMode=-1; >+ > /** > * Creates a new text editor. If not explicitly set, this editor uses > * a <code>SourceViewerConfiguration</code> to configure its >@@ -3044,6 +3070,7 @@ > } > > public void mouseDown(MouseEvent e) { >+ handleMouseDown(e); > } > > public void mouseUp(MouseEvent e) { >@@ -4541,6 +4568,13 @@ > return; > } > >+ if (PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE.equals(property)) { >+ IPreferenceStore store = getPreferenceStore(); >+ if(store != null) { >+ rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE); >+ } >+ } >+ > } > > /** >@@ -6495,6 +6529,71 @@ > } > > /** >+ * Handles a mouse event on the editor (currently only right-clicks) as per user >+ * preferences. See {@link #PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE}. >+ * >+ * @param e The MouseEvent to be handled. >+ * >+ * @since 3.5 >+ */ >+ protected void handleMouseDown(MouseEvent e) { >+ >+ if(e.button!=3) >+ return; >+ >+ // If the mode is -1 it has not yet been set >+ if(rightMouseMode == -1) { >+ IPreferenceStore store = getPreferenceStore(); >+ if(store != null) { >+ rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE); >+ } >+ } >+ >+ if(rightMouseMode == 0) >+ return; >+ >+ StyledText textWidget = null; >+ ISourceViewer viewer = fSourceViewer; >+ if (viewer != null) >+ textWidget = viewer.getTextWidget(); >+ >+ if(textWidget == null) >+ return; >+ >+ int mouseOffset=-1; >+ try { >+ mouseOffset = textWidget.getOffsetAtLocation(new Point(e.x,e.y)); >+ } >+ catch (IllegalArgumentException ex) { >+ >+ } >+ >+ if(mouseOffset == -1) >+ { >+ int lineIndex=textWidget.getLineIndex(e.y)+1; >+ >+ if(lineIndex >= textWidget.getLineCount()) >+ mouseOffset = textWidget.getCharCount(); >+ else >+ mouseOffset = textWidget.getOffsetAtLine(lineIndex)-1; >+ } >+ >+ if(textWidget.getSelectionCount() > 0) >+ { >+ if(rightMouseMode == 1) >+ return; >+ >+ Point textSelection = textWidget.getSelection(); >+ boolean withinSelection = (mouseOffset >= textSelection.x) && (mouseOffset < textSelection.y); >+ >+ if(withinSelection) >+ return; >+ } >+ >+ textWidget.setCaretOffset(mouseOffset); >+ } >+ >+ /** > * Handles a potential change of the cursor position. > * Subclasses may extend. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19825
:
3148
| 130504