Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.LogicalPosition


  static CodePointer getCodePointer(Editor editor) {
    CodePointer codePointer;
    int selectionStart = editor.getSelectionModel().getSelectionStart();
    int selectionEnd = editor.getSelectionModel().getSelectionEnd();
    if (selectionStart != selectionEnd) {
      LogicalPosition start = editor.offsetToLogicalPosition(selectionStart);
      LogicalPosition end = editor.offsetToLogicalPosition(selectionEnd);
      codePointer = new CodePointer(start.line, start.column, end.line, end.column);
    }
    else {
      LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
      codePointer = new CodePointer(pos.line, pos.column);
    }
    return codePointer;
  }
View Full Code Here


    return StringUtil.getMsg("code.pointer");
  }

  private LogicalPosition getLogicalPosition(int line, int column, PositionCorrector positionCorrector) {
    if (myRemoteFile.getContents() != null) {
      return new LogicalPosition(positionCorrector.getCorrectedLine(line), column);
    }
    return new LogicalPosition(line, column);
  }
View Full Code Here

    if (descriptor.getOffset() >= 0){
      editor.getCaretModel().moveToOffset(descriptor.getOffset());
    }
    else if (descriptor.getLine() >= 0 && descriptor.getColumn() >= 0){
      editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(descriptor.getLine(), descriptor.getColumn()));
    }
    editor.getSelectionModel().removeSelection();
    myActiveFile = file;

    return editor;
View Full Code Here

        this.line = line;
        this.column = column;
    }

    private LogicalPosition getLogicalPosition() {
        return line != -1 || column != -1 ? new LogicalPosition(line > -1 ? line - 1 : 0, column > -1 ? column : 0) : null;
    }
View Full Code Here

    private void openFileInEditor(@NotNull final Notification notification, @Nullable final VirtualFile file) {
        if (file == null) return;

        final FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
        final Editor editor = editorManager.openTextEditor(new OpenFileDescriptor(myProject, file), true);
        final LogicalPosition logicalPosition = getLogicalPosition();

        if(editor != null && logicalPosition != null) {
            // Set correct caret position
            // See https://github.com/johnlindquist/open-source-plugins/blob/master/QuickJump/src/com/johnlindquist/quickjump/QuickJumpAction.java
            editor.getCaretModel().moveToVisualPosition(editor.logicalToVisualPosition(logicalPosition));
View Full Code Here

        final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
        final FileEditor[] editor = fileEditorManager.openFile(
                virtualFile, true);

        if (editor.length > 0 && editor[0] instanceof TextEditor) {
            final LogicalPosition problemPos = new LogicalPosition(
                    Math.max(lineFor(nodeInfo) - 1, 0), Math.max(columnFor(nodeInfo), 0));

            final Editor textEditor = ((TextEditor) editor[0]).getEditor();
            textEditor.getCaretModel().moveToLogicalPosition(problemPos);
            textEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.LogicalPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.