use of com.intellij.openapi.editor.colors.EditorColorsScheme in project android by JetBrains.
the class MergedManifestFixture method getDefaultBackgroundColor.
public Color getDefaultBackgroundColor() {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = colorsManager.getGlobalScheme();
return scheme.getDefaultBackground();
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class VcsPreviewPanel method updateView.
@Override
public void updateView() {
EditorColorsScheme colorsScheme = myEditor.getColorsScheme();
StringBuilder sb = new StringBuilder();
sb.append("Deleted line below\n\n" + "Modified line\n\n" + "Added line\n\n" + "Line with modified whitespaces\n\n" + "Added line\n" + "Line with modified whitespaces and deletion after\n");
int additionalLines = Math.max(0, AnnotationsSettings.getInstance().getOrderedColors(colorsScheme).size() - StringUtil.countNewLines(sb));
sb.append(StringUtil.repeat("\n", additionalLines));
myEditor.getDocument().setText(sb);
myEditor.getMarkupModel().removeAllHighlighters();
myEditor.getGutterComponentEx().closeAllAnnotations();
addHighlighter(new Range(1, 1, 0, 1), EditorColors.DELETED_LINES_COLOR);
addHighlighter(createModifiedRange(2, Range.MODIFIED), EditorColors.MODIFIED_LINES_COLOR);
addHighlighter(createModifiedRange(4, Range.INSERTED), EditorColors.ADDED_LINES_COLOR);
addHighlighter(createModifiedRange(6, Range.EQUAL), EditorColors.WHITESPACES_MODIFIED_LINES_COLOR);
addHighlighter(createModifiedRange(8, Range.INSERTED, Range.EQUAL, Range.DELETED), EditorColors.WHITESPACES_MODIFIED_LINES_COLOR);
List<Color> annotationColors = AnnotationsSettings.getInstance().getOrderedColors(colorsScheme);
List<Integer> anchorIndexes = AnnotationsSettings.getInstance().getAnchorIndexes(colorsScheme);
myEditor.getGutterComponentEx().registerTextAnnotation(new MyTextAnnotationGutterProvider(annotationColors, anchorIndexes));
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class HighlightUtil method highlightElements.
public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection, @NotNull final String statusBarText) {
if (elementCollection.isEmpty()) {
return;
}
final Application application = ApplicationManager.getApplication();
application.invokeLater(() -> {
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
final PsiElement firstElement = elements[0];
if (!firstElement.isValid()) {
return;
}
final Project project = firstElement.getProject();
final FileEditorManager editorManager = FileEditorManager.getInstance(project);
final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
final Editor editor = editorManager.getSelectedTextEditor();
if (editor == null) {
return;
}
final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
final HighlightManager highlightManager = HighlightManager.getInstance(project);
highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
final FindManager findmanager = FindManager.getInstance(project);
FindModel findmodel = findmanager.getFindNextModel();
if (findmodel == null) {
findmodel = findmanager.getFindInFileModel();
}
findmodel.setSearchHighlighters(true);
findmanager.setFindWasPerformed();
findmanager.setFindNextModel(findmodel);
application.invokeLater(() -> {
final WindowManager windowManager = WindowManager.getInstance();
final StatusBar statusBar = windowManager.getStatusBar(project);
if (statusBar != null) {
statusBar.setInfo(statusBarText);
}
});
});
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class TextWithMarkupProcessor method collectTransferableData.
@NotNull
@Override
public List<RawTextWithMarkup> collectTransferableData(PsiFile file, Editor editor, int[] startOffsets, int[] endOffsets) {
if (!RichCopySettings.getInstance().isEnabled()) {
return Collections.emptyList();
}
try {
RichCopySettings settings = RichCopySettings.getInstance();
List<Caret> carets = editor.getCaretModel().getAllCarets();
Caret firstCaret = carets.get(0);
final int indentSymbolsToStrip;
final int firstLineStartOffset;
if (Registry.is("editor.richcopy.strip.indents") && carets.size() == 1) {
Pair<Integer, Integer> p = calcIndentSymbolsToStrip(editor.getDocument(), firstCaret.getSelectionStart(), firstCaret.getSelectionEnd());
firstLineStartOffset = p.first;
indentSymbolsToStrip = p.second;
} else {
firstLineStartOffset = firstCaret.getSelectionStart();
indentSymbolsToStrip = 0;
}
logInitial(editor, startOffsets, endOffsets, indentSymbolsToStrip, firstLineStartOffset);
CharSequence text = editor.getDocument().getCharsSequence();
EditorColorsScheme schemeToUse = settings.getColorsScheme(editor.getColorsScheme());
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(file.getViewProvider().getVirtualFile(), schemeToUse, file.getProject());
highlighter.setText(text);
MarkupModel markupModel = DocumentMarkupModel.forDocument(editor.getDocument(), file.getProject(), false);
Context context = new Context(text, schemeToUse, indentSymbolsToStrip);
int endOffset = 0;
Caret prevCaret = null;
for (Caret caret : carets) {
int caretSelectionStart = caret.getSelectionStart();
int caretSelectionEnd = caret.getSelectionEnd();
int startOffsetToUse;
int additionalShift = 0;
if (caret == firstCaret) {
startOffsetToUse = firstLineStartOffset;
} else {
startOffsetToUse = caretSelectionStart;
assert prevCaret != null;
String prevCaretSelectedText = prevCaret.getSelectedText();
// Block selection fills short lines by white spaces
int fillStringLength = prevCaretSelectedText == null ? 0 : prevCaretSelectedText.length() - (prevCaret.getSelectionEnd() - prevCaret.getSelectionStart());
context.addCharacter(endOffset + fillStringLength);
additionalShift = fillStringLength + 1;
}
context.reset(endOffset - caretSelectionStart + additionalShift);
endOffset = caretSelectionEnd;
prevCaret = caret;
if (endOffset <= startOffsetToUse) {
continue;
}
MyMarkupIterator markupIterator = new MyMarkupIterator(text, new CompositeRangeIterator(schemeToUse, new HighlighterRangeIterator(highlighter, startOffsetToUse, endOffset), new MarkupModelRangeIterator(markupModel, schemeToUse, startOffsetToUse, endOffset)), schemeToUse);
try {
context.iterate(markupIterator, endOffset);
} finally {
markupIterator.dispose();
}
}
SyntaxInfo syntaxInfo = context.finish();
logSyntaxInfo(syntaxInfo);
createResult(syntaxInfo, editor);
return ObjectUtils.notNull(myResult, Collections.<RawTextWithMarkup>emptyList());
} catch (Exception e) {
// catching the exception so that the rest of copy/paste functionality can still work fine
LOG.error(e);
}
return Collections.emptyList();
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class EditorTextField method initOneLineMode.
private void initOneLineMode(final EditorEx editor) {
final boolean isOneLineMode = isOneLineMode();
// set mode in editor
editor.setOneLineMode(isOneLineMode);
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
final EditorColorsScheme defaultScheme = UIUtil.isUnderDarcula() ? colorsManager.getGlobalScheme() : colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
EditorColorsScheme customGlobalScheme = isOneLineMode ? defaultScheme : null;
editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));
EditorColorsScheme colorsScheme = editor.getColorsScheme();
editor.getSettings().setCaretRowShown(false);
// color scheme settings:
setupEditorFont(editor);
updateBorder(editor);
editor.setBackgroundColor(getBackgroundColor(isEnabled(), colorsScheme));
}
Aggregations