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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations