本文整理汇总了TypeScript中vs/editor/common/controller/cursorCommon.SingleCursorState.move方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SingleCursorState.move方法的具体用法?TypeScript SingleCursorState.move怎么用?TypeScript SingleCursorState.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/controller/cursorCommon.SingleCursorState
的用法示例。
在下文中一共展示了SingleCursorState.move方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _move
private _move(inSelectionMode: boolean, lineNumber: number, column: number, viewLineNumber: number, viewColumn: number, leftoverVisibleColumns: number, ensureInEditableRange: boolean): void {
this._setState(
this.modelState.move(inSelectionMode, new Position(lineNumber, column), leftoverVisibleColumns),
this.viewState.move(inSelectionMode, new Position(viewLineNumber, viewColumn), leftoverVisibleColumns),
ensureInEditableRange
);
}
示例2: fromMove
public static fromMove(initialState: SingleCursorState, inSelectionMode: boolean, lineNumber: number, column: number, leftoverVisibleColumns: number, ensureInEditableRange: boolean, reason: CursorChangeReason): SingleMoveOperationResult {
return new SingleMoveOperationResult(
initialState.move(inSelectionMode, new Position(lineNumber, column), leftoverVisibleColumns),
ensureInEditableRange,
reason
);
}
示例3: moveRight
public static moveRight(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, noOfColumns: number): SingleCursorState {
let lineNumber: number,
column: number;
if (cursor.hasSelection() && !inSelectionMode) {
// If we are in selection mode, move right without selection cancels selection and puts cursor at the end of the selection
lineNumber = cursor.selection.endLineNumber;
column = cursor.selection.endColumn;
} else {
let r = MoveOperations.right(config, model, cursor.position.lineNumber, cursor.position.column + (noOfColumns - 1));
lineNumber = r.lineNumber;
column = r.column;
}
return cursor.move(inSelectionMode, lineNumber, column, 0);
}
示例4: moveToBeginningOfLine
public static moveToBeginningOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
let lineNumber = cursor.position.lineNumber;
let minColumn = model.getLineMinColumn(lineNumber);
let firstNonBlankColumn = model.getLineFirstNonWhitespaceColumn(lineNumber) || minColumn;
let column: number;
let relevantColumnNumber = cursor.position.column;
if (relevantColumnNumber === firstNonBlankColumn) {
column = minColumn;
} else {
column = firstNonBlankColumn;
}
return cursor.move(inSelectionMode, lineNumber, column, 0);
}
示例5: moveUp
public static moveUp(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, linesCount: number): SingleCursorState {
let lineNumber: number,
column: number;
if (cursor.hasSelection() && !inSelectionMode) {
// If we are in selection mode, move up acts relative to the beginning of selection
lineNumber = cursor.selection.startLineNumber;
column = cursor.selection.startColumn;
} else {
lineNumber = cursor.position.lineNumber;
column = cursor.position.column;
}
let r = MoveOperations.up(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true);
return cursor.move(inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns);
}
示例6: word
public static word(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, position: Position): SingleCursorState {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
let prevWord = WordOperations._findPreviousWordOnLine(wordSeparators, model, position);
let nextWord = WordOperations._findNextWordOnLine(wordSeparators, model, position);
if (!inSelectionMode) {
// Entering word selection for the first time
const isTouchingPrevWord = (prevWord && prevWord.wordType === WordType.Regular && prevWord.start <= position.column - 1 && position.column - 1 <= prevWord.end);
const isTouchingNextWord = (nextWord && nextWord.wordType === WordType.Regular && nextWord.start <= position.column - 1 && position.column - 1 <= nextWord.end);
let startColumn: number;
let endColumn: number;
if (isTouchingPrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isTouchingNextWord) {
startColumn = nextWord.start + 1;
endColumn = nextWord.end + 1;
} else {
if (prevWord) {
startColumn = prevWord.end + 1;
} else {
startColumn = 1;
}
if (nextWord) {
endColumn = nextWord.start + 1;
} else {
endColumn = model.getLineMaxColumn(position.lineNumber);
}
}
return new SingleCursorState(
new Range(position.lineNumber, startColumn, position.lineNumber, endColumn), 0,
new Position(position.lineNumber, endColumn), 0
);
}
const isInsidePrevWord = (prevWord && prevWord.wordType === WordType.Regular && prevWord.start < position.column - 1 && position.column - 1 < prevWord.end);
const isInsideNextWord = (nextWord && nextWord.wordType === WordType.Regular && nextWord.start < position.column - 1 && position.column - 1 < nextWord.end);
let startColumn: number;
let endColumn: number;
if (isInsidePrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isInsideNextWord) {
startColumn = nextWord.start + 1;
endColumn = nextWord.end + 1;
} else {
startColumn = position.column;
endColumn = position.column;
}
let lineNumber = position.lineNumber;
let column: number;
if (cursor.selectionStart.containsPosition(position)) {
column = cursor.selectionStart.endColumn;
} else if (position.isBeforeOrEqual(cursor.selectionStart.getStartPosition())) {
column = startColumn;
let possiblePosition = new Position(lineNumber, column);
if (cursor.selectionStart.containsPosition(possiblePosition)) {
column = cursor.selectionStart.endColumn;
}
} else {
column = endColumn;
let possiblePosition = new Position(lineNumber, column);
if (cursor.selectionStart.containsPosition(possiblePosition)) {
column = cursor.selectionStart.startColumn;
}
}
return cursor.move(true, lineNumber, column, 0);
}
示例7: moveToEndOfBuffer
public static moveToEndOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
let lastLineNumber = model.getLineCount();
let lastColumn = model.getLineMaxColumn(lastLineNumber);
return cursor.move(inSelectionMode, lastLineNumber, lastColumn, 0);
}
示例8: moveToBeginningOfBuffer
public static moveToBeginningOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
return cursor.move(inSelectionMode, 1, 1, 0);
}
示例9: moveToEndOfLine
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
let lineNumber = cursor.position.lineNumber;
let maxColumn = model.getLineMaxColumn(lineNumber);
return cursor.move(inSelectionMode, lineNumber, maxColumn, 0);
}