use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method testRainbow.
@Override
public void testRainbow(@NotNull String fileName, @NotNull String text, boolean isRainbowOn, boolean withColor) {
final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
final boolean isRainbowOnInScheme = RainbowHighlighter.isRainbowEnabled(globalScheme, null);
try {
RainbowHighlighter.setRainbowEnabled(globalScheme, null, isRainbowOn);
configureByText(fileName, text.replaceAll("<" + RAINBOW + "(\\scolor=\'[^\']*\')?>", "").replace("</" + RAINBOW + ">", ""));
List<HighlightInfo> highlighting = ContainerUtil.filter(doHighlighting(), info -> info.type == RainbowHighlighter.RAINBOW_ELEMENT);
assertEquals(text, getTagsFromSegments(myEditor.getDocument().getText(), highlighting, RAINBOW, highlightInfo -> {
if (!withColor) {
return null;
}
TextAttributes attributes = highlightInfo.getTextAttributes(null, null);
String color = attributes == null ? "null" : attributes.getForegroundColor() == null ? "null" : Integer.toHexString(attributes.getForegroundColor().getRGB());
return "color=\'" + color + "\'";
}));
} finally {
RainbowHighlighter.setRainbowEnabled(globalScheme, null, isRainbowOnInScheme);
}
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class EditorHyperlinkSupport method linkFollowed.
// todo fix link followed here!
private static void linkFollowed(Editor editor, Collection<RangeHighlighter> ranges, final RangeHighlighter link) {
MarkupModelEx markupModel = (MarkupModelEx) editor.getMarkupModel();
for (RangeHighlighter range : ranges) {
TextAttributes oldAttr = range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES);
if (oldAttr != null) {
markupModel.setRangeHighlighterAttributes(range, oldAttr);
range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, null);
}
if (range == link) {
range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, range.getTextAttributes());
markupModel.setRangeHighlighterAttributes(range, getFollowedHyperlinkAttributes(range));
}
}
//refresh highlighter text attributes
markupModel.addRangeHighlighter(0, 0, link.getLayer(), getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose();
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class EditorHyperlinkSupport method highlightHyperlinks.
void highlightHyperlinks(@NotNull Filter.Result result, int offsetDelta) {
Document document = myEditor.getDocument();
for (Filter.ResultItem resultItem : result.getResultItems()) {
int start = resultItem.getHighlightStartOffset() + offsetDelta;
int end = resultItem.getHighlightEndOffset() + offsetDelta;
if (start < 0 || end < start || end > document.getTextLength()) {
continue;
}
TextAttributes attributes = resultItem.getHighlightAttributes();
if (resultItem.getHyperlinkInfo() != null) {
createHyperlink(start, end, attributes, resultItem.getHyperlinkInfo(), resultItem.getFollowedHyperlinkAttributes(), resultItem.getHighlighterLayer());
} else if (attributes != null) {
addHighlighter(start, end, attributes, resultItem.getHighlighterLayer());
}
}
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class IterationStateTest method testColumnModeSelectionWithCurrentBreakpointHighlighting.
public void testColumnModeSelectionWithCurrentBreakpointHighlighting() {
init("line1\n" + "line2");
setColumnModeOn();
Color breakpointColor = Color.RED;
myFixture.getEditor().getMarkupModel().addLineHighlighter(0, HighlighterLayer.CARET_ROW + 1, new TextAttributes(null, breakpointColor, null, null, Font.PLAIN));
Color currentDebuggingLineColor = Color.CYAN;
myFixture.getEditor().getMarkupModel().addLineHighlighter(0, HighlighterLayer.SELECTION - 1, new TextAttributes(null, currentDebuggingLineColor, null, null, Font.PLAIN));
mouse().pressAt(0, 4).dragTo(0, 6).release();
verifySplitting(false, new Segment(0, 4, currentDebuggingLineColor), new Segment(4, 5, SELECTION_BACKGROUND), new Segment(5, 6, currentDebuggingLineColor), new Segment(6, 11, DEFAULT_BACKGROUND));
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class SoftWrapApplianceOnDocumentModificationTest method testLeadingTabWithShiftedWidth.
public void testLeadingTabWithShiftedWidth() throws IOException {
// Inspired by IDEA-76353. The point is that we need to consider cached information about tab symbols width during logical
// position to offset mapping
String text = "\t test";
init(15, text);
((EditorImpl) myEditor).setPrefixTextAndAttributes(" ", new TextAttributes());
myEditor.getCaretModel().moveToOffset(text.length());
}
Aggregations