Search in sources :

Example 11 with EditorImpl

use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.

the class CodeInsightTestCase method createEditor.

protected Editor createEditor(@NotNull VirtualFile file) {
    final FileEditorManager instance = FileEditorManager.getInstance(myProject);
    if (file.getFileType().isBinary())
        return null;
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    Editor editor = instance.openTextEditor(new OpenFileDescriptor(myProject, file, 0), false);
    ((EditorImpl) editor).setCaretActive();
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    DaemonCodeAnalyzer.getInstance(getProject()).restart();
    return editor;
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor)

Example 12 with EditorImpl

use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.

the class EventLogConsole method installNotificationsFont.

private void installNotificationsFont(@NotNull final EditorEx editor) {
    final DelegateColorScheme globalScheme = new DelegateColorScheme(EditorColorsManager.getInstance().getGlobalScheme()) {

        @Override
        public String getEditorFontName() {
            return getConsoleFontName();
        }

        @Override
        public int getEditorFontSize() {
            return getConsoleFontSize();
        }

        @Override
        public String getConsoleFontName() {
            return NotificationsUtil.getFontName();
        }

        @Override
        public int getConsoleFontSize() {
            Pair<String, Integer> data = NotificationsUtil.getFontData();
            return data == null ? super.getConsoleFontSize() : data.second;
        }

        @Override
        public void setEditorFontName(String fontName) {
        }

        @Override
        public void setConsoleFontName(String fontName) {
        }

        @Override
        public void setEditorFontSize(int fontSize) {
        }

        @Override
        public void setConsoleFontSize(int fontSize) {
        }
    };
    ApplicationManager.getApplication().getMessageBus().connect(myProjectModel).subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {

        @Override
        public void globalSchemeChange(EditorColorsScheme scheme) {
            globalScheme.setDelegate(EditorColorsManager.getInstance().getGlobalScheme());
            editor.reinitSettings();
        }
    });
    editor.setColorsScheme(ConsoleViewUtil.updateConsoleColorScheme(editor.createBoundColorSchemeDelegate(globalScheme)));
    if (editor instanceof EditorImpl) {
        ((EditorImpl) editor).setUseEditorAntialiasing(false);
    }
}
Also used : EditorColorsListener(com.intellij.openapi.editor.colors.EditorColorsListener) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) DelegateColorScheme(com.intellij.openapi.editor.colors.impl.DelegateColorScheme)

Example 13 with EditorImpl

use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.

the class SoftWrapApplianceOnDocumentModificationTest method testLeadingTabWithShiftedWidth.

public void testLeadingTabWithShiftedWidth() throws IOException {
    // Inspired by IDEA-76353. The point is that we need to consider cached information about tab symbols width during logical
    // position to offset mapping
    String text = "\t test";
    init(15, text);
    ((EditorImpl) myEditor).setPrefixTextAndAttributes(" ", new TextAttributes());
    myEditor.getCaretModel().moveToOffset(text.length());
}
Also used : EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 14 with EditorImpl

use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-plugins by JetBrains.

the class SwfHighlightingTest method testLineMarkersInSwf.

@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithLineMarkers })
public void testLineMarkersInSwf() throws Exception {
    final String testName = getTestName(false);
    myAfterCommitRunnable = () -> FlexTestUtils.addLibrary(myModule, "lib", getTestDataPath() + getBasePath() + "/", testName + ".swc", null, null);
    // actual test data is in library.swf; this file is here just because we need any file
    configureByFile("/" + testName + ".as");
    VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + ".swc");
    vFile = JarFileSystem.getInstance().getJarRootForLocalFile(vFile).findChild("library.swf");
    myEditor = FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, vFile, 0), false);
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    myFile = myPsiManager.findFile(vFile);
    ((EditorImpl) myEditor).setCaretActive();
    vFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + ".as");
    final String verificationText = StreamUtil.convertSeparators(VfsUtilCore.loadText(vFile));
    checkHighlighting(new ExpectedHighlightingData(new DocumentImpl(verificationText), false, false, true, myFile));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 15 with EditorImpl

use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-plugins by JetBrains.

the class SwfHighlightingTest method testProtectSwf.

public void testProtectSwf() throws Exception {
    configureByFiles((String) null);
    VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + getTestName(false) + ".swf");
    myEditor = FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, vFile, 0), false);
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    myFile = myPsiManager.findFile(vFile);
    ((EditorImpl) myEditor).setCaretActive();
    assertFalse(FileDocumentManager.getInstance().requestWriting(myEditor.getDocument(), myProject));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor)

Aggregations

EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)34 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)8 Editor (com.intellij.openapi.editor.Editor)7 LightweightHint (com.intellij.ui.LightweightHint)6 Document (com.intellij.openapi.editor.Document)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 EditorMouseFixture (com.intellij.testFramework.fixtures.EditorMouseFixture)3 NotNull (org.jetbrains.annotations.NotNull)3 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 SoftWrap (com.intellij.openapi.editor.SoftWrap)2 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 FoldingModelEx (com.intellij.openapi.editor.ex.FoldingModelEx)2 SoftWrapModelImpl (com.intellij.openapi.editor.impl.SoftWrapModelImpl)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Project (com.intellij.openapi.project.Project)2 HintHint (com.intellij.ui.HintHint)2 EditorHintListener (com.intellij.codeInsight.hint.EditorHintListener)1