Java Code Examples for com.intellij.openapi.editor.Editor#getColorsScheme()
The following examples show how to use
com.intellij.openapi.editor.Editor#getColorsScheme() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeneralHighlightingPass.java From consulo with Apache License 2.0 | 6 votes |
public GeneralHighlightingPass(@Nonnull Project project, @Nonnull PsiFile file, @Nonnull Document document, int startOffset, int endOffset, boolean updateAll, @Nonnull ProperTextRange priorityRange, @Nullable Editor editor, @Nonnull HighlightInfoProcessor highlightInfoProcessor) { super(project, document, PRESENTABLE_NAME, file, editor, TextRange.create(startOffset, endOffset), true, highlightInfoProcessor); myUpdateAll = updateAll; myPriorityRange = priorityRange; PsiUtilCore.ensureValid(file); boolean wholeFileHighlighting = isWholeFileHighlighting(); myHasErrorElement = !wholeFileHighlighting && Boolean.TRUE.equals(getFile().getUserData(HAS_ERROR_ELEMENT)); final DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap(); myErrorFound = !wholeFileHighlighting && fileStatusMap.wasErrorFound(getDocument()); // initial guess to show correct progress in the traffic light icon setProgressLimit(document.getTextLength() / 2); // approx number of PSI elements = file length/2 myGlobalScheme = editor != null ? editor.getColorsScheme() : EditorColorsManager.getInstance().getGlobalScheme(); }
Example 2
Source File: TemplateEditorUtil.java From consulo with Apache License 2.0 | 6 votes |
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) { EditorFactory editorFactory = EditorFactory.getInstance(); Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project)); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); EditorColorsScheme scheme = editor.getColorsScheme(); scheme.setColor(EditorColors.CARET_ROW_COLOR, null); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx) editor).setHighlighter(highlighter); } return editor; }
Example 3
Source File: HighlightHelper.java From PackageTemplates with Apache License 2.0 | 5 votes |
public static void applyHighlightRange(ArrayList<TextRange> ranges, Project project, Editor editor) { if (project == null) { return; } EditorColorsScheme scheme = editor.getColorsScheme(); TextAttributes attributes = scheme.getAttributes(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES); for (TextRange textRange : ranges) { HighlightManager.getInstance(project).addRangeHighlight( editor, textRange.getBegin(), textRange.getEnd(), attributes, true, null); } }
Example 4
Source File: SassLintExternalAnnotator.java From sass-lint-plugin with MIT License | 5 votes |
@Nullable private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) { if (psiFile.getContext() != null || !SassLintConfigFileUtil.isSassFile(psiFile)) { return null; } VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isInLocalFileSystem()) { return null; } if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) { return null; } Project project = psiFile.getProject(); SassLintProjectComponent component = project.getComponent(SassLintProjectComponent.class); if (!component.isSettingsValid() || !component.isEnabled()) { return null; } Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) { return null; } String fileContent = document.getText(); if (StringUtil.isEmptyOrSpaces(fileContent)) { return null; } EditorColorsScheme colorsScheme = editor != null ? editor.getColorsScheme() : null; // tabSize = getTabSize(editor); // tabSize = 4; return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme); }
Example 5
Source File: RTExternalAnnotator.java From react-templates-plugin with MIT License | 5 votes |
@Nullable private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) { if (psiFile.getContext() != null || !RTFileUtil.isRTFile(psiFile)) { return null; } VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isInLocalFileSystem()) { return null; } if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) { return null; } Project project = psiFile.getProject(); RTProjectComponent component = project.getComponent(RTProjectComponent.class); if (component == null || !component.isValidAndEnabled()) { return null; } Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) { return null; } String fileContent = document.getText(); if (StringUtil.isEmptyOrSpaces(fileContent)) { return null; } EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme(); // tabSize = getTabSize(editor); // tabSize = 4; return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme); }
Example 6
Source File: RTExternalAnnotator.java From react-templates-plugin with MIT License | 5 votes |
@Nullable private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) { if (psiFile.getContext() != null || !RTFileUtil.isRTFile(psiFile)) { return null; } VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isInLocalFileSystem()) { return null; } if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) { return null; } Project project = psiFile.getProject(); RTProjectComponent component = project.getComponent(RTProjectComponent.class); if (component == null || !component.isValidAndEnabled()) { return null; } Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) { return null; } String fileContent = document.getText(); if (StringUtil.isEmptyOrSpaces(fileContent)) { return null; } EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme(); // tabSize = getTabSize(editor); // tabSize = 4; return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme); }
Example 7
Source File: ESLintExternalAnnotator.java From eslint-plugin with MIT License | 5 votes |
@Nullable private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) { if (psiFile.getContext() != null) { return null; } VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isInLocalFileSystem()) { return null; } if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) { return null; } Project project = psiFile.getProject(); ESLintProjectComponent component = project.getComponent(ESLintProjectComponent.class); if (!component.isSettingsValid() || !component.isEnabled() || !isJavaScriptFile(psiFile, component.ext)) { return null; } Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) { return null; } String fileContent = document.getText(); if (StringUtil.isEmptyOrSpaces(fileContent)) { return null; } EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme(); // tabSize = getTabSize(editor); // tabSize = 4; return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme); }
Example 8
Source File: DiffDividerDrawUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static List<DividerSeparator> createVisibleSeparators(@Nonnull Editor editor1, @Nonnull Editor editor2, @Nonnull DividerSeparatorPaintable paintable) { final List<DividerSeparator> separators = new ArrayList<DividerSeparator>(); final Transformation[] transformations = new Transformation[]{getTransformation(editor1), getTransformation(editor2)}; final Interval leftInterval = getVisibleInterval(editor1); final Interval rightInterval = getVisibleInterval(editor2); final int height1 = editor1.getLineHeight(); final int height2 = editor2.getLineHeight(); final EditorColorsScheme scheme = editor1.getColorsScheme(); paintable.process(new DividerSeparatorPaintable.Handler() { @Override public boolean process(int line1, int line2) { if (leftInterval.startLine > line1 + 1 && rightInterval.startLine > line2 + 1) return true; if (leftInterval.endLine < line1 && rightInterval.endLine < line2) return false; separators.add(createSeparator(transformations, line1, line2, height1, height2, scheme)); return true; } }); return separators; }
Example 9
Source File: EditorFragmentComponent.java From consulo with Apache License 2.0 | 5 votes |
public static Color getBackgroundColor(Editor editor, boolean useCaretRowBackground) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR); if (!useCaretRowBackground || color == null) { color = colorsScheme.getDefaultBackground(); } return color; }
Example 10
Source File: XDebuggerInlayUtil.java From consulo with Apache License 2.0 | 5 votes |
private static FontInfo getFontInfo(@Nonnull Editor editor) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); FontPreferences fontPreferences = colorsScheme.getFontPreferences(); TextAttributes attributes = editor.getColorsScheme().getAttributes(DebuggerColors.INLINED_VALUES_EXECUTION_LINE); int fontStyle = attributes == null ? Font.PLAIN : attributes.getFontType(); return ComplementaryFontsRegistry.getFontAbleToDisplay('a', fontStyle, fontPreferences, FontInfo.getFontRenderContext(editor.getContentComponent())); }
Example 11
Source File: BraceHighlightingHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull static EditorHighlighter getLazyParsableHighlighterIfAny(Project project, Editor editor, PsiFile psiFile) { if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) { return ((EditorEx)editor).getHighlighter(); } PsiElement elementAt = psiFile.findElementAt(editor.getCaretModel().getOffset()); for (PsiElement e : SyntaxTraverser.psiApi().parents(elementAt).takeWhile(Conditions.notEqualTo(psiFile))) { if (!(PsiUtilCore.getElementType(e) instanceof ILazyParseableElementType)) continue; Language language = ILazyParseableElementType.LANGUAGE_KEY.get(e.getNode()); if (language == null) continue; TextRange range = e.getTextRange(); final int offset = range.getStartOffset(); SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, psiFile.getVirtualFile()); LexerEditorHighlighter highlighter = new LexerEditorHighlighter(syntaxHighlighter, editor.getColorsScheme()) { @Nonnull @Override public HighlighterIterator createIterator(int startOffset) { return new HighlighterIteratorWrapper(super.createIterator(Math.max(startOffset - offset, 0))) { @Override public int getStart() { return super.getStart() + offset; } @Override public int getEnd() { return super.getEnd() + offset; } }; } }; highlighter.setText(editor.getDocument().getText(range)); return highlighter; } return ((EditorEx)editor).getHighlighter(); }
Example 12
Source File: LineStatusMarkerRenderer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static EditorColorsScheme getColorScheme(@Nullable Editor editor) { return editor != null ? editor.getColorsScheme() : EditorColorsManager.getInstance().getGlobalScheme(); }
Example 13
Source File: HighlightCommand.java From CppTools with Apache License 2.0 | 4 votes |
private void doAddHighlighters(Editor editor, List<String> highlighterStringList, boolean overriden) { if (stamp != communicator.getModificationCount() || failed) return; final long started = System.currentTimeMillis(); Key<THashSet<RangeHighlighter>> highlightersKey = overriden ? myOverridenHighlightersKey : myHighlightersKey; THashSet<RangeHighlighter> currentHighlighters = editor.getUserData(highlightersKey); final THashSet<RangeHighlighter> invalidMarkers; if (currentHighlighters == null) { invalidMarkers = new THashSet<RangeHighlighter>(10000); } else { invalidMarkers = currentHighlighters; } currentHighlighters = new THashSet<RangeHighlighter>(); editor.putUserData(highlightersKey, currentHighlighters); final TIntObjectHashMap<RangeHighlighter> lastOffsetToHighlightersMap = new TIntObjectHashMap<RangeHighlighter>(); final TIntObjectHashMap<RangeHighlighter> overridenMap = new TIntObjectHashMap<RangeHighlighter>(); final TIntObjectHashMap<RangeHighlighter> overriddingMap = new TIntObjectHashMap<RangeHighlighter>(); for(RangeHighlighter h:invalidMarkers) { if (!h.isValid()) continue; final GutterIconRenderer gutterIconRenderer = h.getGutterIconRenderer(); final int offset = h.getStartOffset(); if ((!overriden && gutterIconRenderer == null)) { lastOffsetToHighlightersMap.put(offset, h); } else if (overriden && gutterIconRenderer != null) { final HighlightUtils.MyGutterIconRenderer myGutterIconRenderer = (HighlightUtils.MyGutterIconRenderer) gutterIconRenderer; final boolean overrides = myGutterIconRenderer.isOverrides(); ((HighlightUtils.MyGutterIconRenderer) gutterIconRenderer).clearData(); ((overrides)?overriddingMap:overridenMap).put(offset, h); } } final EditorColorsScheme colorsScheme = editor.getColorsScheme(); for(String s: highlighterStringList) { processHighlighterString(editor, colorsScheme, s, overriddingMap, overridenMap, lastOffsetToHighlightersMap, currentHighlighters, invalidMarkers); } //System.out.println("Updated highlighters 2/5 for "+ (System.currentTimeMillis() - started)); for(RangeHighlighter rangeHighlighter:invalidMarkers) { editor.getMarkupModel().removeHighlighter(rangeHighlighter); currentHighlighters.remove(rangeHighlighter); } long doneFor = System.currentTimeMillis() - started; //System.out.println("Updated highlighters 2 for "+ doneFor); Communicator.debug("Updated highlighters 2 for "+ doneFor); }