use of com.intellij.openapi.editor.markup.EffectType in project intellij-community by JetBrains.
the class IterationState method setAttributes.
private void setAttributes(TextAttributes attributes, boolean atBreak) {
boolean isInSelection = isInSelection(atBreak);
boolean isInCaretRow = isInCaretRow(!myReverseIteration, myReverseIteration);
boolean isInGuardedBlock = false;
if (!myUseOnlyFullLineHighlighters) {
RangeMarker guard = myDocument.getOffsetGuard(myReverseIteration ? myStartOffset - 1 : myStartOffset);
isInGuardedBlock = guard != null && (!atBreak || myReverseIteration ? guard.getEndOffset() > myStartOffset : guard.getStartOffset() < myStartOffset);
}
TextAttributes syntax = myHighlighterIterator == null || myHighlighterIterator.atEnd() ? null : (atBreak && myStartOffset == (myReverseIteration ? myHighlighterIterator.getEnd() : myHighlighterIterator.getStart())) ? null : myHighlighterIterator.getTextAttributes();
TextAttributes selection = isInSelection ? mySelectionAttributes : null;
TextAttributes caret = isInCaretRow ? myCaretRowAttributes : null;
TextAttributes fold = myCurrentFold != null ? myFoldTextAttributes : null;
TextAttributes guard = isInGuardedBlock ? new TextAttributes(null, myReadOnlyColor, null, EffectType.BOXED, Font.PLAIN) : null;
final int size = myCurrentHighlighters.size();
if (size > 1) {
ContainerUtil.quickSort(myCurrentHighlighters, BY_LAYER_THEN_ATTRIBUTES);
}
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < size; i++) {
RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
if (highlighter.getTextAttributes() == TextAttributes.ERASE_MARKER) {
syntax = null;
}
}
List<TextAttributes> cachedAttributes = myCachedAttributesList;
if (!cachedAttributes.isEmpty())
cachedAttributes.clear();
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < size; i++) {
RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
if (atBreak && highlighter.getTargetArea() == HighlighterTargetArea.EXACT_RANGE && myStartOffset == (myReverseIteration ? highlighter.getEndOffset() : highlighter.getStartOffset()))
continue;
if (highlighter.getLayer() < HighlighterLayer.SELECTION) {
if (selection != null) {
cachedAttributes.add(selection);
selection = null;
}
}
if (fold != null && highlighter.getLayer() < HighlighterLayer.GUARDED_BLOCKS) {
cachedAttributes.add(fold);
fold = null;
}
if (guard != null && highlighter.getLayer() < HighlighterLayer.GUARDED_BLOCKS) {
cachedAttributes.add(guard);
guard = null;
}
if (caret != null && highlighter.getLayer() < HighlighterLayer.CARET_ROW) {
cachedAttributes.add(caret);
caret = null;
}
if (syntax != null && highlighter.getLayer() < HighlighterLayer.SYNTAX) {
cachedAttributes.add(syntax);
syntax = null;
}
TextAttributes textAttributes = highlighter.getTextAttributes();
if (textAttributes != null && textAttributes != TextAttributes.ERASE_MARKER) {
cachedAttributes.add(textAttributes);
}
}
if (selection != null)
cachedAttributes.add(selection);
if (fold != null)
cachedAttributes.add(fold);
if (guard != null)
cachedAttributes.add(guard);
if (caret != null)
cachedAttributes.add(caret);
if (syntax != null)
cachedAttributes.add(syntax);
Color fore = null;
Color back = isInGuardedBlock ? myReadOnlyColor : null;
Color effect = null;
EffectType effectType = null;
int fontType = 0;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < cachedAttributes.size(); i++) {
TextAttributes attrs = cachedAttributes.get(i);
if (fore == null) {
fore = attrs.getForegroundColor();
}
if (back == null) {
back = attrs.getBackgroundColor();
}
if (fontType == Font.PLAIN) {
fontType = attrs.getFontType();
}
if (effect == null) {
effect = attrs.getEffectColor();
effectType = attrs.getEffectType();
}
}
if (fore == null)
fore = myDefaultForeground;
if (back == null)
back = myDefaultBackground;
if (effectType == null)
effectType = EffectType.BOXED;
if (fontType == Font.PLAIN)
fontType = myDefaultFontType;
attributes.setAttributes(fore, back, effect, null, effectType, fontType);
}
use of com.intellij.openapi.editor.markup.EffectType in project intellij-community by JetBrains.
the class ImmediatePainter method updateAttributes.
// TODO Unify with com.intellij.openapi.editor.impl.view.IterationState.setAttributes
private static void updateAttributes(final EditorImpl editor, final TextAttributes attributes, final List<RangeHighlighterEx> highlighters) {
if (highlighters.size() > 1) {
ContainerUtil.quickSort(highlighters, IterationState.BY_LAYER_THEN_ATTRIBUTES);
}
TextAttributes syntax = attributes;
TextAttributes caretRow = editor.getCaretModel().getTextAttributes();
final int size = highlighters.size();
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < size; i++) {
RangeHighlighterEx highlighter = highlighters.get(i);
if (highlighter.getTextAttributes() == TextAttributes.ERASE_MARKER) {
syntax = null;
}
}
final List<TextAttributes> cachedAttributes = new ArrayList<>();
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < size; i++) {
RangeHighlighterEx highlighter = highlighters.get(i);
if (caretRow != null && highlighter.getLayer() < HighlighterLayer.CARET_ROW) {
cachedAttributes.add(caretRow);
caretRow = null;
}
if (syntax != null && highlighter.getLayer() < HighlighterLayer.SYNTAX) {
cachedAttributes.add(syntax);
syntax = null;
}
TextAttributes textAttributes = highlighter.getTextAttributes();
if (textAttributes != null && textAttributes != TextAttributes.ERASE_MARKER) {
cachedAttributes.add(textAttributes);
}
}
if (caretRow != null)
cachedAttributes.add(caretRow);
if (syntax != null)
cachedAttributes.add(syntax);
Color foreground = null;
Color background = null;
Color effect = null;
EffectType effectType = null;
int fontType = 0;
//noinspection ForLoopReplaceableByForEach, Duplicates
for (int i = 0; i < cachedAttributes.size(); i++) {
TextAttributes attrs = cachedAttributes.get(i);
if (foreground == null) {
foreground = attrs.getForegroundColor();
}
if (background == null) {
background = attrs.getBackgroundColor();
}
if (fontType == Font.PLAIN) {
fontType = attrs.getFontType();
}
if (effect == null) {
effect = attrs.getEffectColor();
effectType = attrs.getEffectType();
}
}
if (foreground == null)
foreground = editor.getForegroundColor();
if (background == null)
background = editor.getBackgroundColor();
if (effectType == null)
effectType = EffectType.BOXED;
TextAttributes defaultAttributes = editor.getColorsScheme().getAttributes(HighlighterColors.TEXT);
if (fontType == Font.PLAIN)
fontType = defaultAttributes == null ? Font.PLAIN : defaultAttributes.getFontType();
attributes.setAttributes(foreground, background, effect, null, effectType, fontType);
}
Aggregations