Java Code Examples for com.intellij.openapi.editor.ex.EditorEx#setBackgroundColor()
The following examples show how to use
com.intellij.openapi.editor.ex.EditorEx#setBackgroundColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorFragmentComponent.java From consulo with Apache License 2.0 | 6 votes |
/** * @param component Should be provided if editor is not currently displayable. * Makes for correct rendering on multi-monitor configurations. */ private static EditorFragmentComponent createEditorFragmentComponent(Component component, Editor editor, int startLine, int endLine, boolean showFolding, boolean showGutter, boolean useCaretRowBackground) { final EditorEx editorEx = (EditorEx)editor; final Color old = editorEx.getBackgroundColor(); Color backColor = getBackgroundColor(editor, useCaretRowBackground); editorEx.setBackgroundColor(backColor); EditorFragmentComponent fragmentComponent = new EditorFragmentComponent(component, editorEx, startLine, endLine, showFolding, showGutter); fragmentComponent.setBackground(backColor); editorEx.setBackgroundColor(old); return fragmentComponent; }
Example 2
Source File: EditorTextField.java From consulo with Apache License 2.0 | 6 votes |
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())); }
Example 3
Source File: RecentLocationsRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static JComponent setupEditorComponent(@Nonnull EditorEx editor, @Nonnull String text, @Nonnull SpeedSearch speedSearch, @Nonnull EditorColorsScheme colorsScheme, boolean selected) { Iterable<TextRange> ranges = speedSearch.matchingFragments(text); if (ranges != null) { selectSearchResultsInEditor(editor, ranges.iterator()); } else { RecentLocationsAction.clearSelectionInEditor(editor); } editor.setBackgroundColor(getBackgroundColor(colorsScheme, selected)); editor.setBorder(JBUI.Borders.empty(0, 4, 6, 0)); if (EMPTY_FILE_TEXT.equals(editor.getDocument().getText())) { editor.getMarkupModel().addRangeHighlighter(0, EMPTY_FILE_TEXT.length(), HighlighterLayer.SYNTAX, createEmptyTextForegroundTextAttributes(colorsScheme), HighlighterTargetArea.EXACT_RANGE); } return editor.getComponent(); }
Example 4
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 6 votes |
public static EditorEx createPreviewComponent(Project project, FileType languageFileType) { Document document = EditorFactory.getInstance().createDocument(""); UndoUtil.disableUndoFor(document); EditorEx previewEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, project, languageFileType, true); previewEditor.setOneLineMode(true); final EditorSettings settings = previewEditor.getSettings(); settings.setAdditionalLinesCount(0); settings.setAdditionalColumnsCount(1); settings.setRightMarginShown(false); settings.setFoldingOutlineShown(false); settings.setLineNumbersShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); previewEditor.setHorizontalScrollbarVisible(false); previewEditor.setVerticalScrollbarVisible(false); previewEditor.setCaretEnabled(false); settings.setLineCursorWidth(1); final Color bg = previewEditor.getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR); previewEditor.setBackgroundColor(bg); previewEditor.setBorder(BorderFactory.createCompoundBorder(new DottedBorder(Color.gray), new LineBorder(bg, 2))); return previewEditor; }
Example 5
Source File: EditorTextField.java From consulo with Apache License 2.0 | 4 votes |
protected EditorEx createEditor() { LOG.assertTrue(myDocument != null); final EditorFactory factory = EditorFactory.getInstance(); EditorEx editor = (EditorEx)(myIsViewer ? factory.createViewer(myDocument, myProject) : factory.createEditor(myDocument, myProject)); final EditorSettings settings = editor.getSettings(); settings.setAdditionalLinesCount(0); settings.setAdditionalColumnsCount(1); settings.setRightMarginShown(false); settings.setRightMargin(-1); settings.setFoldingOutlineShown(false); settings.setLineNumbersShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setAdditionalPageAtBottom(false); editor.setHorizontalScrollbarVisible(false); editor.setVerticalScrollbarVisible(false); editor.setCaretEnabled(!myIsViewer); settings.setLineCursorWidth(1); JScrollPane scrollPane = editor.getScrollPane(); scrollPane.setBorder(JBUI.Borders.empty()); scrollPane.setViewportBorder(JBUI.Borders.empty()); if (myProject != null) { PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); if (psiFile != null) { DaemonCodeAnalyzer.getInstance(myProject).setHighlightingEnabled(psiFile, !myIsViewer); } } if (myProject != null && myFileType != null) { editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFileType)); } editor.getSettings().setCaretRowShown(false); editor.setOneLineMode(myOneLineMode); editor.getCaretModel().moveToOffset(myDocument.getTextLength()); if (myIsViewer) { editor.getSelectionModel().removeSelection(); } else if (myWholeTextSelected) { doSelectAll(editor); myWholeTextSelected = false; } editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary); editor.getContentComponent().setFocusCycleRoot(false); editor.getContentComponent().addFocusListener(myProxyListeners); editor.getContentComponent().addMouseListener(myProxyListeners); editor.setPlaceholder(myHintText); initOneLineMode(editor); if (myIsRendererWithSelection) { ((DesktopEditorImpl)editor).setPaintSelection(true); editor.getColorsScheme().setColor(EditorColors.SELECTION_BACKGROUND_COLOR, myRendererBg); editor.getColorsScheme().setColor(EditorColors.SELECTION_FOREGROUND_COLOR, myRendererFg); editor.getSelectionModel().setSelection(0, myDocument.getTextLength()); editor.setBackgroundColor(myRendererBg); } for (EditorSettingsProvider provider : mySettingsProviders) { provider.customizeSettings(editor); } return editor; }