当前位置: 首页>>代码示例>>Java>>正文


Java Caret.moveToOffset方法代码示例

本文整理汇总了Java中com.intellij.openapi.editor.Caret.moveToOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Caret.moveToOffset方法的具体用法?Java Caret.moveToOffset怎么用?Java Caret.moveToOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.editor.Caret的用法示例。


在下文中一共展示了Caret.moveToOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: perform

import com.intellij.openapi.editor.Caret; //导入方法依赖的package包/类
protected boolean perform(@NotNull LineSelectionManager manager, @NotNull Caret caret, @NotNull Range range, @NotNull ArrayList<CaretState> createCarets) {
    Editor editor = caret.getEditor();
    final BasedSequence chars = BasedSequenceImpl.of(editor.getDocument().getCharsSequence());
    boolean keepCaret = !isMoveFirstMatch();

    T matcher = prepareMatcher(manager, caret, range, chars);
    if (matcher != null) {
        // forward search withing range in document
        CaretMatch lastMatch = null;
        while (true) {
            CaretMatch match = nextMatch(matcher, chars, range, lastMatch);
            if (match == null) break;

            // found it, create or move caret here
            if (!keepCaret) {
                keepCaret = true;
                if (isMoveFirstMatch()) {
                    caret.moveToOffset(match.caretOffset);
                    caret.setSelection(match.selectionStart, match.selectionEnd);
                }
            } else {
                // create a new position if caret moved
                LogicalPosition offset = editor.offsetToLogicalPosition(match.caretOffset);
                LogicalPosition startOffset = editor.offsetToLogicalPosition(match.selectionStart);
                LogicalPosition endOffset = editor.offsetToLogicalPosition(match.selectionEnd);
                CaretState caretState = new CaretState(offset, startOffset, endOffset);
                createCarets.add(caretState);
            }

            if (isSingleMatch() || match.caretOffset + match.matchLength >= chars.length()) break;
            lastMatch = match;
        }
    }

    return keepCaret || isSingleMatch();
}
 
开发者ID:vsch,项目名称:MissingInActions,代码行数:37,代码来源:PatternSearchCaretHandler.java

示例2: delete

import com.intellij.openapi.editor.Caret; //导入方法依赖的package包/类
private void delete(@NotNull Editor editor, @NotNull Caret caret, int start, int end) {
  if (myCopyToClipboard) {
    KillRingUtil.copyToKillRing(editor, start, end, true);
  }
  else {
    CopyPasteManager.getInstance().stopKillRings();
  }
  editor.getDocument().deleteString(start, end);

  // in case the caret was in the virtual space, we force it to go back to the real offset
  caret.moveToOffset(start);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CutLineActionHandler.java

示例3: moveCaret

import com.intellij.openapi.editor.Caret; //导入方法依赖的package包/类
private static void moveCaret(Editor editor, Caret caret, int offset) {
  caret.removeSelection();
  caret.moveToOffset(offset);
  EditorModificationUtil.scrollToCaret(editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:MatchBraceAction.java


注:本文中的com.intellij.openapi.editor.Caret.moveToOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。