IDEADEV-574. EditorColors.BACKGROUND removed as conflicting with HighlighterColors.TEXT

This commit is contained in:
Maxim Shafirov
2005-03-17 21:32:11 +03:00
parent 11421664f0
commit b48b3797ca
11 changed files with 68 additions and 32 deletions
@@ -10,7 +10,6 @@ public interface EditorColors {
ColorKey RIGHT_MARGIN_COLOR = ColorKey.createColorKey("RIGHT_MARGIN_COLOR");
ColorKey LINE_NUMBERS_COLOR = ColorKey.createColorKey("LINE_NUMBERS_COLOR");
ColorKey ANNOTATIONS_COLOR = ColorKey.createColorKey("ANNOTATIONS_COLOR");
ColorKey BACKGROUND_COLOR = ColorKey.createColorKey("BACKGROUND");
ColorKey READONLY_BACKGROUND_COLOR = ColorKey.createColorKey("READONLY_BACKGROUND");
ColorKey READONLY_FRAGMENT_BACKGROUND_COLOR = ColorKey.createColorKey("READONLY_FRAGMENT_BACKGROUND");
ColorKey WHITESPACES_COLOR = ColorKey.createColorKey("WHITESPACES");
@@ -19,6 +19,9 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable {
TextAttributes getAttributes(TextAttributesKey key);
void setAttributes(TextAttributesKey key, TextAttributes attributes);
Color getDefaultBackground();
Color getDefaultForeground();
Color getColor(ColorKey key);
void setColor(ColorKey key, Color color);
+1 -2
View File
@@ -9,7 +9,6 @@
<option name="SELECTION_BACKGROUND" value="526da5"/>
<option name="CARET_ROW_COLOR" value="ffffd7"/>
<option name="METHOD_SEPARATORS_COLOR" value="c0c0c0"/>
<option name="BACKGROUND" value="ffffff"/>
<option name="WHITESPACES" value="c5c5c5"/>
<option name="SELECTION_FOREGROUND" value="ffffff"/>
<option name="LINE_NUMBERS_COLOR" value="800000"/>
@@ -568,7 +567,7 @@
<option name="TEXT">
<value>
<option name="FOREGROUND" value="0"/>
<option name="BACKGROUND"/>
<option name="BACKGROUND" value="ffffff"/>
<option name="EFFECT_COLOR"/>
<option name="FONT_TYPE" value="0"/>
</value>
@@ -7,7 +7,6 @@ import com.intellij.application.options.colors.highlighting.HighlightData;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.event.CaretEvent;
import com.intellij.openapi.editor.event.CaretListener;
@@ -46,14 +45,7 @@ public class ClickNavigator {
CaretListener listener = new CaretListener() {
public void caretPositionChanged(CaretEvent e) {
int offset = view.logicalPositionToOffset(e.getNewPosition());
CharSequence text = view.getDocument().getCharsSequence();
if (isWhiteSpace(offset, text)) {
setSelectedItem(EditorColors.BACKGROUND_COLOR.getExternalName(), true);
}
else {
setSelectedItem(HighlighterColors.TEXT.getExternalName(), true);
}
setSelectedItem(HighlighterColors.TEXT.getExternalName(), true);
}
};
view.getCaretModel().addCaretListener(listener);
@@ -5,7 +5,6 @@ import com.intellij.codeInsight.daemon.impl.LineMarkerInfo;
import com.intellij.ide.highlighter.HighlighterFactory;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorHighlighter;
@@ -325,7 +324,7 @@ class HTMLTextPainter {
writer.write("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\r\n");
writer.write("<META NAME=\"KEYWORDS\" CONTENT=\"IntelliJ_IDEA_Html\">\r\n");
writer.write("</HEAD>\r\n");
Color color = scheme.getColor(EditorColors.BACKGROUND_COLOR);
Color color = scheme.getDefaultBackground();
if (color==null) color = Color.gray;
writer.write("<BODY BGCOLOR=\"#" + Integer.toString(color.getRGB() & 0xFFFFFF, 16) + "\">\r\n");
writer.write("<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH=\"100%\" BGCOLOR=\"#C0C0C0\" >\r\n");
@@ -219,7 +219,7 @@ public class EditorFragmentComponent extends JPanel {
EditorColorsScheme colorsScheme = editor.getColorsScheme();
Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR);
if (color == null){
color = colorsScheme.getColor(EditorColors.BACKGROUND_COLOR);
color = colorsScheme.getDefaultBackground();
}
return color;
}
@@ -380,12 +380,10 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, DataPr
editorSettings.setAdditionalPageAtBottom(false);
final EditorColorsScheme scheme = editor.getColorsScheme();
scheme.setColor(EditorColors.BACKGROUND_COLOR, BACKGROUND_COLOR);
scheme.setColor(EditorColors.READONLY_BACKGROUND_COLOR, BACKGROUND_COLOR);
editor.setBackgroundColor(BACKGROUND_COLOR);
scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
scheme.setColor(EditorColors.RIGHT_MARGIN_COLOR, null);
editor.addEditorMouseListener(new EditorPopupHandler(){
public void invokePopup(final EditorMouseEvent event) {
final MouseEvent mouseEvent = event.getMouseEvent();
@@ -3,6 +3,7 @@
*/
package com.intellij.openapi.editor.colors.impl;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorFontType;
@@ -40,6 +41,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
protected static final String EDITOR_FONT_NAME = "EDITOR_FONT_NAME";
protected static final String SCHEME_NAME = "SCHEME_NAME";
protected DefaultColorSchemesManager myDefaultColorSchemesManager;
private Color myDeprecatedBackgroundColor = null;
protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) {
myParentScheme = parentScheme;
@@ -56,6 +58,16 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
public abstract void setColor(ColorKey key, Color color);
public abstract Color getColor(ColorKey key);
public Color getDefaultBackground() {
final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor();
return c != null ? c : Color.white;
}
public Color getDefaultForeground() {
final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor();
return c != null ? c : Color.black;
}
public String getName() {
return mySchemeName;
}
@@ -145,6 +157,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
}
private void readScheme(Element node) throws InvalidDataException {
myDeprecatedBackgroundColor = null;
if ("scheme".equals(node.getName())) {
setName(node.getAttributeValue("name"));
myVersion = Integer.parseInt(node.getAttributeValue("version", "0"));
@@ -165,6 +178,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
readAttributes(childNode);
}
}
if (myDeprecatedBackgroundColor != null) {
final TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT);
textAttributes.setBackgroundColor(myDeprecatedBackgroundColor);
}
initFonts();
}
}
@@ -183,18 +202,28 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
private void readColors(Element childNode) {
for (Iterator iterator = childNode.getChildren("option").iterator(); iterator.hasNext();) {
Element colorElement = (Element)iterator.next();
Color valueColor = readColorValue(colorElement);
final String colorName = colorElement.getAttributeValue("name");
if ("BACKGROUND".equals(colorName)) {
// This setting has been deprecated to usages of HighlighterColors.TEXT attributes.
myDeprecatedBackgroundColor = valueColor;
}
ColorKey name = ColorKey.find(colorElement.getAttributeValue("name"));
String value = colorElement.getAttributeValue("value");
if (value == null || "".equals(value.trim())) {
myColorsMap.put(name, null);
} else {
try {
myColorsMap.put(name, new Color(Integer.parseInt(value, 16)));
} catch (NumberFormatException e) {
}
ColorKey name = ColorKey.find(colorName);
myColorsMap.put(name, valueColor);
}
}
private Color readColorValue(final Element colorElement) {
String value = colorElement.getAttributeValue("value");
Color valueColor = null;
if (value != null && value.trim().length() > 0) {
try {
valueColor = new Color(Integer.parseInt(value, 16));
} catch (NumberFormatException e) {
}
}
return valueColor;
}
private void readSettings(Element childNode) {
@@ -1033,11 +1033,14 @@ public class EditorImpl implements EditorEx {
myForcedBackground = null;
}
public Color getForegroundColor() {
return myScheme.getDefaultForeground();
}
public Color getBackroundColor() {
if (myForcedBackground != null) return myForcedBackground;
Color color = myScheme.getColor(EditorColors.BACKGROUND_COLOR);
if (color == null) color = Color.white;
Color color = myScheme.getDefaultBackground();
if (myDocument.isWritable()) {
return color;
}
@@ -3546,6 +3549,14 @@ public class EditorImpl implements EditorEx {
myOwnAttributes.put(key, attributes);
}
public Color getDefaultBackground() {
return getGlobal().getDefaultBackground();
}
public Color getDefaultForeground() {
return getGlobal().getDefaultForeground();
}
public Color getColor(ColorKey key) {
if (myOwnColors.containsKey(key)) return myOwnColors.get(key);
return getGlobal().getColor(key);
@@ -42,6 +42,8 @@ public class IterationState {
private TextAttributes myFoldTextAttributes = null;
private TextAttributes mySelectionAttributes = null;
private TextAttributes myCaretRowAttributes = null;
private Color myDefaultBackground = null;
private Color myDefaultForeground = null;
private int myCaretRowStart;
private int myCaretRowEnd;
private ArrayList<TextAttributes> myCachedAttributesList;
@@ -84,6 +86,8 @@ public class IterationState {
CaretModelImpl caretModel = (CaretModelImpl)editor.getCaretModel();
myCaretRowAttributes = editor.isRendererMode() ? null : caretModel.getTextAttributes();
myDefaultBackground = editor.getBackroundColor();
myDefaultForeground = editor.getForegroundColor();
myCurrentHighlighters = new ArrayList<RangeHighlighterImpl>();
@@ -425,11 +429,11 @@ public class IterationState {
TextAttributes textAttributes = myCachedAttributesList.get(i);
if (fore == null) {
fore = textAttributes.getForegroundColor();
fore = ifDiffers(textAttributes.getForegroundColor(), myDefaultForeground);
}
if (back == null) {
back = textAttributes.getBackgroundColor();
back = ifDiffers(textAttributes.getBackgroundColor(), myDefaultBackground);
}
if (fontType == 0) {
@@ -449,6 +453,9 @@ public class IterationState {
myMergedAttributes.setEffectType(effectType);
}
private Color ifDiffers(final Color c1, final Color c2) {
return c1 == c2 ? null : c1;
}
public boolean atEnd() {
return myStartOffset >= myEnd;
@@ -58,7 +58,6 @@ public class GeneralColorsPage implements ColorSettingsPage {
};
private static final ColorDescriptor[] COLOR_DESCRIPTORS = new ColorDescriptor[] {
new ColorDescriptor("Background", EditorColors.BACKGROUND_COLOR, ColorDescriptor.Kind.BACKGROUND),
new ColorDescriptor("Background in readonly files", EditorColors.READONLY_BACKGROUND_COLOR, ColorDescriptor.Kind.BACKGROUND),
new ColorDescriptor("Readonly fragment background", EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, ColorDescriptor.Kind.BACKGROUND),
new ColorDescriptor("Gutter background", EditorColors.LEFT_GUTTER_BACKGROUND, ColorDescriptor.Kind.BACKGROUND),