mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expose EditorImpl's getAscent() method in Editor interface
GitOrigin-RevId: a75822a2367a2d82623df60f9375804875e08efa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
05db0f3fd5
commit
19aabfcbe3
@@ -4,6 +4,7 @@ package com.intellij.openapi.editor;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEventArea;
|
||||
import com.intellij.openapi.editor.event.EditorMouseListener;
|
||||
import com.intellij.openapi.editor.event.EditorMouseMotionListener;
|
||||
@@ -444,4 +445,14 @@ public interface Editor extends UserDataHolder {
|
||||
|
||||
@NotNull
|
||||
EditorKind getEditorKind();
|
||||
|
||||
/**
|
||||
* Vertical distance, in pixels, between the top of visual line (corresponding coordinate is returned by {@link #visualLineToY(int)},
|
||||
* {@link #visualPositionToXY(VisualPosition)}, etc) and baseline of text in that visual line.
|
||||
*/
|
||||
default int getAscent() {
|
||||
// actual implementation in EditorImpl is a bit more complex, but this gives an idea how it's constructed
|
||||
return (int)(getContentComponent().getFontMetrics(getColorsScheme().getFont(EditorFontType.PLAIN)).getAscent() *
|
||||
getColorsScheme().getLineSpacing());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,4 +304,9 @@ class LazyEditor extends UserDataHolderBase implements Editor {
|
||||
public IndentsModel getIndentsModel() {
|
||||
return getEditor().getIndentsModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAscent() {
|
||||
return getEditor().getAscent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class LookupPreview {
|
||||
Editor editor = inlay.getEditor();
|
||||
g.setColor(JBColor.GRAY);
|
||||
g.setFont(getFont(editor));
|
||||
g.drawString(suffix, r.x, r.y + ((EditorImpl)editor).getAscent());
|
||||
g.drawString(suffix, r.x, r.y + editor.getAscent());
|
||||
}
|
||||
|
||||
private Font getFont(@NotNull Editor editor) {
|
||||
|
||||
+5
@@ -905,4 +905,9 @@ class EditorWindowImpl extends com.intellij.injected.editor.EditorWindowImpl imp
|
||||
public void setCustomCursor(@NotNull Object requestor, @Nullable Cursor cursor) {
|
||||
myDelegate.setCustomCursor(requestor, cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAscent() {
|
||||
return myDelegate.getAscent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2063,6 +2063,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return myCaretCursor.getCaretLocations(onlyIfShown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAscent() {
|
||||
return myView.getAscent();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.openapi.editor.Inlay;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.FontPreferences;
|
||||
import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.impl.FontInfo;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
@@ -145,7 +144,7 @@ public class XDebuggerInlayUtil {
|
||||
int xEnd = editor.offsetToXY(value.refEndOffset, false, true).x;
|
||||
int width = g.getFontMetrics().stringWidth(value.value);
|
||||
curX = Math.max(curX, (xStart + xEnd - width) / 2);
|
||||
g.drawString(value.value, curX, targetRegion.y + ((EditorImpl)editor).getAscent());
|
||||
g.drawString(value.value, curX, targetRegion.y + editor.getAscent());
|
||||
g.drawLine(Math.min(xEnd, Math.max(xStart, curX + width / 2)), targetRegion.y, curX + width / 2, targetRegion.y + 2);
|
||||
g.drawLine(curX, targetRegion.y + 2, curX + width, targetRegion.y + 2);
|
||||
curX += width;
|
||||
|
||||
Reference in New Issue
Block a user