Java Code Examples for com.intellij.openapi.editor.ex.EditorEx#getSettings()
The following examples show how to use
com.intellij.openapi.editor.ex.EditorEx#getSettings() .
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: ProjectViewUi.java From intellij with Apache License 2.0 | 6 votes |
private static EditorEx createEditor(String tooltip) { Project project = getProject(); Document document = LanguageTextField.createDocument( /* value= */ "", ProjectViewLanguage.INSTANCE, project, new SimpleDocumentCreator()); EditorEx editor = (EditorEx) EditorFactory.getInstance() .createEditor(document, project, ProjectViewFileType.INSTANCE, false); final EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(false); settings.setLineMarkerAreaShown(false); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setAdditionalPageAtBottom(false); editor.getComponent().setMinimumSize(getEditorSize()); editor.getComponent().setPreferredSize(getEditorSize()); editor.getComponent().setToolTipText(tooltip); editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); return editor; }
Example 2
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 3
Source File: Utils.java From idea-gitignore with MIT License | 6 votes |
/** * Creates and configures template preview editor. * * @param document virtual editor document * @param project current project * @return editor */ @NotNull public static Editor createPreviewEditor(@NotNull Document document, @Nullable Project project, boolean isViewer) { EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, IgnoreFileType.INSTANCE, isViewer); editor.setCaretEnabled(!isViewer); final EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(false); settings.setAdditionalColumnsCount(1); settings.setAdditionalLinesCount(0); settings.setRightMarginShown(false); settings.setFoldingOutlineShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); EditorColorsScheme colorsScheme = editor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); return editor; }
Example 4
Source File: GoalEditor.java From MavenHelper with Apache License 2.0 | 6 votes |
@NotNull private static Editor createEditor() { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); ColorAndFontOptions options = new ColorAndFontOptions(); options.reset(); options.selectScheme(scheme.getName()); EditorFactory editorFactory = EditorFactory.getInstance(); Document editorDocument = editorFactory.createDocument(""); EditorEx editor = (EditorEx) (true ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument)); editor.setColorsScheme(scheme); EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(false); settings.setUseSoftWraps(true); settings.setWhitespacesShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setFoldingOutlineShown(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(0); settings.setRightMarginShown(false); return editor; }
Example 5
Source File: IntentionUsagePanel.java From consulo with Apache License 2.0 | 6 votes |
private 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; }
Example 6
Source File: ActionUsagePanel.java From consulo with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: FontEditorPreview.java From consulo with Apache License 2.0 | 6 votes |
static Editor createPreviewEditor(String text, int column, int line, int selectedLine, ColorAndFontOptions options, boolean editable) { EditorFactory editorFactory = EditorFactory.getInstance(); Document editorDocument = editorFactory.createDocument(text); EditorEx editor = (EditorEx) (editable ? editorFactory.createEditor(editorDocument) : editorFactory.createViewer(editorDocument)); editor.setColorsScheme(options.getSelectedScheme()); EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(true); 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; }
Example 8
Source File: DetailViewImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull protected Editor createEditor(@Nullable Project project, Document document, VirtualFile file) { EditorEx editor = (EditorEx)EditorFactory.getInstance().createViewer(document, project); final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); editor.setFile(file); editor.setHighlighter(highlighter); EditorSettings settings = editor.getSettings(); settings.setAnimatedScrolling(false); settings.setRefrainFromScrolling(false); settings.setLineNumbersShown(true); settings.setFoldingOutlineShown(false); if (settings instanceof SettingsImpl) { ((SettingsImpl)settings).setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.PREVIEW); } editor.getFoldingModel().setFoldingEnabled(false); return editor; }
Example 9
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 10
Source File: LanguageConsoleImpl.java From consulo with Apache License 2.0 | 5 votes |
public void setupEditor(@Nonnull EditorEx editor) { ConsoleViewUtil.setupConsoleEditor(editor, false, false); editor.getContentComponent().setFocusCycleRoot(false); editor.setHorizontalScrollbarVisible(true); editor.setVerticalScrollbarVisible(true); editor.setBorder(null); EditorSettings editorSettings = editor.getSettings(); editorSettings.setAdditionalLinesCount(1); editorSettings.setAdditionalColumnsCount(1); DataManager.registerDataProvider(editor.getComponent(), (dataId) -> getEditorData(editor, dataId)); }
Example 11
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; }
Example 12
Source File: EditorTextFieldProviderImpl.java From consulo with Apache License 2.0 | 4 votes |
private static void applyDefaultSettings(EditorEx ex) { EditorSettings settings = ex.getSettings(); settings.setAdditionalColumnsCount(3); settings.setVirtualSpace(false); }