use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class LexerEditorHighlighter method createIterator.
@NotNull
@Override
public HighlighterIterator createIterator(int startOffset) {
synchronized (this) {
if (!isInSyncWithDocument()) {
final Document document = getDocument();
assert document != null;
if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate()) {
// bulk mode failed
((DocumentEx) document).setInBulkUpdate(false);
}
doSetText(document.getImmutableCharSequence());
}
final int latestValidOffset = mySegments.getLastValidOffset();
return new HighlighterIteratorImpl(startOffset <= latestValidOffset ? startOffset : latestValidOffset);
}
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class StatusBarUpdater method updateStatus.
private void updateStatus() {
Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if (editor == null || !editor.getContentComponent().hasFocus()) {
return;
}
final Document document = editor.getDocument();
if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate())
return;
int offset = editor.getCaretModel().getOffset();
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
HighlightInfo info = ((DaemonCodeAnalyzerImpl) codeAnalyzer).findHighlightByOffset(document, offset, false, MIN);
String text = info != null && info.getDescription() != null ? info.getDescription() : "";
StatusBar statusBar = WindowManager.getInstance().getStatusBar(editor.getContentComponent(), myProject);
if (statusBar != null && !text.equals(statusBar.getInfo())) {
statusBar.setInfo(text, "updater");
}
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class BraceHighlighter method updateBraces.
static void updateBraces(@NotNull final Editor editor, @NotNull final Alarm alarm) {
final Document document = editor.getDocument();
if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate())
return;
BraceHighlightingHandler.lookForInjectedAndMatchBracesInOtherThread(editor, alarm, handler -> {
handler.updateBraces();
return false;
});
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class ApplyChangesState method setDone.
@Override
protected void setDone(boolean done) {
super.setDone(done);
if (myResetBulkUpdateState) {
DocumentEx document = getAffectedDocument(myModel);
if (document != null) {
document.setInBulkUpdate(false);
myResetBulkUpdateState = false;
}
}
if (done) {
myModel.commitChanges();
}
}
use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method createInterruptAction.
private AnAction createInterruptAction() {
AnAction anAction = new AnAction() {
@Override
public void actionPerformed(final AnActionEvent e) {
if (myPydevConsoleCommunication.isExecuting() || myPydevConsoleCommunication.isWaitingForInput()) {
myConsoleView.print("^C", ProcessOutputTypes.SYSTEM);
myPydevConsoleCommunication.interrupt();
} else {
DocumentEx document = myConsoleView.getConsoleEditor().getDocument();
if (!(document.getTextLength() == 0)) {
ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().runUndoTransparentAction(() -> document.deleteString(0, document.getLineEndOffset(document.getLineCount() - 1))));
}
}
}
@Override
public void update(final AnActionEvent e) {
EditorEx consoleEditor = myConsoleView.getConsoleEditor();
boolean enabled = IJSwingUtilities.hasFocus(consoleEditor.getComponent()) && !consoleEditor.getSelectionModel().hasSelection();
e.getPresentation().setEnabled(enabled);
}
};
anAction.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.CTRL_MASK, myConsoleView.getConsoleEditor().getComponent());
anAction.getTemplatePresentation().setVisible(false);
return anAction;
}
Aggregations