use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class TodoFileNode method updateImpl.
@Override
protected void updateImpl(PresentationData data) {
super.updateImpl(data);
String newName;
if (myBuilder.getTodoTreeStructure().isPackagesShown()) {
newName = getValue().getName();
} else {
newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl();
}
int nameEndOffset = newName.length();
int todoItemCount;
try {
todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue());
} catch (IndexNotReadyException e) {
return;
}
if (mySingleFileMode) {
if (todoItemCount == 0) {
newName = IdeBundle.message("node.todo.no.items.found", newName);
} else {
newName = IdeBundle.message("node.todo.found.items", newName, todoItemCount);
}
} else {
newName = IdeBundle.message("node.todo.items", newName, todoItemCount);
}
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
textAttributes.setForegroundColor(myColor);
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class HTMLTextPainter method writeStyles.
private void writeStyles(@NonNls final Writer writer) throws IOException {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
writer.write("<style type=\"text/css\">\n");
final Color lineNumbers = scheme.getColor(EditorColors.LINE_NUMBERS_COLOR);
writer.write(String.format(".ln { color: #%s; font-weight: normal; font-style: normal; }\n", ColorUtil.toHex(lineNumbers == null ? Gray.x00 : lineNumbers)));
HighlighterIterator hIterator = myHighlighter.createIterator(myOffset);
while (!hIterator.atEnd()) {
TextAttributes textAttributes = hIterator.getTextAttributes();
if (!myStyleMap.containsKey(textAttributes)) {
@NonNls String styleName = "s" + myStyleMap.size();
myStyleMap.put(textAttributes, styleName);
writer.write("." + styleName + " { ");
Color foreColor = textAttributes.getForegroundColor();
if (foreColor == null)
foreColor = scheme.getDefaultForeground();
writer.write("color: " + colorToHtml(foreColor) + "; ");
if (BitUtil.isSet(textAttributes.getFontType(), Font.BOLD)) {
writer.write("font-weight: bold; ");
}
if (BitUtil.isSet(textAttributes.getFontType(), Font.ITALIC)) {
writer.write("font-style: italic; ");
}
writer.write("}\n");
}
hIterator.advance();
}
for (LineMarkerInfo separator : myMethodSeparators) {
Color color = separator.separatorColor;
if (color != null && !mySeparatorStyles.containsKey(color)) {
@NonNls String styleName = "ls" + mySeparatorStyles.size();
mySeparatorStyles.put(color, styleName);
String htmlColor = colorToHtml(color);
writer.write("." + styleName + " { height: 1px; border-width: 0; color: " + htmlColor + "; background-color:" + htmlColor + "}\n");
}
}
writer.write("</style>\n");
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class BraceHighlightingHandler method highlightBraces.
private void highlightBraces(@Nullable TextRange lBrace, @Nullable TextRange rBrace, boolean matched, boolean scopeHighlighting, @NotNull FileType fileType) {
if (!matched && fileType == FileTypes.PLAIN_TEXT) {
return;
}
EditorColorsScheme scheme = myEditor.getColorsScheme();
final TextAttributes attributes = matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES) : scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
if (rBrace != null && !scopeHighlighting) {
highlightBrace(rBrace, matched);
}
if (lBrace != null && !scopeHighlighting) {
highlightBrace(lBrace, matched);
}
// null in default project
FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
if (fileEditorManager == null || !myEditor.equals(fileEditorManager.getSelectedTextEditor())) {
return;
}
if (lBrace != null && rBrace != null) {
final int startLine = myEditor.offsetToLogicalPosition(lBrace.getStartOffset()).line;
final int endLine = myEditor.offsetToLogicalPosition(rBrace.getEndOffset()).line;
if (endLine - startLine > 0) {
final Runnable runnable = () -> {
if (myProject.isDisposed() || myEditor.isDisposed())
return;
Color color = attributes.getBackgroundColor();
if (color == null)
return;
color = ColorUtil.isDark(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()) ? ColorUtil.shift(color, 1.5d) : color.darker();
lineMarkFragment(startLine, endLine, color);
};
if (!scopeHighlighting) {
myAlarm.addRequest(runnable, 300);
} else {
runnable.run();
}
} else {
removeLineMarkers();
}
if (!scopeHighlighting) {
showScopeHint(lBrace.getStartOffset(), lBrace.getEndOffset());
}
} else {
if (!myCodeInsightSettings.HIGHLIGHT_SCOPE) {
removeLineMarkers();
}
}
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class TemplateEditorUtil method createEditor.
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));
editor.getContentComponent().setFocusable(!isReadOnly);
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setIndentGuidesShown(false);
editorSettings.setLineNumbersShown(false);
editorSettings.setFoldingOutlineShown(false);
editorSettings.setCaretRowShown(false);
EditorColorsScheme scheme = editor.getColorsScheme();
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file != null) {
EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
((EditorEx) editor).setHighlighter(highlighter);
}
return editor;
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class TemplateEditorUtil method setHighlighter.
private static void setHighlighter(EditorEx editor, @Nullable SyntaxHighlighter highlighter) {
EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
LayeredLexerEditorHighlighter layeredHighlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), editorColorsScheme);
layeredHighlighter.registerLayer(TemplateTokenType.TEXT, new LayerDescriptor(ObjectUtils.notNull(highlighter, new PlainSyntaxHighlighter()), ""));
editor.setHighlighter(layeredHighlighter);
}
Aggregations