use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class JavaBraceMatcherTest method testBinaryStatement.
public void testBinaryStatement() {
myFixture.configureByText("a.java", "import java.util.ArrayList;" + "class A {" + " int i = 3 <caret>< 4 ? 5 > 6 : 1 : 1 : 1;" + "}");
final Editor editor = myFixture.getEditor();
final EditorHighlighter editorHighlighter = ((EditorEx) editor).getHighlighter();
final HighlighterIterator iterator = editorHighlighter.createIterator(editor.getCaretModel().getOffset());
boolean matched = BraceMatchingUtil.matchBrace(editor.getDocument().getCharsSequence(), myFixture.getFile().getFileType(), iterator, true);
assertFalse(matched);
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-code-outline by sitano.
the class CodeOutlineImageEx method renderRestOfLineToImg.
/**
* Renders the characters at the given document offset to the code outline
* image until the first newline character is reached or until the right
* edge of the image is reached and no more characters can be rendered.
*
* @param startOff the offset into the document at which to start rendering
* @return how many characters were rendered, not including the newline
*/
@Override
protected int renderRestOfLineToImg(int startOff) {
final CharSequence chars = document.getCharsSequence();
final int endOff = document.getTextLength();
if (startOff >= endOff)
return 0;
final LogicalPosition startPos = editor.offsetToLogicalPosition(startOff);
final int line = startPos.line;
final EditorEx ex = (EditorEx) editor;
final EditorHighlighter hl = ex.getHighlighter();
final HighlighterIterator hi = hl.createIterator(startOff);
int col = startPos.column;
int painted = 0;
for (int i = startOff; i < endOff; i++) {
final char ch = chars.charAt(i);
while (!hi.atEnd() && i > hi.getEnd()) {
hi.advance();
}
if (ch == '\n')
break;
if (col >= visibleImgWidth)
break;
drawChar(ch, col, line, getCharColor(editor, hi));
painted++;
col++;
}
return painted;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-plugins by JetBrains.
the class MarkdownCssSettingsForm method createEditor.
@NotNull
private static Editor createEditor() {
EditorFactory editorFactory = EditorFactory.getInstance();
Document editorDocument = editorFactory.createDocument("");
EditorEx editor = (EditorEx) editorFactory.createEditor(editorDocument);
fillEditorSettings(editor.getSettings());
setHighlighting(editor);
return editor;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-plugins by JetBrains.
the class ManifestEditor method createEditor.
@Override
protected EditorEx createEditor() {
EditorEx editor = super.createEditor();
editor.setVerticalScrollbarVisible(true);
editor.setHorizontalScrollbarVisible(true);
return editor;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class CheckRegExpForm method createUIComponents.
private void createUIComponents() {
myProject = myRegexpFile.getProject();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(myRegexpFile);
final Language language = myRegexpFile.getLanguage();
final LanguageFileType fileType;
if (language instanceof RegExpLanguage) {
fileType = RegExpLanguage.INSTANCE.getAssociatedFileType();
} else {
// for correct syntax highlighting
fileType = new RegExpFileType(language);
}
myRegExp = new EditorTextField(document, myProject, fileType);
final String sampleText = PropertiesComponent.getInstance(myProject).getValue(LAST_EDITED_REGEXP, "Sample Text");
mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE) {
@Override
protected void updateBorder(@NotNull EditorEx editor) {
setupBorder(editor);
}
};
mySampleText.setOneLineMode(false);
int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width);
myRegExp.setPreferredWidth(preferredWidth);
mySampleText.setPreferredWidth(preferredWidth);
myRootPanel = new JPanel(new BorderLayout()) {
Disposable disposable;
Alarm updater;
@Override
public void addNotify() {
super.addNotify();
disposable = Disposer.newDisposable();
IdeFocusManager.getGlobalInstance().requestFocus(mySampleText, true);
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
IdeFocusManager.findInstance().requestFocus(myRegExp.getFocusTarget(), true);
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), mySampleText);
updater = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable);
DocumentAdapter documentListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
update();
}
};
myRegExp.addDocumentListener(documentListener);
mySampleText.addDocumentListener(documentListener);
update();
mySampleText.selectAll();
}
public void update() {
final TransactionId transactionId = TransactionGuard.getInstance().getContextTransaction();
updater.cancelAllRequests();
if (!updater.isDisposed()) {
updater.addRequest(() -> {
final RegExpMatchResult result = isMatchingText(myRegexpFile, mySampleText.getText());
TransactionGuard.getInstance().submitTransaction(myProject, transactionId, () -> setBalloonState(result));
}, 200);
}
}
@Override
public void removeNotify() {
super.removeNotify();
Disposer.dispose(disposable);
PropertiesComponent.getInstance(myProject).setValue(LAST_EDITED_REGEXP, mySampleText.getText());
}
};
myRootPanel.setBorder(JBUI.Borders.empty(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
}
Aggregations