com.intellij.openapi.editor.impl.EditorImpl Java Examples
The following examples show how to use
com.intellij.openapi.editor.impl.EditorImpl.
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: PromptConsole.java From reasonml-idea-plugin with MIT License | 6 votes |
PromptConsole(@NotNull Project project, ConsoleViewImpl consoleView) { m_consoleView = consoleView; EditorFactory editorFactory = EditorFactory.getInstance(); PsiFileFactory fileFactory = PsiFileFactory.getInstance(project); Document outputDocument = ((EditorFactoryImpl) editorFactory).createDocument(true); UndoUtil.disableUndoFor(outputDocument); m_outputEditor = (EditorImpl) editorFactory.createViewer(outputDocument, project, CONSOLE); PsiFile file = fileFactory.createFileFromText("PromptConsoleDocument.ml", OclLanguage.INSTANCE, ""); Document promptDocument = file.getViewProvider().getDocument(); m_promptEditor = (EditorImpl) editorFactory.createEditor(promptDocument, project, CONSOLE); setupOutputEditor(); setupPromptEditor(); m_consoleView.print("(* ctrl+enter to send a command, ctrl+up/down to cycle through history *)\r\n", USER_INPUT); m_mainPanel.add(m_outputEditor.getComponent(), BorderLayout.CENTER); m_mainPanel.add(m_promptEditor.getComponent(), BorderLayout.SOUTH); }
Example #2
Source File: WidgetIndentsHighlightingPass.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updatePreviewHighlighter(MarkupModel mm, WidgetIndentsPassData data) { final FlutterSettings settings = FlutterSettings.getInstance(); if (!settings.isEnableHotUiInCodeEditor()) return; if (data.previewsForEditor == null && myEditor instanceof EditorImpl) { // TODO(jacobr): is there a way to get access to a disposable that will // trigger when the editor disposes than casting to EditorImpl? final Disposable parentDisposable = ((EditorImpl)myEditor).getDisposable(); final TextRange range = new TextRange(0, Integer.MAX_VALUE); final RangeHighlighter highlighter = mm.addRangeHighlighter( 0, myDocument.getTextLength(), HighlighterLayer.FIRST, null, HighlighterTargetArea.LINES_IN_RANGE ); data.previewsForEditor = new PreviewsForEditor(context, editorEventService, myEditor, parentDisposable); highlighter.setCustomRenderer(data.previewsForEditor); } if (data.previewsForEditor != null) { data.previewsForEditor.outlinesChanged(data.myDescriptors); } }
Example #3
Source File: WidgetIndentsHighlightingPass.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updatePreviewHighlighter(MarkupModel mm, WidgetIndentsPassData data) { final FlutterSettings settings = FlutterSettings.getInstance(); if (!settings.isEnableHotUiInCodeEditor()) return; if (data.previewsForEditor == null && myEditor instanceof EditorImpl) { // TODO(jacobr): is there a way to get access to a disposable that will // trigger when the editor disposes than casting to EditorImpl? final Disposable parentDisposable = ((EditorImpl)myEditor).getDisposable(); final TextRange range = new TextRange(0, Integer.MAX_VALUE); final RangeHighlighter highlighter = mm.addRangeHighlighter( 0, myDocument.getTextLength(), HighlighterLayer.FIRST, null, HighlighterTargetArea.LINES_IN_RANGE ); data.previewsForEditor = new PreviewsForEditor(context, editorEventService, myEditor, parentDisposable); highlighter.setCustomRenderer(data.previewsForEditor); } if (data.previewsForEditor != null) { data.previewsForEditor.outlinesChanged(data.myDescriptors); } }
Example #4
Source File: IdeUtils.java From StringManipulation with Apache License 2.0 | 6 votes |
public static EditorImpl createEditorPreview(String text, boolean editable) { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); ColorAndFontOptions options = new ColorAndFontOptions(); options.reset(); options.selectScheme(scheme.getName()); EditorFactory editorFactory = EditorFactory.getInstance(); Document editorDocument = editorFactory.createDocument(text); EditorEx editor = (EditorEx) (editable ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument)); editor.setColorsScheme(scheme); EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(true); settings.setWhitespacesShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setFoldingOutlineShown(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(0); settings.setRightMarginShown(false); return (EditorImpl) editor; }
Example #5
Source File: AbstractBashSyntaxHighlighterTest.java From BashSupport with Apache License 2.0 | 5 votes |
protected void doLexerHighlightingTest(String fileContent, IElementType targetElementType) { BashSyntaxHighlighter syntaxHighlighter = new BashSyntaxHighlighter(); TextAttributesKey[] keys = syntaxHighlighter.getTokenHighlights(targetElementType); Assert.assertEquals("Expected one key", 1, keys.length); TextAttributesKey attributesKey = keys[0]; Assert.assertNotNull(attributesKey); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme) manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributes targetAttributes = new TextAttributes(JBColor.RED, JBColor.BLUE, JBColor.GRAY, EffectType.BOXED, Font.BOLD); scheme.setAttributes(attributesKey, targetAttributes); myFixture.configureByText(BashFileType.BASH_FILE_TYPE, fileContent); TextAttributes actualAttributes = null; HighlighterIterator iterator = ((EditorImpl) myFixture.getEditor()).getHighlighter().createIterator(0); while (!iterator.atEnd()) { if (iterator.getTokenType() == targetElementType) { actualAttributes = iterator.getTextAttributes(); break; } iterator.advance(); } Assert.assertEquals("Expected text attributes for " + attributesKey, targetAttributes, actualAttributes); }
Example #6
Source File: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public static Optional<VirtualFile> getFileInSelectedEditor(@Nullable Project project) { Optional<Editor> editor = Optional.ofNullable(project) .flatMap(p -> Optional.ofNullable(FileEditorManager.getInstance(p).getSelectedTextEditor())); Optional<EditorImpl> editorImpl = editor .flatMap(e -> e instanceof EditorImpl ? Optional.of((EditorImpl) e) : Optional.empty()); return editorImpl.map(EditorImpl::getVirtualFile); }
Example #7
Source File: PromptConsole.java From reasonml-idea-plugin with MIT License | 4 votes |
@NotNull EditorImpl getOutputEditor() { return m_outputEditor; }
Example #8
Source File: GoalEditor.java From MavenHelper with Apache License 2.0 | 4 votes |
private void createUIComponents() { myEditor = (EditorImpl) createEditor(); cmdPanel = (JPanel) myEditor.getComponent(); cmdPanel.setPreferredSize(new Dimension(800, 50)); }