Java Code Examples for com.intellij.openapi.editor.markup.TextAttributes#setEffectColor()
The following examples show how to use
com.intellij.openapi.editor.markup.TextAttributes#setEffectColor() .
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: NavigationUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Patches attributes to be visible under debugger active line */ @SuppressWarnings("UseJBColor") public static TextAttributes patchAttributesColor(TextAttributes attributes, @Nonnull TextRange range, @Nonnull Editor editor) { if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null) return attributes; MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); if (model != null) { if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(), highlighter -> { if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { TextAttributes textAttributes = highlighter.getTextAttributes(); if (textAttributes != null) { Color color = textAttributes.getBackgroundColor(); return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128); } } return true; })) { TextAttributes clone = attributes.clone(); clone.setForegroundColor(Color.orange); clone.setEffectColor(Color.orange); return clone; } } return attributes; }
Example 2
Source File: EditorDocOps.java From KodeBeagle with Apache License 2.0 | 5 votes |
public final void addHighlighting(final List<Integer> linesForHighlighting, final Document document) { TextAttributes attributes = new TextAttributes(); JBColor color = JBColor.GREEN; attributes.setEffectColor(color); attributes.setEffectType(EffectType.SEARCH_MATCH); attributes.setBackgroundColor(HIGHLIGHTING_COLOR); Editor projectEditor = FileEditorManager.getInstance(windowObjects.getProject()).getSelectedTextEditor(); if (projectEditor != null) { PsiFile psiFile = PsiDocumentManager.getInstance(windowObjects.getProject()). getPsiFile(projectEditor.getDocument()); MarkupModel markupModel = projectEditor.getMarkupModel(); if (markupModel != null) { markupModel.removeAllHighlighters(); for (int line : linesForHighlighting) { line = line - 1; if (line < document.getLineCount()) { int startOffset = document.getLineStartOffset(line); int endOffset = document.getLineEndOffset(line); String lineText = document.getCharsSequence(). subSequence(startOffset, endOffset).toString(); int lineStartOffset = startOffset + lineText.length() - lineText.trim().length(); markupModel.addRangeHighlighter(lineStartOffset, endOffset, HighlighterLayer.ERROR, attributes, HighlighterTargetArea.EXACT_RANGE); if (psiFile != null && psiFile.findElementAt(lineStartOffset) != null) { HighlightUsagesHandler.doHighlightElements(projectEditor, new PsiElement[]{psiFile.findElementAt(lineStartOffset)}, attributes, false); } } } } } }
Example 3
Source File: Filter.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static TextAttributes getGrayedHyperlinkAttributes(@Nonnull TextAttributesKey normalHyperlinkAttrsKey) { EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); TextAttributes grayedHyperlinkAttrs = GRAYED_BY_NORMAL_CACHE.get(normalHyperlinkAttrsKey); if (grayedHyperlinkAttrs == null) { TextAttributes normalHyperlinkAttrs = globalScheme.getAttributes(normalHyperlinkAttrsKey); if (normalHyperlinkAttrs != null) { grayedHyperlinkAttrs = normalHyperlinkAttrs.clone(); grayedHyperlinkAttrs.setForegroundColor(UIUtil.getInactiveTextColor()); grayedHyperlinkAttrs.setEffectColor(UIUtil.getInactiveTextColor()); GRAYED_BY_NORMAL_CACHE.put(normalHyperlinkAttrsKey, grayedHyperlinkAttrs); } } return grayedHyperlinkAttrs; }
Example 4
Source File: LivePreview.java From consulo with Apache License 2.0 | 5 votes |
private TextAttributes createAttributes(FindResult range) { EditorColorsScheme colorsScheme = mySearchResults.getEditor().getColorsScheme(); if (mySearchResults.isExcluded(range)) { return new TextAttributes(null, null, colorsScheme.getDefaultForeground(), EffectType.STRIKEOUT, Font.PLAIN); } TextAttributes attributes = colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); if (range.getLength() == 0) { attributes = attributes.clone(); attributes.setEffectType(EffectType.BOXED); attributes.setEffectColor(attributes.getBackgroundColor()); } return attributes; }
Example 5
Source File: ColoredOutputTypeRegistry.java From consulo with Apache License 2.0 | 4 votes |
public Key getOutputKey(@NonNls String attribute) { final Key key = myRegisteredKeys.get(attribute); if (key != null) { return key; } final String completeAttribute = attribute; if (attribute.startsWith("\u001B[")) { attribute = attribute.substring(2); } else if (attribute.startsWith("[")) { attribute = attribute.substring(1); } if (attribute.endsWith("m")) { attribute = attribute.substring(0, attribute.length() - 1); } if (attribute.equals("0")) { return ProcessOutputTypes.STDOUT; } TextAttributes attrs = new TextAttributes(); final String[] strings = attribute.split(";"); for (String string : strings) { int value; try { value = Integer.parseInt(string); } catch (NumberFormatException e) { continue; } if (value == 1) { attrs.setFontType(Font.BOLD); } else if (value == 4) { attrs.setEffectType(EffectType.LINE_UNDERSCORE); } else if (value == 22) { attrs.setFontType(Font.PLAIN); } else if (value == 24) { //not underlined attrs.setEffectType(null); } else if (value >= 30 && value <= 37) { attrs.setForegroundColor(getAnsiColor(value - 30)); } else if (value == 38) { //TODO: 256 colors foreground } else if (value == 39) { attrs.setForegroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY)); } else if (value >= 40 && value <= 47) { attrs.setBackgroundColor(getAnsiColor(value - 40)); } else if (value == 48) { //TODO: 256 colors background } else if (value == 49) { attrs.setBackgroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY)); } else if (value >= 90 && value <= 97) { attrs.setForegroundColor( getAnsiColor(value - 82)); } else if (value >= 100 && value <= 107) { attrs.setBackgroundColor( getAnsiColor(value - 92)); } } if (attrs.getEffectType() == EffectType.LINE_UNDERSCORE) { attrs.setEffectColor(attrs.getForegroundColor()); } Key newKey = new Key(completeAttribute); ConsoleViewContentType contentType = new ConsoleViewContentType(completeAttribute, attrs); ConsoleViewContentType.registerNewConsoleViewType(newKey, contentType); myRegisteredKeys.put(completeAttribute, newKey); return newKey; }
Example 6
Source File: PackagingElementNode.java From consulo with Apache License 2.0 | 4 votes |
private static SimpleTextAttributes addErrorHighlighting(boolean error, SimpleTextAttributes attributes) { final TextAttributes textAttributes = attributes.toTextAttributes(); textAttributes.setEffectType(EffectType.WAVE_UNDERSCORE); textAttributes.setEffectColor(error ? JBColor.RED : JBColor.GRAY); return SimpleTextAttributes.fromTextAttributes(textAttributes); }
Example 7
Source File: CppHighlighter.java From CppTools with Apache License 2.0 | 4 votes |
private static TextAttributes createParameterAttributes() { TextAttributes attrs = new TextAttributes(); attrs.setEffectType(EffectType.LINE_UNDERSCORE); attrs.setEffectColor(Color.black); return attrs; }