本文整理匯總了TypeScript中vs/editor/common/controller/cursorCommon.ICursorSimpleModel類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ICursorSimpleModel類的具體用法?TypeScript ICursorSimpleModel怎麽用?TypeScript ICursorSimpleModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ICursorSimpleModel類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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);
}
示例2: 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);
}
示例3: _findPreviousWordOnLine
private static _findPreviousWordOnLine(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, position: Position): IFindWordResult {
let lineContent = model.getLineContent(position.lineNumber);
return this._doFindPreviousWordOnLine(lineContent, wordSeparators, position);
}
示例4: deleteWordRight
public static deleteWordRight(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
if (!selection.isEmpty()) {
return selection;
}
const position = new Position(selection.positionLineNumber, selection.positionColumn);
let lineNumber = position.lineNumber;
let column = position.column;
const lineCount = model.getLineCount();
const maxColumn = model.getLineMaxColumn(lineNumber);
if (lineNumber === lineCount && column === maxColumn) {
// Ignore deleting at end of file
return null;
}
if (whitespaceHeuristics) {
let r = this._deleteWordRightWhitespace(model, position);
if (r) {
return r;
}
}
let nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, position);
if (wordNavigationType === WordNavigationType.WordEnd) {
if (nextWordOnLine) {
column = nextWordOnLine.end + 1;
} else {
if (column < maxColumn || lineNumber === lineCount) {
column = maxColumn;
} else {
lineNumber++;
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, 1));
if (nextWordOnLine) {
column = nextWordOnLine.start + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
}
}
} else {
if (nextWordOnLine && column >= nextWordOnLine.start + 1) {
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1));
}
if (nextWordOnLine) {
column = nextWordOnLine.start + 1;
} else {
if (column < maxColumn || lineNumber === lineCount) {
column = maxColumn;
} else {
lineNumber++;
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, 1));
if (nextWordOnLine) {
column = nextWordOnLine.start + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
}
}
}
return new Range(lineNumber, column, position.lineNumber, position.column);
}
示例5: 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);
}
示例6: cut
public static cut(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): EditOperationResult {
let commands: (ICommand | null)[] = [];
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
if (selection.isEmpty()) {
if (config.emptySelectionClipboard) {
// This is a full line cut
let position = selection.getPosition();
let startLineNumber: number,
startColumn: number,
endLineNumber: number,
endColumn: number;
if (position.lineNumber < model.getLineCount()) {
// Cutting a line in the middle of the model
startLineNumber = position.lineNumber;
startColumn = 1;
endLineNumber = position.lineNumber + 1;
endColumn = 1;
} else if (position.lineNumber > 1) {
// Cutting the last line & there are more than 1 lines in the model
startLineNumber = position.lineNumber - 1;
startColumn = model.getLineMaxColumn(position.lineNumber - 1);
endLineNumber = position.lineNumber;
endColumn = model.getLineMaxColumn(position.lineNumber);
} else {
// Cutting the single line that the model contains
startLineNumber = position.lineNumber;
startColumn = 1;
endLineNumber = position.lineNumber;
endColumn = model.getLineMaxColumn(position.lineNumber);
}
let deleteSelection = new Range(
startLineNumber,
startColumn,
endLineNumber,
endColumn
);
if (!deleteSelection.isEmpty()) {
commands[i] = new ReplaceCommand(deleteSelection, '');
} else {
commands[i] = null;
}
} else {
// Cannot cut empty selection
commands[i] = null;
}
} else {
commands[i] = new ReplaceCommand(selection, '');
}
}
return new EditOperationResult(EditOperationType.Other, commands, {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: true
});
}
示例7: moveToEndOfBuffer
public static moveToEndOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleMoveOperationResult {
let lastLineNumber = model.getLineCount();
let lastColumn = model.getLineMaxColumn(lastLineNumber);
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lastLineNumber, lastColumn, 0, true, CursorChangeReason.Explicit);
}
示例8: moveToEndOfLine
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleMoveOperationResult {
let lineNumber = cursor.position.lineNumber;
let maxColumn = model.getLineMaxColumn(lineNumber);
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lineNumber, maxColumn, 0, true, CursorChangeReason.Explicit);
}
示例9: findPreviousWordOnLine
public static findPreviousWordOnLine(config: CursorConfiguration, model: ICursorSimpleModel, position: Position): IFindWordResult {
let wordSeparators = getMapForWordSeparators(config.wordSeparators);
let lineContent = model.getLineContent(position.lineNumber);
return this._findPreviousWordOnLine(lineContent, wordSeparators, position);
}
示例10: isLastLineVisibleInViewPort
// -- view
public isLastLineVisibleInViewPort(): boolean {
return this.viewModel.getLineCount() <= this.getCompletelyVisibleViewLinesRangeInViewport().getEndPosition().lineNumber;
}