use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.
the class InlineElementData method addHighlToView.
@Override
public void addHighlToView(Editor view, EditorColorsScheme scheme, Map<TextAttributesKey, String> displayText) {
int offset = getStartOffset();
ParameterHintsPresentationManager.getInstance().addHint(view, offset, myText, false, false);
List<Inlay> inlays = view.getInlayModel().getInlineElementsInRange(offset, offset);
for (Inlay inlay : inlays) {
EditorCustomElementRenderer renderer = inlay.getRenderer();
if (!(renderer instanceof RendererWrapper)) {
Disposer.dispose(inlay);
RendererWrapper wrapper = new RendererWrapper(renderer);
wrapper.drawBorder = myAddBorder;
view.getInlayModel().addInlineElement(offset, wrapper);
}
}
}
use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.
the class EditorInlayTest method testDocumentEditingWithSoftWraps.
public void testDocumentEditingWithSoftWraps() throws Exception {
initText("long line");
configureSoftWraps(7);
Inlay inlay = addInlay(1);
assertNotNull(myEditor.getSoftWrapModel().getSoftWrap(5));
new WriteCommandAction.Simple<Void>(ourProject) {
@Override
protected void run() throws Throwable {
myEditor.getDocument().setText(" ");
}
}.execute();
assertFalse(inlay.isValid());
}
use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.
the class XDebuggerInlayUtil method createInlay.
public static void createInlay(@NotNull Project project, @NotNull VirtualFile file, int offset, String inlayText) {
UIUtil.invokeLaterIfNeeded(() -> {
FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(file);
if (editor instanceof TextEditor) {
Editor e = ((TextEditor) editor).getEditor();
CharSequence text = e.getDocument().getImmutableCharSequence();
int insertOffset = offset;
while (insertOffset < text.length() && Character.isJavaIdentifierPart(text.charAt(insertOffset))) insertOffset++;
List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(insertOffset, insertOffset);
for (Inlay inlay : existing) {
if (inlay.getRenderer() instanceof MyRenderer) {
Disposer.dispose(inlay);
}
}
e.getInlayModel().addInlineElement(insertOffset, new MyRenderer(inlayText));
}
});
}
use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.
the class InlayModelImpl method getElementAt.
@Nullable
@Override
public Inlay getElementAt(@NotNull Point point) {
if (myInlayTree.size() == 0)
return null;
int offset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(point));
List<Inlay> inlays = getInlineElementsInRange(offset, offset);
if (inlays.isEmpty())
return null;
VisualPosition startVisualPosition = myEditor.offsetToVisualPosition(offset);
int x = myEditor.visualPositionToXY(startVisualPosition).x;
for (Inlay inlay : inlays) {
int endX = x + inlay.getWidthInPixels();
if (point.x >= x && point.x < endX)
return inlay;
x = endX;
}
return null;
}
Aggregations