Java Code Examples for com.intellij.openapi.editor.ScrollingModel#enableAnimation()
The following examples show how to use
com.intellij.openapi.editor.ScrollingModel#enableAnimation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextStartAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void execute(Editor editor, DataContext dataContext) { editor.getCaretModel().removeSecondaryCarets(); editor.getCaretModel().moveToOffset(0); editor.getSelectionModel().removeSelection(); ScrollingModel scrollingModel = editor.getScrollingModel(); scrollingModel.disableAnimation(); scrollingModel.scrollToCaret(ScrollType.RELATIVE); scrollingModel.enableAnimation(); Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project != null) { IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project); if (instance != null) { instance.includeCurrentCommandAsNavigation(); } } }
Example 2
Source File: TextEndAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void execute(Editor editor, DataContext dataContext) { editor.getCaretModel().removeSecondaryCarets(); int offset = editor.getDocument().getTextLength(); if (editor instanceof DesktopEditorImpl) { editor.getCaretModel().moveToLogicalPosition(editor.offsetToLogicalPosition(offset).leanForward(true)); } else { editor.getCaretModel().moveToOffset(offset); } editor.getSelectionModel().removeSelection(); ScrollingModel scrollingModel = editor.getScrollingModel(); scrollingModel.disableAnimation(); scrollingModel.scrollToCaret(ScrollType.CENTER); scrollingModel.enableAnimation(); Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project != null) { IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project); if (instance != null) { instance.includeCurrentCommandAsNavigation(); } } }
Example 3
Source File: SyncScrollSupport.java From consulo with Apache License 2.0 | 5 votes |
private static void doScrollVertically(@Nonnull ScrollingModel model, int offset) { model.disableAnimation(); try { model.scrollVertically(offset); } finally { model.enableAnimation(); } }
Example 4
Source File: SyncScrollSupport.java From consulo with Apache License 2.0 | 5 votes |
private static void doScrollHorizontally(@Nonnull ScrollingModel model, int offset) { model.disableAnimation(); try { model.scrollHorizontally(offset); } finally { model.enableAnimation(); } }
Example 5
Source File: SyncScrollSupport.java From consulo with Apache License 2.0 | 5 votes |
public static void scrollEditor(@Nonnull Editor editor, int logicalLine) { editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalLine, 0)); ScrollingModel scrollingModel = editor.getScrollingModel(); scrollingModel.disableAnimation(); scrollingModel.scrollToCaret(ScrollType.CENTER); scrollingModel.enableAnimation(); }
Example 6
Source File: CaretVisualPositionKeeper.java From consulo with Apache License 2.0 | 5 votes |
public void restoreOriginalLocation() { for (Map.Entry<Editor, Integer> e : myCaretRelativeVerticalPositions.entrySet()) { Editor editor = e.getKey(); int relativePosition = e.getValue(); Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition()); int scrollOffset = caretLocation.y - relativePosition; ScrollingModel scrollingModel = editor.getScrollingModel(); Rectangle targetArea = scrollingModel.getVisibleAreaOnScrollingFinished(); // when animated scrolling is in progress, we'll not stop it immediately boolean useAnimation = !targetArea.equals(scrollingModel.getVisibleArea()); if (!useAnimation) scrollingModel.disableAnimation(); scrollingModel.scroll(targetArea.x, scrollOffset); if (!useAnimation) scrollingModel.enableAnimation(); } }
Example 7
Source File: SyncScrollSupport.java From consulo with Apache License 2.0 | 4 votes |
private static void doScrollVertically(@Nonnull Editor editor, int offset, boolean animated) { ScrollingModel model = editor.getScrollingModel(); if (!animated) model.disableAnimation(); model.scrollVertically(offset); if (!animated) model.enableAnimation(); }
Example 8
Source File: SyncScrollSupport.java From consulo with Apache License 2.0 | 4 votes |
private static void doScrollHorizontally(@Nonnull Editor editor, int offset, boolean animated) { ScrollingModel model = editor.getScrollingModel(); if (!animated) model.disableAnimation(); model.scrollHorizontally(offset); if (!animated) model.enableAnimation(); }