@Override public void mouseDragged(MouseEvent e) { if (resizing) { config.width = widthStart + (resizeStart - e.getXOnScreen()); if (config.width < 1) { config.width = 1; } configService.dispatch().configChanged(); } if (dragging) { // Disable animation when dragging for better experience. editor.getScrollingModel().disableAnimation(); editor .getScrollingModel() .scrollVertically( scrollStart + coords.pixelsToLines(e.getY() - mouseStart) * editor.getLineHeight()); editor.getScrollingModel().enableAnimation(); } }
@Override public void mouseMoved(MouseEvent e) { if (inResizeGutter(e.getX())) { setCursor(resizeCursor); } else { setCursor(defaultCursor); } }
@Override public void mouseClicked(MouseEvent e) { if (!config.jumpOnMouseDown) { editor .getScrollingModel() .scrollTo( editor.offsetToLogicalPosition( coords.screenSpaceToOffset(e.getY(), config.percentageBasedClick)), ScrollType.CENTER); } }
public void mouseMoved(final EditorMouseEvent e) { if (e.isConsumed() || !myProject.isInitialized()) { return; } MouseEvent mouseEvent = e.getMouseEvent(); Editor editor = e.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); Point point = new Point(mouseEvent.getPoint()); if (!PsiDocumentManager.getInstance(myProject).isUncommited(editor.getDocument())) { // when document is committed, try to check injected stuff - it's fast editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit( editor, psiFile, editor.logicalPositionToOffset(editor.xyToLogicalPosition(point))); } LogicalPosition pos = editor.xyToLogicalPosition(point); int offset = editor.logicalPositionToOffset(pos); int selStart = editor.getSelectionModel().getSelectionStart(); int selEnd = editor.getSelectionModel().getSelectionEnd(); myStoredModifiers = mouseEvent.getModifiers(); BrowseMode browseMode = getBrowseMode(myStoredModifiers); if (myTooltipProvider != null) { myTooltipProvider.dispose(); } if (browseMode == BrowseMode.None || offset >= selStart && offset < selEnd) { disposeHighlighter(); myTooltipProvider = null; return; } myTooltipProvider = new TooltipProvider(editor, pos); myTooltipProvider.execute(browseMode); }
@Override public void mousePressed(MouseEvent e) { if (!dragging && inResizeGutter(e.getX())) { resizing = true; } else if (!resizing) { dragging = true; } if (resizing) { resizeStart = e.getXOnScreen(); widthStart = config.width; } if (dragging) { Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); int firstVisibleLine = getMapYFromEditorY((int) visibleArea.getMinY()); int height = coords.linesToPixels( (int) ((visibleArea.getMaxY() - visibleArea.getMinY()) / editor.getLineHeight())); int panelY = e.getY() - getY(); if (config.jumpOnMouseDown && (panelY <= firstVisibleLine || panelY >= (firstVisibleLine + height))) { editor.getScrollingModel().disableAnimation(); editor .getScrollingModel() .scrollTo( editor.offsetToLogicalPosition( coords.screenSpaceToOffset(e.getY(), config.percentageBasedClick)), ScrollType.CENTER); editor.getScrollingModel().enableAnimation(); } scrollStart = editor.getScrollingModel().getVerticalScrollOffset(); mouseStart = e.getY(); } }
@Override public void mouseMoved(final EditorMouseEvent e) { if (e.isConsumed() || !myProject.isInitialized() || myProject.isDisposed()) { return; } MouseEvent mouseEvent = e.getMouseEvent(); if (isMouseOverTooltip(mouseEvent.getLocationOnScreen()) || ScreenUtil.isMovementTowards( myPrevMouseLocation, mouseEvent.getLocationOnScreen(), getHintBounds())) { myPrevMouseLocation = mouseEvent.getLocationOnScreen(); return; } myPrevMouseLocation = mouseEvent.getLocationOnScreen(); Editor editor = e.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject); PsiFile psiFile = documentManager.getPsiFile(editor.getDocument()); Point point = new Point(mouseEvent.getPoint()); if (documentManager.isCommitted(editor.getDocument())) { // when document is committed, try to check injected stuff - it's fast int offset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(point)); editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, psiFile, offset); } LogicalPosition pos = editor.xyToLogicalPosition(point); int offset = editor.logicalPositionToOffset(pos); int selStart = editor.getSelectionModel().getSelectionStart(); int selEnd = editor.getSelectionModel().getSelectionEnd(); myStoredModifiers = mouseEvent.getModifiers(); BrowseMode browseMode = getBrowseMode(myStoredModifiers); cancelPreviousTooltip(); if (browseMode == BrowseMode.None || offset >= selStart && offset < selEnd) { disposeHighlighter(); return; } myTooltipProvider = new TooltipProvider(editor, pos); myTooltipProvider.execute(browseMode); }
public void mouseExited(@NotNull MouseEvent e) { processStateChangeIfNecessary(e.getLocationOnScreen(), false); }