Search in sources :

Example 16 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class DiffSideView method getCurrentOpenFileDescriptor.

@Nullable
public OpenFileDescriptor getCurrentOpenFileDescriptor() {
    final EditorEx editor = myEditorSource.getEditor();
    final DiffContent content = myEditorSource.getContent();
    if (content == null || editor == null) {
        return null;
    }
    return content.getOpenFileDescriptor(editor.getCaretModel().getOffset());
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) DiffContent(com.intellij.openapi.diff.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class EditVarConstraintsDialog method createEditor.

private static Editor createEditor(final Project project, final String text, final String fileName) {
    final FileType fileType = getFileType(fileName);
    final Document doc = createDocument(fileName, fileType, text);
    final Editor editor = EditorFactory.getInstance().createEditor(doc, project);
    ((EditorEx) editor).setEmbeddedIntoDialogWrapper(true);
    final EditorSettings settings = editor.getSettings();
    settings.setLineNumbersShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    ((EditorEx) editor).setHighlighter(HighlighterFactory.createHighlighter(fileType, DefaultColorSchemesManager.getInstance().getFirstScheme(), project));
    return editor;
}
Also used : EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) FileType(com.intellij.openapi.fileTypes.FileType) Document(com.intellij.openapi.editor.Document) Editor(com.intellij.openapi.editor.Editor)

Example 18 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class UIUtil method createEditor.

@NotNull
public static Editor createEditor(@NotNull Document doc, final Project project, boolean editable, boolean addToolTipForVariableHandler, @Nullable TemplateContextType contextType) {
    final Editor editor = editable ? EditorFactory.getInstance().createEditor(doc, project) : EditorFactory.getInstance().createViewer(doc, project);
    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setVirtualSpace(false);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineNumbersShown(false);
    editorSettings.setFoldingOutlineShown(false);
    editorSettings.setCaretRowShown(false);
    if (!editable) {
        final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
        Color c = globalScheme.getColor(EditorColors.READONLY_BACKGROUND_COLOR);
        if (c == null) {
            c = globalScheme.getDefaultBackground();
        }
        ((EditorEx) editor).setBackgroundColor(c);
    } else {
        ((EditorEx) editor).setEmbeddedIntoDialogWrapper(true);
    }
    TemplateEditorUtil.setHighlighter(editor, contextType);
    if (addToolTipForVariableHandler) {
        SubstitutionShortInfoHandler handler = new SubstitutionShortInfoHandler(editor);
        editor.addEditorMouseMotionListener(handler);
        editor.getDocument().addDocumentListener(handler);
        editor.getCaretModel().addCaretListener(handler);
        editor.putUserData(LISTENER_KEY, handler);
    }
    return editor;
}
Also used : EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class EditorFactoryImpl method createEditor.

@Override
public Editor createEditor(@NotNull Document document, Project project, @NotNull VirtualFile file, boolean isViewer) {
    Editor editor = createEditor(document, isViewer, project);
    ((EditorEx) editor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file));
    return editor;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) Editor(com.intellij.openapi.editor.Editor)

Example 20 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class EditorTextField method createEditor.

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);
    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 (!shouldHaveBorder()) {
        editor.setBorder(null);
    }
    if (myIsViewer) {
        editor.getSelectionModel().removeSelection();
    } else if (myWholeTextSelected) {
        doSelectAll(editor);
        myWholeTextSelected = false;
    }
    editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary);
    editor.getContentComponent().setFocusCycleRoot(false);
    editor.getContentComponent().addFocusListener(this);
    editor.setPlaceholder(myHintText);
    initOneLineMode(editor);
    if (myIsRendererWithSelection) {
        ((EditorImpl) 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;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) PsiFile(com.intellij.psi.PsiFile)

Aggregations

EditorEx (com.intellij.openapi.editor.ex.EditorEx)164 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)36 Editor (com.intellij.openapi.editor.Editor)35 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)33 Document (com.intellij.openapi.editor.Document)29 NotNull (org.jetbrains.annotations.NotNull)26 IElementType (com.intellij.psi.tree.IElementType)14 Nullable (org.jetbrains.annotations.Nullable)13 Project (com.intellij.openapi.project.Project)12 PsiFile (com.intellij.psi.PsiFile)12 EditorFactory (com.intellij.openapi.editor.EditorFactory)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 TextRange (com.intellij.openapi.util.TextRange)10 FileType (com.intellij.openapi.fileTypes.FileType)8 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)7 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)7 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)6 Language (com.intellij.lang.Language)6 CaretModel (com.intellij.openapi.editor.CaretModel)6 EditorGutterComponentEx (com.intellij.openapi.editor.ex.EditorGutterComponentEx)6