Java Code Examples for com.intellij.openapi.editor.ex.util.EditorUtil#inVirtualSpace()

The following examples show how to use com.intellij.openapi.editor.ex.util.EditorUtil#inVirtualSpace() . 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: EditorHyperlinkSupport.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public Runnable getLinkNavigationRunnable(final LogicalPosition logical) {
  if (EditorUtil.inVirtualSpace(myEditor, logical)) {
    return null;
  }

  final RangeHighlighter range = findLinkRangeAt(myEditor.logicalPositionToOffset(logical));
  if (range != null) {
    final HyperlinkInfo hyperlinkInfo = getHyperlinkInfo(range);
    if (hyperlinkInfo != null) {
      return () -> {
        if (hyperlinkInfo instanceof HyperlinkInfoBase) {
          final Point point = myEditor.logicalPositionToXY(logical);
          final MouseEvent event = new MouseEvent(myEditor.getContentComponent(), 0, 0, 0, point.x, point.y, 1, false);
          ((HyperlinkInfoBase)hyperlinkInfo).navigate(myProject, new RelativePoint(event));
        }
        else {
          hyperlinkInfo.navigate(myProject);
        }
        linkFollowed(myEditor, getHyperlinks(0, myEditor.getDocument().getTextLength(), myEditor), range);
      };
    }
  }
  return null;
}
 
Example 2
Source File: EventLogConsole.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void addConfigureNotificationAction(@Nonnull EditorEx editor, @Nonnull EditorMouseEvent event, @Nonnull final DefaultActionGroup actions) {
  LogicalPosition position = editor.xyToLogicalPosition(event.getMouseEvent().getPoint());
  if (EditorUtil.inVirtualSpace(editor, position)) {
    return;
  }
  int offset = editor.logicalPositionToOffset(position);
  editor.getMarkupModel().processRangeHighlightersOverlappingWith(offset, offset, new Processor<RangeHighlighterEx>() {
    @Override
    public boolean process(RangeHighlighterEx rangeHighlighter) {
      String groupId = GROUP_ID.get(rangeHighlighter);
      if (groupId != null) {
        addConfigureNotificationAction(actions, groupId);
        return false;
      }
      return true;
    }
  });
}
 
Example 3
Source File: EditorComponentImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Object getData(@Nonnull Key<?> dataId) {
  if (myEditor.isDisposed() || myEditor.isRendererMode()) return null;

  if (CommonDataKeys.EDITOR == dataId) {
    return myEditor;
  }
  if (CommonDataKeys.CARET == dataId) {
    return myEditor.getCaretModel().getCurrentCaret();
  }
  if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER == dataId) {
    return myEditor.getDeleteProvider();
  }
  if (PlatformDataKeys.CUT_PROVIDER == dataId) {
    return myEditor.getCutProvider();
  }
  if (PlatformDataKeys.COPY_PROVIDER == dataId) {
    return myEditor.getCopyProvider();
  }
  if (PlatformDataKeys.PASTE_PROVIDER == dataId) {
    return myEditor.getPasteProvider();
  }
  if (CommonDataKeys.EDITOR_VIRTUAL_SPACE == dataId) {
    LogicalPosition location = myEditor.myLastMousePressedLocation;
    if (location == null) {
      location = myEditor.getCaretModel().getLogicalPosition();
    }
    return EditorUtil.inVirtualSpace(myEditor, location);
  }
  return null;
}
 
Example 4
Source File: EditorHyperlinkSupport.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public HyperlinkInfo getHyperlinkInfoByPoint(final Point p) {
  final LogicalPosition pos = myEditor.xyToLogicalPosition(new Point(p.x, p.y));
  if (EditorUtil.inVirtualSpace(myEditor, pos)) {
    return null;
  }

  return getHyperlinkInfoByLineAndCol(pos.line, pos.column);
}
 
Example 5
Source File: TargetElementUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean inVirtualSpace(@Nonnull Editor editor, int offset) {
  if (offset == editor.getCaretModel().getOffset()) {
    return EditorUtil.inVirtualSpace(editor, editor.getCaretModel().getLogicalPosition());
  }

  return false;
}