/** * Scrolls the editor to place the given visual line in the middle of the current window. * * @param editor The editor to scroll * @param visualLine The visual line to place in the middle of the current window */ public static void scrollVisualLineToMiddleOfScreen(@NotNull Editor editor, int visualLine) { final ScrollingModel scrollingModel = editor.getScrollingModel(); int y = editor.visualLineToY(visualLine); int lineHeight = editor.getLineHeight(); int height = scrollingModel.getVisibleArea().height; scrollingModel.scrollVertically(y - ((height - lineHeight) / 2)); }
/** * Scrolls the editor to put the given visual line at the top of the current window. Ensures that any block inlay * elements above the given line are also visible. * * @param editor The editor to scroll * @param visualLine The visual line to place at the top of the current window * @return Returns true if the window was moved */ public static boolean scrollVisualLineToTopOfScreen(@NotNull final Editor editor, int visualLine) { final ScrollingModel scrollingModel = editor.getScrollingModel(); int inlayHeight = getHeightOfVisualLineInlays(editor, visualLine, true); int y = editor.visualLineToY(visualLine) - inlayHeight; int verticalPos = scrollingModel.getVerticalScrollOffset(); scrollingModel.scrollVertically(y); return verticalPos != scrollingModel.getVerticalScrollOffset(); }
scrollingModel.scrollVertically(yVisualLine - caretScreenOffset - inlayOffset);
scrollingModel.scrollVertically(topY - topLineInlayHeight);
/** * Turns off the ex entry field and optionally puts the focus back to the original component */ public void deactivate(boolean refocusOwningEditor) { logger.info("deactivate"); if (!active) return; active = false; if (!ApplicationManager.getApplication().isUnitTestMode()) { if (refocusOwningEditor && parent != null) { UiHelper.requestFocus(parent); } oldGlass.removeComponentListener(adapter); oldGlass.setVisible(false); oldGlass.remove(this); oldGlass.setOpaque(wasOpaque); oldGlass.setLayout(oldLayout); if (isIncSearchEnabled(label.getText())) { entry.getDocument().removeDocumentListener(documentListener); final Editor editor = entry.getEditor(); editor.getScrollingModel().scrollVertically(verticalOffset); editor.getScrollingModel().scrollHorizontally(horizontalOffset); if (incHighlighter != null) { editor.getMarkupModel().removeHighlighter(incHighlighter); } } } parent = null; }