Search in sources :

Example 11 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.

the class UIUtil method createEditor.

@NotNull
public static Editor createEditor(@NotNull Document doc, final Project project, boolean editable, boolean addToolTipForVariableHandler, @Nullable TemplateContextType contextType) {
    final Editor editor = editable ? EditorFactory.getInstance().createEditor(doc, project) : EditorFactory.getInstance().createViewer(doc, project);
    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setVirtualSpace(false);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineNumbersShown(false);
    editorSettings.setFoldingOutlineShown(false);
    editorSettings.setCaretRowShown(false);
    if (!editable) {
        final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
        Color c = globalScheme.getColor(EditorColors.READONLY_BACKGROUND_COLOR);
        if (c == null) {
            c = globalScheme.getDefaultBackground();
        }
        ((EditorEx) editor).setBackgroundColor(c);
    } else {
        ((EditorEx) editor).setEmbeddedIntoDialogWrapper(true);
    }
    TemplateEditorUtil.setHighlighter(editor, contextType);
    if (addToolTipForVariableHandler) {
        SubstitutionShortInfoHandler handler = new SubstitutionShortInfoHandler(editor);
        editor.addEditorMouseMotionListener(handler);
        editor.getDocument().addDocumentListener(handler);
        editor.getCaretModel().addCaretListener(handler);
        editor.putUserData(LISTENER_KEY, handler);
    }
    return editor;
}
Also used : EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.

the class EditorNotificationPanel method getBackground.

@Override
public Color getBackground() {
    EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
    if (myBackgroundColor != null)
        return myBackgroundColor;
    if (myBackgroundColorKey != null) {
        Color color = globalScheme.getColor(myBackgroundColorKey);
        if (color != null)
            return color;
    }
    Color color = globalScheme.getColor(EditorColors.NOTIFICATION_BACKGROUND);
    return color != null ? color : UIUtil.getToolTipBackground();
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 13 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.

the class DarculaInstaller method performImpl.

private static void performImpl(boolean dark) {
    JBColor.setDark(dark);
    IconLoader.setUseDarkIcons(dark);
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    EditorColorsScheme current = colorsManager.getGlobalScheme();
    if (dark != ColorUtil.isDark(current.getDefaultBackground())) {
        String targetScheme = dark ? DarculaLaf.NAME : EditorColorsScheme.DEFAULT_SCHEME_NAME;
        PropertiesComponent properties = PropertiesComponent.getInstance();
        String savedEditorThemeKey = dark ? DARCULA_EDITOR_THEME_KEY : DEFAULT_EDITOR_THEME_KEY;
        String toSavedEditorThemeKey = dark ? DEFAULT_EDITOR_THEME_KEY : DARCULA_EDITOR_THEME_KEY;
        String themeName = properties.getValue(savedEditorThemeKey);
        if (themeName != null && colorsManager.getScheme(themeName) != null) {
            targetScheme = themeName;
        }
        properties.setValue(toSavedEditorThemeKey, current.getName(), dark ? EditorColorsScheme.DEFAULT_SCHEME_NAME : DarculaLaf.NAME);
        EditorColorsScheme scheme = colorsManager.getScheme(targetScheme);
        if (scheme != null) {
            colorsManager.setGlobalScheme(scheme);
        }
    }
    update();
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 14 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.

the class SelectionModelImpl method getTextAttributes.

@Override
public TextAttributes getTextAttributes() {
    if (myTextAttributes == null) {
        TextAttributes textAttributes = new TextAttributes();
        EditorColorsScheme scheme = myEditor.getColorsScheme();
        textAttributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
        textAttributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
        myTextAttributes = textAttributes;
    }
    return myTextAttributes;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 15 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.

the class EditorUtil method getEditorFont.

public static Font getEditorFont() {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    int size = UISettings.getInstance().getPresentationMode() ? UISettings.getInstance().getPresentationModeFontSize() - 4 : scheme.getEditorFontSize();
    return new Font(scheme.getEditorFontName(), Font.PLAIN, size);
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Aggregations

EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)103 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)31 NotNull (org.jetbrains.annotations.NotNull)28 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)17 Nullable (org.jetbrains.annotations.Nullable)15 Document (com.intellij.openapi.editor.Document)14 Project (com.intellij.openapi.project.Project)14 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)12 Editor (com.intellij.openapi.editor.Editor)11 DocumentMarkupModel (com.intellij.openapi.editor.impl.DocumentMarkupModel)10 EditorEx (com.intellij.openapi.editor.ex.EditorEx)8 TextRange (com.intellij.openapi.util.TextRange)8 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)7 PsiFile (com.intellij.psi.PsiFile)7 List (java.util.List)7 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)6 ApplicationManager (com.intellij.openapi.application.ApplicationManager)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 java.awt (java.awt)6 java.util (java.util)6