本文整理汇总了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();
}
示例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);
}
示例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);
}