private BeforeAfter<Integer> getEditorLines() {
    final Editor editor = ((DiffPanelImpl) getCurrentPanel()).getEditor1();
    Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
    final int offset = editor.getScrollingModel().getVerticalScrollOffset();

    int leftPixels = offset % editor.getLineHeight();

    final Point start = visibleArea.getLocation();
    final LogicalPosition startLp = editor.xyToLogicalPosition(start);
    final Point location = new Point(start.x + visibleArea.width, start.y + visibleArea.height);
    final LogicalPosition lp = editor.xyToLogicalPosition(location);

    int curStartLine =
        startLp.line == (editor.getDocument().getLineCount() - 1)
            ? startLp.line
            : (startLp.line + 1);
    int cutEndLine = lp.line == 0 ? 0 : lp.line - 1;

    boolean commonPartOk = leftPixels == 0 || startLp.line == lp.line;
    return new BeforeAfter<Integer>(
        commonPartOk && startLp.softWrapLinesOnCurrentLogicalLine == 0
            ? startLp.line
            : curStartLine,
        commonPartOk && lp.softWrapLinesOnCurrentLogicalLine == 0 ? lp.line : cutEndLine);
    /*if (leftPixels == 0 || startLp.line == lp.line) {
      return new BeforeAfter<Integer>(startLp.line, lp.line);
    } else {
      return new BeforeAfter<Integer>(curStartLine, cutEndLine);
    }*/
  }
Beispiel #2
0
        @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 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);
        }
Beispiel #4
0
  private int getMapYFromEditorY(int y) {
    int offset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(new Point(0, y)));

    return coords.offsetToScreenSpace(offset);
  }