Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java28
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.properties4
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml12
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java215
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties11
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java7
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java7
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java5
12 files changed, 236 insertions, 74 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
index 791596570..dccbacde3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
@@ -43,6 +43,8 @@ TextEditorPreferencePage.appearanceOptions=Appearance co&lor options:
TextEditorPreferencePage.lineNumberForegroundColor=Line number foreground
TextEditorPreferencePage.currentLineHighlighColor=Current line highlight
TextEditorPreferencePage.printMarginColor=Print margin
+TextEditorPreferencePage.accessibility.disableCustomCarets= Use onl&y standard caret
+TextEditorPreferencePage.accessibility.wideCaret= Ena&ble thick caret
TextEditorPreferencePage.empty_input=Empty input
TextEditorPreferencePage.invalid_input=''{0}'' is not a valid input.
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
index e08055eae..63013183a 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
@@ -166,6 +166,8 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_DISABLE_CUSTOM_CARETS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_WIDE_CARET));
OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
@@ -305,6 +307,11 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe
label= TextEditorMessages.getString("TextEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
+ label= TextEditorMessages.getString("TextEditorPreferencePage.accessibility.disableCustomCarets"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_DISABLE_CUSTOM_CARETS, 0);
+
+ label= TextEditorMessages.getString("TextEditorPreferencePage.accessibility.wideCaret"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, 0);
Label l= new Label(appearanceComposite, SWT.LEFT );
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java
index 2c11b3159..e6e19994d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java
@@ -184,7 +184,30 @@ public class ExtendedTextEditorPreferenceConstants {
* @since 3.0
*/
public static final String QUICK_DIFF_CHARACTER_MODE= "quickdiff.characterMode"; //$NON-NLS-1$
-
+
+ /**
+ * A named preference that controls whether custom carets are allowed in the
+ * editor or not.
+ * <p>
+ * Value is of type <code>Boolean</code>. If <code>true</code>, only
+ * the default caret is used in the editor.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_DISABLE_CUSTOM_CARETS= AbstractTextEditor.PREFERENCE_DISABLE_CUSTOM_CARETS;
+
+ /**
+ * A named preference that controls whether carets are drawn wide or not.
+ * <p>
+ * Value is of type <code>Boolean</code>. If <code>true</code>, the caret is
+ * twice as wide as the default caret.
+ * </p>
+ *
+ * @since 3.0
+ */
+ public static final String EDITOR_WIDE_CARET= AbstractTextEditor.PREFERENCE_WIDE_CARET;
+
/**
* Initializes the given preference store with the default values.
*
@@ -213,6 +236,9 @@ public class ExtendedTextEditorPreferenceConstants {
store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_DISABLE_CUSTOM_CARETS, false);
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, true);
+
MarkerAnnotationPreferences.initializeDefaultValues(store);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.properties b/org.eclipse.ui.workbench.texteditor/plugin.properties
index 3629aaaf8..cfa562ad9 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.properties
+++ b/org.eclipse.ui.workbench.texteditor/plugin.properties
@@ -147,8 +147,10 @@ command.textEnd.description = Go to the end of the text
command.textEnd.name = Text End
command.textStart.description = Go to the start of the text
command.textStart.name = Text Start
-command.toggleOverwrite.description = Toggle input mode
+command.toggleOverwrite.description = Toggle overwrite mode
command.toggleOverwrite.name = Toggle Overwrite
+command.toggleInsertMode.description = Toggle insert mode
+command.toggleInsertMode.name = Toggle Insert Mode
command.windowEnd.description = Go to the end of the window
command.windowEnd.name = Window End
command.windowStart.description = Go to the start of the window
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
index ffc3a7e87..01a83e4ca 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor/plugin.xml
@@ -420,6 +420,12 @@
categoryId="org.eclipse.ui.category.edit"
id="org.eclipse.ui.edit.text.contentAssist.contextInformation">
</command>
+ <command
+ name="%command.toggleInsertMode.name"
+ description="%command.toggleInsertMode.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.toggleInsertMode">
+ </command>
<keyBinding
commandId="org.eclipse.ui.edit.text.delete.line"
@@ -777,6 +783,12 @@
keySequence="Command+Shift+Space">
</keyBinding>
<keyBinding
+ commandId="org.eclipse.ui.edit.text.toggleInsertMode"
+ contextId="org.eclipse.ui.textEditorScope"
+ keySequence="Ctrl+Shift+Insert"
+ keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+ <keyBinding
commandId="org.eclipse.ui.edit.text.cut.line.to.beginning"
contextId="org.eclipse.ui.textEditorScope"
keySequence="Alt+0 Ctrl+K"
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 39a0fc6ba..4cb0c10a6 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -174,6 +175,22 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 2.0
*/
private static final String TAG_CONTRIBUTION_TYPE= "editorContribution"; //$NON-NLS-1$
+
+ /**
+ * The caret width for the wide (double) caret.
+ * Value: {@value}
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715
+ * @since 3.0
+ */
+ private static final int WIDE_CARET_WIDTH= 2;
+
+ /**
+ * The caret width for the narrow (single) caret.
+ * Value: {@value}
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715
+ * @since 3.0
+ */
+ private static final int SINGLE_CARET_WIDTH= 1;
/**
* The text input listener.
@@ -189,7 +206,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {}
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { inputChanged= true; }
}
-
+
/**
* Internal element state listener.
*/
@@ -483,8 +500,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
String property= event.getProperty();
- if (getFontPropertyPreferenceKey().equals(property))
+ if (getFontPropertyPreferenceKey().equals(property)) {
initializeViewerFont(fSourceViewer);
+ updateCaret();
+ }
}
}
@@ -793,21 +812,48 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
/**
- * Action to toggle the insert mode.
- * @since 2.1
+ * Action to toggle the insert mode. The action is checked if smart mode is
+ * turned on.
+ *
+ * @since 2.1
*/
- class ToggleInsertModeAction extends TextNavigationAction {
+ class ToggleInsertModeAction extends ResourceAction {
- public ToggleInsertModeAction(StyledText textWidget) {
- super(textWidget, ST.TOGGLE_OVERWRITE);
+ public ToggleInsertModeAction(ResourceBundle bundle, String prefix) {
+ super(bundle, prefix, IAction.AS_CHECK_BOX);
}
-
+
/*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
switchToNextInsertMode();
}
+
+ /*
+ * @see org.eclipse.jface.action.IAction#isChecked()
+ */
+ public boolean isChecked() {
+ return fInsertMode == SMART_INSERT;
+ }
+ }
+
+ /**
+ * Action to toggle the overwrite mode.
+ * @since 3.0
+ */
+ class ToggleOverwriteModeAction extends ResourceAction {
+
+ public ToggleOverwriteModeAction(ResourceBundle bundle, String prefix) {
+ super(bundle, prefix);
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ toggleOverwriteMode();
+ }
}
/**
@@ -1165,6 +1211,18 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 2.1
*/
public final static String PREFERENCE_NAVIGATION_SMART_HOME_END= "AbstractTextEditor.Navigation.SmartHomeEnd"; //$NON-NLS-1$
+ /**
+ * Key used to look up the custom caret preference.
+ * Value: {@value}
+ * @since 3.0
+ */
+ public final static String PREFERENCE_DISABLE_CUSTOM_CARETS= "AbstractTextEditor.Accessibility.DisableCustomCarets"; //$NON-NLS-1$
+ /**
+ * Key used to look up the caret width preference.
+ * Value: {@value}
+ * @since 3.0
+ */
+ public final static String PREFERENCE_WIDE_CARET= "AbstractTextEditor.Accessibility.WideCaret"; //$NON-NLS-1$
/** Menu id for the editor context menu. */
@@ -1433,6 +1491,16 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 2.1
*/
private String[] fKeyBindingScopes;
+ /**
+ * Whether the overwrite mode can be turned on.
+ * @since 3.0
+ */
+ private boolean fIsOverwriteModeEnabled= true;
+ /**
+ * Whether the overwrite mode is currently on.
+ * @since 3.0
+ */
+ private boolean fIsOverwriting= false;
/**
* The editor's insert mode.
* @since 3.0
@@ -1459,7 +1527,6 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
private Caret fDefaultCaret;
-
/**
* Creates a new text editor. If not explicitly set, this editor uses
* a <code>SourceViewerConfiguration</code> to configure its
@@ -2399,7 +2466,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (fDefaultCaret == null)
fDefaultCaret= getSourceViewer().getTextWidget().getCaret();
- if (getInsertMode() == OVERWRITE)
+ if (fIsOverwriting)
fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE);
handleInsertModeChanged();
}
@@ -2576,6 +2643,15 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
disposeNonDefaultCaret();
+
+ /* The following code exists to dispose a custom caret set e.g. by the
+ * source viewer implementation. Note that StyledText does not set a
+ * caret by default, so fDefaultCaret will usually be null.
+ *
+ * A source viewer that sets a custom caret on the widget does not
+ * need to dispose it, or will run into an error_widget_disposed,
+ * respectively.
+ */
if (fDefaultCaret != null && !fDefaultCaret.isDisposed()) {
try {
fDefaultCaret.dispose();
@@ -2777,6 +2853,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
initializeViewerColors(fSourceViewer);
} else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) {
initializeFindScopeColor(fSourceViewer);
+ } else if (PREFERENCE_DISABLE_CUSTOM_CARETS.equals(property)) {
+ updateCaret();
+ } else if (PREFERENCE_WIDE_CARET.equals(property)) {
+ updateCaret();
}
if (affectsTextPresentation(event))
@@ -3543,7 +3623,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
setAction(entry.getActionId(), action);
}
- action= new ToggleInsertModeAction(textWidget);
+ action= new ToggleOverwriteModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleOverwriteMode."); //$NON-NLS-1$
action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE);
setAction(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, action);
textWidget.setKeyBinding(SWT.INSERT, SWT.NULL);
@@ -3784,6 +3864,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE);
setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action);
+ action = new ToggleInsertModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleInsertMode."); //$NON-NLS-1$
+ action.setHelpContextId(IAbstractTextEditorHelpContextIds.TOGGLE_INSERT_MODE_ACTION);
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
+ setAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE, action);
markAsContentDependentAction(ITextEditorActionConstants.UNDO, true);
markAsContentDependentAction(ITextEditorActionConstants.REDO, true);
@@ -4231,11 +4315,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*
* @return <code>true</code> if in insert mode, <code>false</code> for overwrite mode
* @since 2.0
- * @deprecated
*/
protected boolean isInInsertMode() {
- InsertMode mode= getInsertMode();
- return mode == INSERT || mode == SMART_INSERT;
+ return !fIsOverwriting;
}
/*
@@ -4253,14 +4335,8 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (!legalModes.contains(newMode))
throw new IllegalArgumentException();
- InsertMode oldMode= fInsertMode;
fInsertMode= newMode;
- if (getSourceViewer() != null && (oldMode == OVERWRITE || newMode == OVERWRITE)) {
- StyledText styledText= getSourceViewer().getTextWidget();
- styledText.invokeAction(ST.TOGGLE_OVERWRITE);
- }
-
handleInsertModeChanged();
}
@@ -4273,7 +4349,6 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
protected List getLegalInsertModes() {
if (fLegalInsertModes == null) {
fLegalInsertModes= new ArrayList();
- fLegalInsertModes.add(OVERWRITE);
fLegalInsertModes.add(INSERT);
fLegalInsertModes.add(SMART_INSERT);
}
@@ -4295,7 +4370,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
InsertMode newMode= (InsertMode) legalModes.get(i);
setInsertMode(newMode);
}
-
+
+ private void toggleOverwriteMode() {
+ if (fIsOverwriteModeEnabled) {
+ fIsOverwriting= !fIsOverwriting;
+ fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE);
+ handleInsertModeChanged();
+ }
+ }
/**
* Configures the given insert mode as legal or inlegal. This call is ignored if the set of legal
@@ -4315,67 +4397,62 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
legalModes.remove(mode);
}
}
+
+ protected void enableOverwriteMode(boolean enable) {
+ if (fIsOverwriting && !enable)
+ toggleOverwriteMode();
+ fIsOverwriteModeEnabled= enable;
+ }
- private Image createOverwriteModeCaretImage(StyledText styledText) {
-
- if (!"win32".equals(SWT.getPlatform())) //$NON-NLS-1$
- return null;
-
- PaletteData caretPalette= new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
- ImageData imageData = new ImageData(100, styledText.getLineHeight(), 1, caretPalette);
- Display display = styledText.getDisplay();
- Image blockImage= new Image(display, imageData);
- GC gc = new GC (blockImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.setFont(styledText.getFont());
- Point extent= gc.stringExtent("l"); //$NON-NLS-1$
- gc.fillRectangle(0, 0,extent.x, imageData.height -1);
- gc.dispose();
+ private Caret createOverwriteCaret(StyledText styledText) {
+ Caret caret= new Caret(styledText, SWT.NULL);
+ GC gc= new GC(styledText);
+ // XXX this overwrite box is not proportiona-font aware
+ // take 'a' as a medium sized character
+ Point charSize= gc.stringExtent("a"); //$NON-NLS-1$
+ caret.setSize(charSize.x, caret.getSize().y);
- return blockImage;
+ return caret;
}
- private Caret createOverwriteCaret(StyledText styledText) {
+ private Caret createInsertCaret(StyledText styledText) {
Caret caret= new Caret(styledText, SWT.NULL);
- Image image= createOverwriteModeCaretImage(styledText);
- if (image != null)
- caret.setImage(image);
- else
- caret.setSize(1, caret.getSize().y);
-
+ int width= getPreferenceStore().getBoolean(PREFERENCE_WIDE_CARET) ? WIDE_CARET_WIDTH : SINGLE_CARET_WIDTH;
+ caret.setSize(width, caret.getSize().y);
return caret;
}
- private Image createSmartInsertModeCaretImage(StyledText styledText) {
-
- if (!"win32".equals(SWT.getPlatform())) //$NON-NLS-1$
- return null;
+ private Image createRawInsertModeCaretImage(StyledText styledText) {
PaletteData caretPalette= new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
- ImageData imageData = new ImageData(4, styledText.getLineHeight(), 1, caretPalette);
+ int width= getPreferenceStore().getBoolean(PREFERENCE_WIDE_CARET) ? WIDE_CARET_WIDTH : SINGLE_CARET_WIDTH;
+ int widthOffset= width - 1;
+ ImageData imageData = new ImageData(4 + widthOffset, styledText.getLineHeight(), 1, caretPalette);
Display display = styledText.getDisplay();
Image bracketImage= new Image(display, imageData);
GC gc = new GC (bracketImage);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.drawLine(0, 0, imageData.width -1, 0);
- gc.drawLine(0, 0, 0, imageData.height -1);
- gc.drawLine(0, imageData.height -1, imageData.width -1, imageData.height -1);
+ gc.setLineWidth(width);
+ gc.drawLine(0, widthOffset, imageData.width, widthOffset);
+ gc.drawLine(widthOffset, 0, widthOffset, imageData.height - 1);
+ gc.drawLine(0, imageData.height - 1, imageData.width - 1, imageData.height - 1);
gc.dispose();
return bracketImage;
}
- private Caret createSmartInsertModeCaret(StyledText styledText) {
+ private Caret createRawInsertModeCaret(StyledText styledText) {
Caret caret= new Caret(styledText, SWT.NULL);
- Image image= createSmartInsertModeCaretImage(styledText);
+ int width= getPreferenceStore().getBoolean(PREFERENCE_WIDE_CARET) ? WIDE_CARET_WIDTH : SINGLE_CARET_WIDTH;
+ Image image= createRawInsertModeCaretImage(styledText);
if (image != null)
caret.setImage(image);
else
- caret.setSize(1, caret.getSize().y);
+ caret.setSize(width, caret.getSize().y);
return caret;
}
-
+
private void updateCaret() {
if (getSourceViewer() == null)
@@ -4388,15 +4465,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
styledText.setCaret(null);
disposeNonDefaultCaret();
- if (INSERT == mode) {
- styledText.setCaret(fDefaultCaret);
- return;
- }
-
- if (OVERWRITE == mode)
+ if (getPreferenceStore().getBoolean(PREFERENCE_DISABLE_CUSTOM_CARETS))
+ fNonDefaultCaret= createInsertCaret(styledText);
+ else if (fIsOverwriting)
fNonDefaultCaret= createOverwriteCaret(styledText);
else if (SMART_INSERT == mode)
- fNonDefaultCaret= createSmartInsertModeCaret(styledText);
+ fNonDefaultCaret= createInsertCaret(styledText);
+ else if (INSERT == mode)
+ fNonDefaultCaret= createRawInsertModeCaret(styledText);
styledText.setCaret(fNonDefaultCaret);
if (fNonDefaultCaret != null)
@@ -4426,10 +4502,19 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 2.0
*/
protected void handleInsertModeChanged() {
+ updateInsertModeAction();
updateCaret();
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE);
}
+ private void updateInsertModeAction() {
+ IAction action= getAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE);
+ if (action != null) {
+ action.setEnabled(!fIsOverwriting);
+ action.setChecked(fInsertMode == SMART_INSERT);
+ }
+ }
+
/**
* Handles a potential change of the cursor position.
* Subclasses may extend.
@@ -4462,7 +4547,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
text= isEditorInputReadOnly() ? fReadOnlyLabel : fWritableLabel;
else if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE.equals(category)) {
InsertMode mode= getInsertMode();
- if (OVERWRITE == mode)
+ if (fIsOverwriting)
text= fOverwriteModeLabel;
else if (INSERT == mode)
text= fInsertModeLabel;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties
index 9051a9bba..2c9241a4c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties
@@ -159,6 +159,11 @@ Editor.SwapMark.tooltip=Swap Mark
Editor.SwapMark=
Editor.SwapMark.description=Swap Mark
+Editor.ToggleInsertMode.label=Sma&rt Insert Mode
+Editor.ToggleInsertMode.tooltip=Toggle Smart Insert Mode
+Editor.ToggleInsertMode.image=
+Editor.ToggleInsertMode.description= Toggles smart insert mode
+
Editor.FindReplace.label=&Find/Replace...
Editor.FindReplace.tooltip=Find/Replace
Editor.FindReplace.image=
@@ -264,6 +269,12 @@ Editor.statusline.mode.smartinsert.label=Smart Insert
Editor.statusline.position.pattern={0} : {1}
Editor.statusline.error.label=?
+## Overwrite action #
+Editor.ToggleOverwriteMode.label= Toggle Overwrite Mode
+Editor.ToggleOverwriteMode.tooltip= Toggle Overwrite Mode
+Editor.ToggleOverwriteMode.iamge=
+Editor.ToggleOverwriteMode.description= Toggles overwrite / insert behaviour
+
## Others ##
WorkbenchChainedTextFontFieldEditor.defaultWorkbenchTextFont=<Using Workbench Text Font>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
index 6d7c7b846..54e1a33ef 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java
@@ -295,4 +295,11 @@ public interface IAbstractTextEditorHelpContextIds {
* @since 3.0
*/
public static final String SMART_ENTER_ACTION= PREFIX + "smart_enter" + ACTION_POSTFIX; //$NON-NLS-1$;
+
+ /**
+ * Help context id for the smart insert mode toggle action.
+ * Value: <code>"org.eclipse.ui.toggle_insert_mode_action_context"</code>
+ * @since 3.0
+ */
+ public static final String TOGGLE_INSERT_MODE_ACTION= PREFIX + "toggle_insert_mode" + ACTION_POSTFIX; //$NON-NLS-1$;;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
index 775c26905..12709e58f 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java
@@ -422,4 +422,12 @@ public interface ITextEditorActionConstants extends IWorkbenchActionConstants {
* Value: <code>"ITextEditorActionConstants.REVERT"</code>
*/
static final String REVERT_TO_SAVED= REVERT;
+
+ /**
+ * Name of the action for toggling the smart insert mode.
+ * Value: <code>"ToggleInsertMode"</code>
+ *
+ * @since 3.0
+ */
+ static final String TOGGLE_INSERT_MODE= "TOGGLE_INSERT_MODE"; //$NON-NLS-1$
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
index 7efc0c336..9b32e9bb2 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java
@@ -440,4 +440,11 @@ public interface ITextEditorActionDefinitionIds extends IWorkbenchActionDefiniti
* @since 2.1
*/
public static final String CONTENT_ASSIST_CONTEXT_INFORMATION= "org.eclipse.ui.edit.text.contentAssist.contextInformation"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the edit -> smart insert mode action
+ * Value: <code>"org.eclipse.ui.edit.text.toggleInsertMode"</code>).
+ * @since 3.0
+ */
+ public static final String TOGGLE_INSERT_MODE= "org.eclipse.ui.edit.text.toggleInsertMode"; //$NON-NLS-1$
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java
index 520c2382d..68ee6624e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java
@@ -35,10 +35,6 @@ public interface ITextEditorExtension3 {
*/
final static InsertMode INSERT= new InsertMode();
/**
- * Represents the non-smart overwrite mode.
- */
- final static InsertMode OVERWRITE= new InsertMode();
- /**
* Represents the smart insert mode.
*/
final static InsertMode SMART_INSERT= new InsertMode();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
index dfd005df0..961d52bae 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
@@ -20,17 +20,16 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
/**
- * An <code>IAction</code> wrapper for text widget navigational and selection actions.
+ * An <code>Action</code> wrapper for text widget navigational and selection actions.
* @since 2.0
*/
-public class TextNavigationAction extends Action implements IAction {
+public class TextNavigationAction extends Action {
/** The text widget */
private StyledText fTextWidget;

Back to the top