下面列出了com.intellij.psi.PsiStatement#com.intellij.openapi.editor.colors.EditorColorsManager 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static void highlightPsiElement(PsiElement psiElement, boolean openInEditor) {
if (openInEditor) {
EditorHelper.openInEditor(psiElement);
}
Editor editor = FileEditorManager.getInstance(psiElement.getProject()).getSelectedTextEditor();
if (editor == null) {
return;
}
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
editor.getMarkupModel().addRangeHighlighter(
psiElement.getTextRange().getStartOffset(),
psiElement.getTextRange().getEndOffset(),
HighlighterLayer.SELECTION,
attributes,
HighlighterTargetArea.EXACT_RANGE
);
}
public static TextAttributes getTextAttributesOfColumn(int columnIndex, UserDataHolder userDataHolder) {
List<TextAttributes> textAttributeList = userDataHolder.getUserData(COLUMN_HIGHLIGHT_TEXT_ATTRIBUTES_KEY);
if (textAttributeList == null) {
EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
textAttributeList = new ArrayList<>();
int maxIndex = 0;
for (int colorDescriptorIndex = 0; colorDescriptorIndex < MAX_COLUMN_HIGHLIGHT_COLORS; ++colorDescriptorIndex) {
TextAttributesKey textAttributesKey = COLUMN_HIGHLIGHT_ATTRIBUTES.get(colorDescriptorIndex);
TextAttributes textAttributes = editorColorsScheme.getAttributes(textAttributesKey);
textAttributeList.add(textAttributes);
if (!textAttributesKey.getDefaultAttributes().equals(textAttributes)) {
maxIndex = colorDescriptorIndex;
}
}
textAttributeList = textAttributeList.subList(0, maxIndex + 1);
userDataHolder.putUserData(COLUMN_HIGHLIGHT_TEXT_ATTRIBUTES_KEY, textAttributeList);
}
return textAttributeList.isEmpty() ? null : textAttributeList.get(columnIndex % textAttributeList.size());
}
protected Font determineFont(@NotNull String text) {
Font finalFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN));
FontFallbackIterator it = new FontFallbackIterator();
it.setPreferredFont(finalFont.getFamily(), finalFont.getSize());
it.setFontStyle(finalFont.getStyle());
it.start(text, 0, text.length());
for (; !it.atEnd(); it.advance()) {
Font font = it.getFont();
if (!font.getFamily().equals(finalFont.getFamily())) {
finalFont = font;
break;
}
}
return finalFont;
}
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
Iterator iterator = ranges.iterator();
while (iterator.hasNext()) {
TextRange range = (TextRange) iterator.next();
//highlightManager.addOccurrenceHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, 0, highlighters, (Color) null);
highlightManager.addRangeHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, false, highlighters);
}
iterator = highlighters.iterator();
while (iterator.hasNext()) {
RangeHighlighter highlighter = (RangeHighlighter) iterator.next();
highlighter.setGreedyToLeft(true);
highlighter.setGreedyToRight(true);
}
}
protected void performHighlighting() {
boolean clearHighlights = HighlightUsagesHandler.isClearHighlights(myEditor);
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
myEditor, attributes, clearHighlights, myReadUsages);
HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
myEditor, writeAttributes, clearHighlights, myWriteUsages);
if (!clearHighlights) {
WindowManager.getInstance().getStatusBar(myEditor.getProject()).setInfo(myStatusText);
HighlightHandlerBase.setupFindModel(myEditor.getProject()); // enable f3 navigation
}
if (myHintText != null) {
HintManager.getInstance().showInformationHint(myEditor, myHintText);
}
}
protected static Editor createEditor(String text, int column, int line, int selectedLine) {
EditorFactory editorFactory = EditorFactory.getInstance();
Document editorDocument = editorFactory.createDocument(text);
EditorEx editor = (EditorEx)editorFactory.createViewer(editorDocument);
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
editor.setColorsScheme(scheme);
EditorSettings settings = editor.getSettings();
settings.setWhitespacesShown(true);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setFoldingOutlineShown(false);
settings.setAdditionalColumnsCount(0);
settings.setAdditionalLinesCount(0);
settings.setRightMarginShown(true);
settings.setRightMargin(60);
LogicalPosition pos = new LogicalPosition(line, column);
editor.getCaretModel().moveToLogicalPosition(pos);
if (selectedLine >= 0) {
editor.getSelectionModel().setSelection(editorDocument.getLineStartOffset(selectedLine),
editorDocument.getLineEndOffset(selectedLine));
}
return editor;
}
@Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
FileType type = content.getContentType();
VirtualFile file = content.getHighlightFile();
Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);
EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
if (language != null) {
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
}
if (file != null) {
if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
return highlighterFactory.createEditorHighlighter(project, file);
}
}
if (type != null) {
return highlighterFactory.createEditorHighlighter(project, type);
}
return null;
}
private static void paintLine(@Nonnull Graphics g,
@Nonnull int[] xPoints, @Nonnull int[] yPoints,
int lineHeight,
@Nullable EditorColorsScheme scheme) {
int height = getHeight(lineHeight);
if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme();
Graphics2D gg = ((Graphics2D)g);
AffineTransform oldTransform = gg.getTransform();
for (int i = 0; i < height; i++) {
Color color = getTopBorderColor(i, lineHeight, scheme);
if (color == null) color = getBottomBorderColor(i, lineHeight, scheme);
if (color == null) color = getBackgroundColor(scheme);
gg.setColor(color);
gg.drawPolyline(xPoints, yPoints, xPoints.length);
gg.translate(0, 1);
}
gg.setTransform(oldTransform);
}
@Inject
public CoverageDataManagerImpl(final Project project) {
myProject = project;
if (project.isDefault()) {
return;
}
EditorColorsManager.getInstance().addEditorColorsListener(new EditorColorsAdapter() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
chooseSuitesBundle(myCurrentSuitesBundle);
}
}, project);
addSuiteListener(new CoverageViewSuiteListener(this, myProject), myProject);
}
private static void flashUsageScriptaculously(@Nonnull final Usage usage) {
if (!(usage instanceof UsageInfo2UsageAdapter)) {
return;
}
UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;
Editor editor = usageInfo.openTextEditor(true);
if (editor == null) return;
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);
RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
List<Segment> segments = new ArrayList<>();
Processor<Segment> processor = Processors.cancelableCollectProcessor(segments);
usageInfo.processRangeMarkers(processor);
rangeBlinker.resetMarkers(segments);
rangeBlinker.startBlinking();
}
public GeneralHighlightingPass(@Nonnull Project project,
@Nonnull PsiFile file,
@Nonnull Document document,
int startOffset,
int endOffset,
boolean updateAll,
@Nonnull ProperTextRange priorityRange,
@Nullable Editor editor,
@Nonnull HighlightInfoProcessor highlightInfoProcessor) {
super(project, document, PRESENTABLE_NAME, file, editor, TextRange.create(startOffset, endOffset), true, highlightInfoProcessor);
myUpdateAll = updateAll;
myPriorityRange = priorityRange;
PsiUtilCore.ensureValid(file);
boolean wholeFileHighlighting = isWholeFileHighlighting();
myHasErrorElement = !wholeFileHighlighting && Boolean.TRUE.equals(getFile().getUserData(HAS_ERROR_ELEMENT));
final DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap();
myErrorFound = !wholeFileHighlighting && fileStatusMap.wasErrorFound(getDocument());
// initial guess to show correct progress in the traffic light icon
setProgressLimit(document.getTextLength() / 2); // approx number of PSI elements = file length/2
myGlobalScheme = editor != null ? editor.getColorsScheme() : EditorColorsManager.getInstance().getGlobalScheme();
}
@Override
public void apply() throws ConfigurationException {
if (myApplyCompleted) {
return;
}
try {
EditorColorsManager myColorsManager = EditorColorsManager.getInstance();
myColorsManager.removeAllSchemes();
for (MyColorScheme scheme : mySchemes.values()) {
if (!scheme.isDefault()) {
scheme.apply();
myColorsManager.addColorsScheme(scheme.getOriginalScheme());
}
}
EditorColorsScheme originalScheme = mySelectedScheme.getOriginalScheme();
myColorsManager.setGlobalScheme(originalScheme);
applyChangesToEditors();
reset();
}
finally {
myApplyCompleted = true;
}
}
@Inject
public EditorFactoryImpl(Application application) {
MessageBusConnection busConnection = application.getMessageBus().connect();
busConnection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
@Override
public void projectClosed(@Nonnull Project project, @Nonnull UIAccess uiAccess) {
// validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
Disposer.register(project, () -> {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
boolean isLastProjectClosed = openProjects.length == 0;
// EditorTextField.releaseEditorLater defer releasing its editor; invokeLater to avoid false positives about such editors.
ApplicationManager.getApplication().invokeLater(() -> validateEditorsAreReleased(project, isLastProjectClosed));
});
}
});
busConnection.subscribe(EditorColorsManager.TOPIC, scheme -> refreshAllEditors());
LaterInvocator.addModalityStateListener(new ModalityStateListener() {
@Override
public void beforeModalityStateChanged(boolean entering) {
for (Editor editor : myEditors) {
((DesktopEditorImpl)editor).beforeModalityStateChanged();
}
}
}, ApplicationManager.getApplication());
}
private void applyFocusMode(@Nonnull Segment focusRange) {
EditorColorsScheme scheme = ObjectUtils.notNull(myEditor.getColorsScheme(), EditorColorsManager.getInstance().getGlobalScheme());
Color background = scheme.getDefaultBackground();
//noinspection UseJBColor
Color foreground = Registry.getColor(ColorUtil.isDark(background) ? "editor.focus.mode.color.dark" : "editor.focus.mode.color.light", Color.GRAY);
TextAttributes attributes = new TextAttributes(foreground, background, background, LINE_UNDERSCORE, Font.PLAIN);
myEditor.putUserData(FOCUS_MODE_ATTRIBUTES, attributes);
MarkupModel markupModel = myEditor.getMarkupModel();
DocumentEx document = myEditor.getDocument();
int textLength = document.getTextLength();
int start = focusRange.getStartOffset();
int end = focusRange.getEndOffset();
if (start <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(0, start, LAYER, attributes, EXACT_RANGE));
if (end <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(end, textLength, LAYER, attributes, EXACT_RANGE));
myFocusModeRange = document.createRangeMarker(start, end);
}
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()));
}
private static void tweakEditorAndFireUpdateUI(UISettings settings, boolean inPresentation) {
EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
int fontSize = inPresentation ? settings.PRESENTATION_MODE_FONT_SIZE : globalScheme.getEditorFontSize();
if (inPresentation) {
ourSavedConsoleFontSize = globalScheme.getConsoleFontSize();
globalScheme.setConsoleFontSize(fontSize);
}
else {
globalScheme.setConsoleFontSize(ourSavedConsoleFontSize);
}
for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
if (editor instanceof EditorEx) {
((EditorEx)editor).setFontSize(fontSize);
}
}
UISettings.getInstance().fireUISettingsChanged();
LafManager.getInstance().updateUI();
EditorUtil.reinitSettings();
}
public void renderElement(LookupElement element, LookupElementPresentation presentation) {
Suggestion suggestion = (Suggestion) element.getObject();
if (suggestion.icon != null) {
presentation.setIcon(suggestion.icon);
}
presentation.setStrikeout(suggestion.deprecationLevel != null);
if (suggestion.deprecationLevel != null) {
if (suggestion.deprecationLevel == SpringConfigurationMetadataDeprecationLevel.error) {
presentation.setItemTextForeground(RED);
} else {
presentation.setItemTextForeground(YELLOW);
}
}
String lookupString = element.getLookupString();
presentation.setItemText(lookupString);
if (!lookupString.equals(suggestion.suggestionToDisplay)) {
presentation.setItemTextBold(true);
}
String shortDescription;
if (suggestion.defaultValue != null) {
shortDescription = shortenTextWithEllipsis(suggestion.defaultValue, 60, 0, true);
TextAttributes attrs =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(SCALAR_TEXT);
presentation.setTailText("=" + shortDescription, attrs.getForegroundColor());
}
if (suggestion.description != null) {
presentation
.appendTailText(" (" + getFirstSentenceWithoutDot(suggestion.description) + ")",
true);
}
if (suggestion.shortType != null) {
presentation.setTypeText(suggestion.shortType);
}
}
private void applyFontProps() {
Document document = myEditorPane.getDocument();
if (!(document instanceof StyledDocument)) {
return;
}
String fontName = Registry.is("documentation.component.editor.font") ? EditorColorsManager.getInstance().getGlobalScheme().getEditorFontName() : myEditorPane.getFont().getFontName();
// changing font will change the doc's CSS as myEditorPane has JEditorPane.HONOR_DISPLAY_PROPERTIES via UIUtil.getHTMLEditorKit
myEditorPane.setFont(UIUtil.getFontWithFallback(fontName, Font.PLAIN, JBUIScale.scale(getQuickDocFontSize().getSize())));
}
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
Project project = dataContext.getData(CommonDataKeys.PROJECT);
List<PsiElement> elements = getElementsToCopy(editor, dataContext);
if (!doCopy(elements, project, editor) && editor != null && project != null) {
Document document = editor.getDocument();
PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
if (file != null) {
String toCopy = getFileFqn(file) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
CopyPasteManager.getInstance().setContents(new StringSelection(toCopy));
setStatusBarText(project, toCopy + " has been copied");
}
return;
}
HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
if (elements.size() == 1 && editor != null && project != null) {
PsiElement element = elements.get(0);
PsiElement nameIdentifier = IdentifierUtil.getNameIdentifier(element);
if (nameIdentifier != null) {
highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{nameIdentifier}, attributes, true, null);
} else {
PsiReference reference = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
if (reference != null) {
highlightManager.addOccurrenceHighlights(editor, new PsiReference[]{reference}, attributes, true, null);
} else if (element != PsiDocumentManager.getInstance(project).getCachedPsiFile(editor.getDocument())) {
highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{element}, attributes, true, null);
}
}
}
}
/**
* @param object an object that represents a node in the project tree
* @param expanded {@code true} if the corresponding node is expanded,
* {@code false} if it is collapsed
* @return a non-null value if the corresponding node should be , or {@code null}
*/
protected ErrorStripe getStripe(Object object, boolean expanded) {
if (expanded && object instanceof PsiDirectoryNode) return null;
if (object instanceof PresentableNodeDescriptor) {
PresentableNodeDescriptor node = (PresentableNodeDescriptor)object;
TextAttributesKey key = node.getPresentation().getTextAttributesKey();
TextAttributes attributes = key == null ? null : EditorColorsManager.getInstance().getSchemeForCurrentUITheme().getAttributes(key);
Color color = attributes == null ? null : attributes.getErrorStripeColor();
if (color != null) return ErrorStripe.create(color, 1);
}
return null;
}
public static String printWithHighlighting(@Nonnull LanguageConsoleView console, @Nonnull Editor inputEditor, @Nonnull TextRange textRange) {
String text;
EditorHighlighter highlighter;
if (inputEditor instanceof EditorWindow) {
PsiFile file = ((EditorWindow)inputEditor).getInjectedFile();
highlighter = HighlighterFactory.createHighlighter(file.getVirtualFile(), EditorColorsManager.getInstance().getGlobalScheme(), console.getProject());
String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
highlighter.setText(fullText);
text = textRange.substring(fullText);
}
else {
text = inputEditor.getDocument().getText(textRange);
highlighter = ((EditorEx)inputEditor).getHighlighter();
}
SyntaxHighlighter syntax = highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter)highlighter).getSyntaxHighlighter() : null;
LanguageConsoleImpl consoleImpl = (LanguageConsoleImpl)console;
consoleImpl.doAddPromptToHistory();
if (syntax != null) {
ConsoleViewUtil.printWithHighlighting(console, text, syntax, () -> {
String identPrompt = consoleImpl.myConsoleExecutionEditor.getConsolePromptDecorator().getIndentPrompt();
if (StringUtil.isNotEmpty(identPrompt)) {
consoleImpl.addPromptToHistoryImpl(identPrompt);
}
});
}
else {
console.print(text, ConsoleViewContentType.USER_INPUT);
}
console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
return text;
}
@Nonnull
@Override
public EditorHighlighter getHighlighter() {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(myInjectedFile.getLanguage(), getProject(), myInjectedFile.getVirtualFile());
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(syntaxHighlighter, scheme);
highlighter.setText(getDocument().getText());
highlighter.setEditor(new LightHighlighterClient(getDocument(), getProject()));
return highlighter;
}
@Nonnull
public static LineMarkerInfo<PsiElement> createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) {
LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
EditorColorsScheme scheme = colorsManager.getGlobalScheme();
info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
info.separatorPlacement = SeparatorPlacement.TOP;
return info;
}
private int getColumnWidth(int index)
{
int letters = getTypesMaxLength() + (index == 0 ? 1 : getNamesMaxLength() + 2);
Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
font = new Font(font.getFontName(), font.getStyle(), 12);
return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W");
}
@Nonnull
public List<Color> getAuthorsColors(@Nullable EditorColorsScheme scheme) {
if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme();
List<Color> colors = getOrderedColors(scheme);
List<Color> authorColors = new ArrayList<>();
for (int i = 0; i < SHUFFLE_STEP; i++) {
for (int k = 0; k <= colors.size() / SHUFFLE_STEP; k++) {
int index = k * SHUFFLE_STEP + i;
if (index < colors.size()) authorColors.add(colors.get(index));
}
}
return authorColors;
}
private static void highlightInEditor(@Nonnull final Project project, @Nonnull final SimpleMatch match,
@Nonnull final Editor editor, Map<SimpleMatch, RangeHighlighter> highlighterMap) {
final List<RangeHighlighter> highlighters = new ArrayList<>();
final HighlightManager highlightManager = HighlightManager.getInstance(project);
final EditorColorsManager colorsManager = EditorColorsManager.getInstance();
final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
final int startOffset = match.getStartElement().getTextRange().getStartOffset();
final int endOffset = match.getEndElement().getTextRange().getEndOffset();
highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, highlighters);
highlighterMap.put(match, highlighters.get(0));
final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset);
editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE);
}
@Nonnull
public TextAttributes getAttributes(@Nullable Editor editor) {
if (editor == null) {
return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(myKey);
}
else {
return editor.getColorsScheme().getAttributes(myKey);
}
}
private JComponent createOutputTab(JComponent console,
AnAction[] consoleActions) {
JPanel outputTab = new JPanel(new BorderLayout());
console.setFocusable(true);
final Color editorBackground = EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground();
console.setBorder(new CompoundBorder(IdeBorderFactory.createBorder(SideBorder.RIGHT | SideBorder.TOP),
new SideBorder(editorBackground, SideBorder.LEFT)));
outputTab.add(console, BorderLayout.CENTER);
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(consoleActions), false);
outputTab.add(toolbar.getComponent(), BorderLayout.EAST);
return outputTab;
}
public LivePreview(@Nonnull SearchResults searchResults) {
mySearchResults = searchResults;
searchResultsUpdated(searchResults);
searchResults.addListener(this);
EditorUtil.addBulkSelectionListener(mySearchResults.getEditor(), this, myDisposable);
ApplicationManager.getApplication().getMessageBus().connect(myDisposable).subscribe(EditorColorsManager.TOPIC, this);
}
private boolean isUsualAttributes(final TextAttributes ta) {
if (myUsualAttributes == null) {
final EditorColorsManager manager = EditorColorsManager.getInstance();
final EditorColorsScheme[] schemes = manager.getAllSchemes();
EditorColorsScheme defaultScheme = schemes[0];
for (EditorColorsScheme scheme : schemes) {
if (manager.isDefaultScheme(scheme)) {
defaultScheme = scheme;
break;
}
}
myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT);
}
return myUsualAttributes.equals(ta);
}