Java 类com.intellij.openapi.editor.event.CaretEvent 实例源码

项目:intellij-ce-playground    文件:CaretImpl.java   
@Nullable
CaretEvent moveToLogicalPosition(@NotNull LogicalPosition pos,
                                         boolean locateBeforeSoftWrap,
                                         @Nullable StringBuilder debugBuffer,
                                         boolean fireListeners) {
  if (mySkipChangeRequests) {
    return null;
  }
  if (myReportCaretMoves) {
    LogMessageEx.error(LOG, "Unexpected caret move request");
  }
  if (!myEditor.isStickySelection() && !myEditor.getCaretModel().isDocumentChanged && !pos.equals(myLogicalCaret)) {
    CopyPasteManager.getInstance().stopKillRings();
  }

  myReportCaretMoves = true;
  try {
    return doMoveToLogicalPosition(pos, locateBeforeSoftWrap, debugBuffer, fireListeners);
  }
  finally {
    myReportCaretMoves = false;
  }
}
项目:intellij-ce-playground    文件:EditorComponentImpl.java   
public void caretUpdate(CaretEvent e) {
  //int dot = e.getDot();
  //int mark = e.getMark();
  //if (caretPos != dot) {
  //  // the caret moved
  //  firePropertyChange(ACCESSIBLE_CARET_PROPERTY, new Integer(caretPos), new Integer(dot));
  //  caretPos = dot;
  //
  //  try {
  //    oldLocationOnScreen = getLocationOnScreen();
  //  }
  //  catch (IllegalComponentStateException iae) {//
  //  }
  //}
  //if (mark != dot) {
  //  // there is a selection
  //  firePropertyChange(ACCESSIBLE_SELECTION_PROPERTY, null, getSelectedText());
  //}
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLQueryContextHighlightVisitor.java   
/**
 * Gets the operation that wraps the current caret position, or <code>null</code> if none is found,
 * e.g. when outside any operation or inside a fragment definition
 */
private static PsiElement getOperationAtCursor(PsiFile psiFile, CaretEvent caretEvent) {
    final FileEditor fileEditor = FileEditorManager.getInstance(psiFile.getProject()).getSelectedEditor(psiFile.getVirtualFile());
    if (fileEditor instanceof TextEditor) {
        final Editor editor = ((TextEditor) fileEditor).getEditor();
        final int currentOffset;
        if(caretEvent != null) {
            currentOffset = editor.logicalPositionToOffset(caretEvent.getNewPosition());
        } else {
            try {
                currentOffset = editor.getCaretModel().getOffset();
            } catch (Throwable e) {
                // a caret update is in progress, so can't determine the operation at this time,
                // but a new caretPositionChanged event will follow
                return null;
            }
        }
        PsiElement currentElement = psiFile.findElementAt(currentOffset);
        while (currentElement != null && !(currentElement.getParent() instanceof PsiFile)) {
            currentElement = currentElement.getParent();
        }
        return asOperationOrNull(currentElement);
    }
    return null;
}
项目:tools-idea    文件:CaretModelImpl.java   
@Nullable
private CaretEvent moveToLogicalPosition(@NotNull LogicalPosition pos,
                                         boolean locateBeforeSoftWrap,
                                         @Nullable StringBuilder debugBuffer,
                                         boolean fireListeners) {
  if (mySkipChangeRequests) {
    return null;
  }
  if (myReportCaretMoves) {
    LogMessageEx.error(LOG, "Unexpected caret move request");
  }
  if (!myEditor.isStickySelection()) {
    CopyPasteManager.getInstance().stopKillRings();
  }

  myReportCaretMoves = true;
  try {
    return doMoveToLogicalPosition(pos, locateBeforeSoftWrap, debugBuffer, fireListeners);
  }
  finally {
    myReportCaretMoves = false;
  }
}
项目:tools-idea    文件:TextEditorBasedStructureViewModel.java   
protected TextEditorBasedStructureViewModel(Editor editor, PsiFile file) {
  myEditor = editor;
  myPsiFile = file;

  if (editor != null) {
    EditorFactory.getInstance().getEventMulticaster().addCaretListener(new CaretListener() {
      @Override
      public void caretPositionChanged(CaretEvent e) {
        if (e.getEditor().equals(myEditor)) {
          for (FileEditorPositionListener listener : myListeners) {
            listener.onCurrentElementChanged();
          }
        }
      }
    }, myDisposable);
  }
}
项目:tools-idea    文件:SimpleEditorPreview.java   
public SimpleEditorPreview(final ColorAndFontOptions options, final ColorSettingsPage page, final boolean navigatable) {
  myOptions = options;
  myPage = page;

  String text = page.getDemoText();

  HighlightsExtractor extractant2 = new HighlightsExtractor(page.getAdditionalHighlightingTagToDescriptorMap());
  myHighlightData = extractant2.extractHighlights(text);

  int selectedLine = -1;
  myEditor = (EditorEx)FontEditorPreview.createPreviewEditor(extractant2.cutDefinedTags(text), 10, 3, selectedLine, myOptions, false);

  FontEditorPreview.installTrafficLights(myEditor);
  myBlinkingAlarm = new Alarm().setActivationComponent(myEditor.getComponent());
  if (navigatable) {
    addMouseMotionListener(myEditor, page.getHighlighter(), myHighlightData, false);

    CaretListener listener = new CaretListener() {
      @Override
      public void caretPositionChanged(CaretEvent e) {
        navigate(myEditor, true, e.getNewPosition(), page.getHighlighter(), myHighlightData, false);
      }
    };
    myEditor.getCaretModel().addCaretListener(listener);
  }
}
项目:consulo    文件:CaretImpl.java   
@Nullable
CaretEvent moveToLogicalPosition(@Nonnull LogicalPosition pos,
                                 boolean locateBeforeSoftWrap,
                                 @Nullable StringBuilder debugBuffer,
                                 boolean fireListeners) {
  if (mySkipChangeRequests) {
    return null;
  }
  if (myReportCaretMoves) {
    LogMessageEx.error(LOG, "Unexpected caret move request");
  }
  if (!myEditor.isStickySelection() && !myEditor.getDocument().isInEventsHandling() && !pos.equals(myLogicalCaret)) {
    CopyPasteManager.getInstance().stopKillRings();
  }

  myReportCaretMoves = true;
  try {
    return doMoveToLogicalPosition(pos, locateBeforeSoftWrap, debugBuffer, fireListeners);
  }
  finally {
    myReportCaretMoves = false;
  }
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretPositionChanged(final CaretEvent e) {
    if (commonIdeaService.isTypingActionInProgress()) {
        return;
    }

    impexHeaderNameHighlighterService.highlightCurrentHeader(e.getEditor());
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretPositionChanged(final CaretEvent e) {
    if (commonIdeaService.isTypingActionInProgress()) {
        return;
    }

    impexColumnHighlighterService.highlightCurrentColumn(e.getEditor());
}
项目:intellij-ce-playground    文件:CaretImpl.java   
@Override
public void moveToOffset(final int offset, final boolean locateBeforeSoftWrap) {
  assertIsDispatchThread();
  validateCallContext();
  if (mySkipChangeRequests) {
    return;
  }
  myEditor.getCaretModel().doWithCaretMerging(new Runnable() {
    @Override
    public void run() {
      final LogicalPosition logicalPosition = myEditor.offsetToLogicalPosition(offset);
      CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, false);
      final LogicalPosition positionByOffsetAfterMove = myEditor.offsetToLogicalPosition(myOffset);
      if (!positionByOffsetAfterMove.equals(logicalPosition)) {
        StringBuilder debugBuffer = new StringBuilder();
        moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, true);
        int textStart = Math.max(0, Math.min(offset, myOffset) - 1);
        final DocumentEx document = myEditor.getDocument();
        int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, myOffset) + 1);
        CharSequence text = document.getCharsSequence().subSequence(textStart, textEnd);
        int inverseOffset = myEditor.logicalPositionToOffset(logicalPosition);
        LogMessageEx.error(
          LOG, "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.",
          "Requested: offset=" + offset + ", logical position='" + logicalPosition + "' but actual: offset=" +
          myOffset + ", logical position='" + myLogicalCaret + "' (" + positionByOffsetAfterMove + "). " + myEditor.dumpState() +
          "\ninterested text [" + textStart + ";" + textEnd + "): '" + text + "'\n debug trace: " + debugBuffer +
          "\nLogical position -> offset ('" + logicalPosition + "'->'" + inverseOffset + "')"
        );
      }
      if (event != null) {
        myEditor.getCaretModel().fireCaretPositionChanged(event);
        EditorActionUtil.selectNonexpandableFold(myEditor);
      }
    }
  });
}
项目:intellij-ce-playground    文件:TextEditorBasedStructureViewModel.java   
protected TextEditorBasedStructureViewModel(Editor editor, PsiFile file) {
  myEditor = editor;
  myPsiFile = file;

  myEditorCaretListener = new CaretAdapter() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (e.getEditor().equals(myEditor)) {
        for (FileEditorPositionListener listener : myListeners) {
          listener.onCurrentElementChanged();
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:ClickNavigator.java   
public void addClickNavigator(final Editor view,
                              final SyntaxHighlighter highlighter,
                              final HighlightData[] data,
                              final boolean isBackgroundImportant) {
  addMouseMotionListener(view, highlighter, data, isBackgroundImportant);

  CaretListener listener = new CaretAdapter() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      navigate(view, true, e.getNewPosition(), highlighter, data, isBackgroundImportant);
    }
  };
  view.getCaretModel().addCaretListener(listener);
}
项目:intellij-ce-playground    文件:SimpleEditorPreview.java   
public SimpleEditorPreview(final ColorAndFontOptions options, final ColorSettingsPage page, final boolean navigatable) {
  myOptions = options;
  myPage = page;

  String text = page.getDemoText();

  HighlightsExtractor extractant2 = new HighlightsExtractor(page.getAdditionalHighlightingTagToDescriptorMap());
  List<HighlightData> highlights = new ArrayList<HighlightData>();
  String stripped = extractant2.extractHighlights(text, highlights);
  myHighlightData = highlights.toArray(new HighlightData[highlights.size()]);
  int selectedLine = -1;
  myEditor = (EditorEx)FontEditorPreview.createPreviewEditor(stripped, 10, 3, selectedLine, myOptions, false);

  FontEditorPreview.installTrafficLights(myEditor);
  myBlinkingAlarm = new Alarm().setActivationComponent(myEditor.getComponent());
  if (navigatable) {
    addMouseMotionListener(myEditor, page.getHighlighter(), myHighlightData, false);

    CaretListener listener = new CaretAdapter() {
      @Override
      public void caretPositionChanged(CaretEvent e) {
        navigate(myEditor, true, e.getNewPosition(), page.getHighlighter(), myHighlightData, false);
      }
    };
    myEditor.getCaretModel().addCaretListener(listener);
  }
}
项目:intellij-ce-playground    文件:CaretModelWindow.java   
@Override
public void addCaretListener(@NotNull final CaretListener listener) {
  CaretListener wrapper = new CaretAdapter() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (!myEditorWindow.getDocument().isValid()) return; // injected document can be destroyed by now
      CaretEvent event = new CaretEvent(myEditorWindow, createInjectedCaret(e.getCaret()),
                                        myEditorWindow.hostToInjected(e.getOldPosition()),
                                        myEditorWindow.hostToInjected(e.getNewPosition()));
      listener.caretPositionChanged(event);
    }
  };
  myCaretListeners.registerWrapper(listener, wrapper);
  myDelegate.addCaretListener(wrapper);
}
项目:intellij-ce-playground    文件:AndroidLayoutPreviewPanel.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  updateCaret();
  if (!myIgnoreListener) {
    ActionBarHandler.showMenu(false, myContext, true);
  }
}
项目:eddy    文件:EddyFileListener.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  if (inChange)
    return;

  // TODO: only process if input changed (if we switched statements?)
  if (active_editor != this.editor || // process if current thread is for a different editor
      e.getNewPosition().line != e.getOldPosition().line) // process if we switched lines
    process();
}
项目:IntelliComment    文件:CommentsToolWindowRenderer.java   
@Override
public void caretPositionChanged(CaretEvent caretEvent) {
    if (commentLayouter.commentExistsForLine(caretEvent.getNewPosition().line + 1)) {
        centerForLine(caretEvent.getNewPosition().line + 1);
    }
    commentLayouter.updateCommentProperties(caretEvent.getNewPosition().line + 1);
    repaint();
}
项目:tools-idea    文件:CaretModelImpl.java   
@Override
public void moveToOffset(int offset, boolean locateBeforeSoftWrap) {
  assertIsDispatchThread();
  validateCallContext();
  if (mySkipChangeRequests) {
    return;
  }
  final LogicalPosition logicalPosition = myEditor.offsetToLogicalPosition(offset);
  CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, false);
  final LogicalPosition positionByOffsetAfterMove = myEditor.offsetToLogicalPosition(myOffset);
  if (!myIgnoreWrongMoves && !positionByOffsetAfterMove.equals(logicalPosition)) {
    StringBuilder debugBuffer = new StringBuilder();
    moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, true);
    int textStart = Math.max(0, Math.min(offset, myOffset) - 1);
    final DocumentEx document = myEditor.getDocument();
    int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, myOffset) + 1);
    CharSequence text = document.getCharsSequence().subSequence(textStart, textEnd);
    StringBuilder positionToOffsetTrace = new StringBuilder();
    int inverseOffset = myEditor.logicalPositionToOffset(logicalPosition, positionToOffsetTrace);
    LogMessageEx.error(
      LOG, "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.",
      String.format(
        "Requested: offset=%d, logical position='%s' but actual: offset=%d, logical position='%s' (%s). %s%n"
        + "interested text [%d;%d): '%s'%n debug trace: %s%nLogical position -> offset ('%s'->'%d') trace: %s",
        offset, logicalPosition, myOffset, myLogicalCaret, positionByOffsetAfterMove, myEditor.dumpState(),
        textStart, textEnd, text, debugBuffer, logicalPosition, inverseOffset, positionToOffsetTrace
      ));
  }
  if (event != null) {
    myCaretListeners.getMulticaster().caretPositionChanged(event);
    EditorActionUtil.selectNonexpandableFold(myEditor);
  }
}
项目:tools-idea    文件:ClickNavigator.java   
public void addClickNavigator(final Editor view,
                              final SyntaxHighlighter highlighter,
                              final HighlightData[] data,
                              final boolean isBackgroundImportant) {
  addMouseMotionListener(view, highlighter, data, isBackgroundImportant);

  CaretListener listener = new CaretListener() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      navigate(view, true, e.getNewPosition(), highlighter, data, isBackgroundImportant);
    }
  };
  view.getCaretModel().addCaretListener(listener);
}
项目:tools-idea    文件:CaretModelWindow.java   
@Override
public void addCaretListener(@NotNull final CaretListener listener) {
  CaretListener wrapper = new CaretListener() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (!myEditorWindow.getDocument().isValid()) return; // injected document can be destroyed by now
      CaretEvent event = new CaretEvent(myEditorWindow, myEditorWindow.hostToInjected(e.getOldPosition()),
                                        myEditorWindow.hostToInjected(e.getNewPosition()));
      listener.caretPositionChanged(event);
    }
  };
  myCaretListeners.registerWrapper(listener, wrapper);
  myDelegate.addCaretListener(wrapper);
}
项目:asciidoctor-intellij-plugin    文件:AsciiDocSplitEditor.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  final Editor editor = e.getEditor();
  if (editor.getCaretModel().getCaretCount() != 1) {
    return;
  }

  myPreviewFileEditor.scrollToLine(e.getNewPosition().line);
}
项目:consulo    文件:CaretImpl.java   
@Override
public void moveToOffset(final int offset, final boolean locateBeforeSoftWrap) {
  assertIsDispatchThread();
  validateCallContext();
  if (mySkipChangeRequests) {
    return;
  }
  myEditor.getCaretModel().doWithCaretMerging(() -> {
    final LogicalPosition logicalPosition = myEditor.offsetToLogicalPosition(offset);
    CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, false);
    final LogicalPosition positionByOffsetAfterMove = myEditor.offsetToLogicalPosition(getOffset());
    if (!positionByOffsetAfterMove.equals(logicalPosition)) {
      StringBuilder debugBuffer = new StringBuilder();
      moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, true);
      int actualOffset = getOffset();
      int textStart = Math.max(0, Math.min(offset, actualOffset) - 1);
      final DocumentEx document = myEditor.getDocument();
      int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, actualOffset) + 1);
      CharSequence text = document.getCharsSequence().subSequence(textStart, textEnd);
      int inverseOffset = myEditor.logicalPositionToOffset(logicalPosition);
      LogMessageEx.error(
              LOG, "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.",
              "Requested: offset=" + offset + ", logical position='" + logicalPosition + "' but actual: offset=" +
              actualOffset + ", logical position='" + myLogicalCaret + "' (" + positionByOffsetAfterMove + "). " + myEditor.dumpState() +
              "\ninterested text [" + textStart + ";" + textEnd + "): '" + text + "'\n debug trace: " + debugBuffer +
              "\nLogical position -> offset ('" + logicalPosition + "'->'" + inverseOffset + "')"
      );
    }
    if (event != null) {
      myEditor.getCaretModel().fireCaretPositionChanged(event);
      EditorActionUtil.selectNonexpandableFold(myEditor);
    }
  });
}
项目:consulo    文件:EditorComponentImpl.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  Caret caret = e.getCaret();
  if (caret == null) {
    return;
  }
  int dot = caret.getOffset();
  int mark = caret.getLeadSelectionOffset();
  if (myCaretPos != dot) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    firePropertyChange(ACCESSIBLE_CARET_PROPERTY,
                       new Integer(myCaretPos), new Integer(dot));

    if (SystemInfo.isMac) {
      // For MacOSX we also need to fire a caret event to anyone listening
      // to our Document, since *that* rather than the accessible property
      // change is the only way to trigger a speech update
      //fireJTextComponentCaretChange(dot, mark);
      fireJTextComponentCaretChange(e);
    }

    myCaretPos = dot;
  }

  if (mark != dot) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    firePropertyChange(ACCESSIBLE_SELECTION_PROPERTY, null,
                       getSelectedText());
  }
}
项目:consulo    文件:TextEditorBasedStructureViewModel.java   
protected TextEditorBasedStructureViewModel(Editor editor, PsiFile file) {
  myEditor = editor;
  myPsiFile = file;

  myEditorCaretListener = new CaretAdapter() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (e.getEditor().equals(myEditor)) {
        for (FileEditorPositionListener listener : myListeners) {
          listener.onCurrentElementChanged();
        }
      }
    }
  };
}
项目:consulo    文件:ClickNavigator.java   
public void addClickNavigator(final Editor view,
                              final SyntaxHighlighter highlighter,
                              final HighlightData[] data,
                              final boolean isBackgroundImportant) {
  addMouseMotionListener(view, highlighter, data, isBackgroundImportant);

  CaretListener listener = new CaretAdapter() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      navigate(view, true, e.getNewPosition(), highlighter, data, isBackgroundImportant);
    }
  };
  view.getCaretModel().addCaretListener(listener);
}
项目:consulo    文件:CaretModelWindow.java   
@Override
public void addCaretListener(@Nonnull final CaretListener listener) {
  CaretListener wrapper = new CaretListener() {
    @Override
    public void caretPositionChanged(CaretEvent e) {
      if (!myEditorWindow.getDocument().isValid()) return; // injected document can be destroyed by now
      CaretEvent event = new CaretEvent(myEditorWindow, createInjectedCaret(e.getCaret()),
                                        myEditorWindow.hostToInjected(e.getOldPosition()),
                                        myEditorWindow.hostToInjected(e.getNewPosition()));
      listener.caretPositionChanged(event);
    }
  };
  myCaretListeners.registerWrapper(listener, wrapper);
  myDelegate.addCaretListener(wrapper);
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretAdded(final CaretEvent e) {
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretRemoved(final CaretEvent e) {
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretAdded(final CaretEvent e) {
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexHeaderHighlighterComponent.java   
@Override
public void caretRemoved(final CaretEvent e) {
}
项目:intellij-ce-playground    文件:CurrentLineMarker.java   
public void caretPositionChanged(CaretEvent e) {
  if (isHiden()) return;
  set();
}
项目:intellij-ce-playground    文件:MergeSearchHelper.java   
public static Change findChangeAt(CaretEvent e, MergePanel2 mergePanel, int index) {
  Editor editor = e.getEditor();
  LOG.assertTrue(editor == mergePanel.getEditor(index));
  return forMergeList(mergePanel.getMergeList(), index).
    findChangeAt(editor.logicalPositionToOffset(e.getNewPosition()));
}
项目:intellij-ce-playground    文件:CaretModelImpl.java   
void fireCaretPositionChanged(CaretEvent caretEvent) {
  myCaretListeners.getMulticaster().caretPositionChanged(caretEvent);
}
项目:intellij-ce-playground    文件:CaretModelImpl.java   
void fireCaretAdded(@NotNull Caret caret) {
  myCaretListeners.getMulticaster().caretAdded(new CaretEvent(myEditor, caret, caret.getLogicalPosition(), caret.getLogicalPosition()));
}
项目:intellij-ce-playground    文件:CaretModelImpl.java   
void fireCaretRemoved(@NotNull Caret caret) {
  myCaretListeners.getMulticaster().caretRemoved(new CaretEvent(myEditor, caret, caret.getLogicalPosition(), caret.getLogicalPosition()));
}
项目:intellij-ce-playground    文件:CaretImpl.java   
void moveToVisualPosition(@NotNull VisualPosition pos, boolean fireListeners) {
  assertIsDispatchThread();
  validateCallContext();
  if (mySkipChangeRequests) {
    return;
  }
  if (myReportCaretMoves) {
    LogMessageEx.error(LOG, "Unexpected caret move request");
  }
  if (!myEditor.isStickySelection() && !myEditor.getCaretModel().isDocumentChanged && !pos.equals(myVisibleCaret)) {
    CopyPasteManager.getInstance().stopKillRings();
  }

  myDesiredX = -1;
  int column = pos.column;
  int line = pos.line;
  boolean leanRight = pos.leansRight;

  int lastLine = myEditor.getVisibleLineCount() - 1;
  if (lastLine <= 0) {
    lastLine = 0;
  }

  if (line > lastLine) {
    line = lastLine;
  }

  EditorSettings editorSettings = myEditor.getSettings();

  if (!editorSettings.isVirtualSpace()) {
    int lineEndColumn = EditorUtil.getLastVisualLineColumnNumber(myEditor, line);
    if (column > lineEndColumn && (!myEditor.myUseNewRendering || !myEditor.getSoftWrapModel().isInsideSoftWrap(pos))) {
      column = lineEndColumn;
      leanRight = true;
    }

    if (!myEditor.myUseNewRendering && column < 0 && line > 0) {
      line--;
      column = EditorUtil.getLastVisualLineColumnNumber(myEditor, line);
    }
  }

  myVisibleCaret = new VisualPosition(line, column, leanRight);

  VerticalInfo oldInfo = myCaretInfo;
  LogicalPosition oldPosition = myLogicalCaret;

  setCurrentLogicalCaret(myEditor.visualToLogicalPosition(myVisibleCaret));
  updateOffsetsFromLogicalPosition();
  LOG.assertTrue(myOffset >= 0 && myOffset <= myEditor.getDocument().getTextLength());

  updateVisualLineInfo();

  myEditor.getFoldingModel().flushCaretPosition();

  setLastColumnNumber(myLogicalCaret.column);
  myDesiredSelectionStartColumn = myDesiredSelectionEndColumn = -1;
  myEditor.updateCaretCursor();
  requestRepaint(oldInfo);

  if (fireListeners && !oldPosition.equals(myLogicalCaret)) {
    CaretEvent event = new CaretEvent(myEditor, this, oldPosition, myLogicalCaret);
    myEditor.getCaretModel().fireCaretPositionChanged(event);
  }
}
项目:intellij-ce-playground    文件:EditorComponentImpl.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  caretUpdate(e);
}
项目:intellij-ce-playground    文件:EditorComponentImpl.java   
@Override
public void caretAdded(CaretEvent e) {
  caretUpdate(e);
}
项目:intellij-ce-playground    文件:EditorComponentImpl.java   
@Override
public void caretRemoved(CaretEvent e) {
  caretUpdate(e);
}
项目:intellij-ce-playground    文件:SelectInEditorManagerImpl.java   
@Override
public void caretPositionChanged(CaretEvent e) {
  releaseAll();
}