use of com.intellij.openapi.editor.event.CaretEvent in project intellij-community by JetBrains.
the class EmmetPreviewUtil method addEmmetPreviewListeners.
public static void addEmmetPreviewListeners(@NotNull final Editor editor, @NotNull final PsiFile file, final boolean expandPrimitiveAbbreviations) {
editor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(@NotNull DocumentEvent e) {
EmmetPreviewHint existingHint = EmmetPreviewHint.getExistingHint(editor);
if (existingHint != null) {
existingHint.updateText(new TemplateTextProducer(editor, file, expandPrimitiveAbbreviations));
} else {
e.getDocument().removeDocumentListener(this);
}
}
});
editor.getCaretModel().addCaretListener(new CaretAdapter() {
@Override
public void caretPositionChanged(@NotNull CaretEvent e) {
EmmetPreviewHint existingHint = EmmetPreviewHint.getExistingHint(e.getEditor());
if (existingHint != null) {
existingHint.updateText(new TemplateTextProducer(editor, file, expandPrimitiveAbbreviations));
} else {
e.getEditor().getCaretModel().removeCaretListener(this);
}
}
});
}
Aggregations