本文整理汇总了TypeScript中vs/editor/common/controller/cursorCommon.SingleCursorState.hasSelection方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SingleCursorState.hasSelection方法的具体用法?TypeScript SingleCursorState.hasSelection怎么用?TypeScript SingleCursorState.hasSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/controller/cursorCommon.SingleCursorState
的用法示例。
在下文中一共展示了SingleCursorState.hasSelection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
示例2: moveLeft
public static moveLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, noOfColumns: number): SingleMoveOperationResult {
let lineNumber: number,
column: number;
if (cursor.hasSelection() && !inSelectionMode) {
// If we are in selection mode, move left without selection cancels selection and puts cursor at the beginning of the selection
lineNumber = cursor.selection.startLineNumber;
column = cursor.selection.startColumn;
} else {
let r = MoveOperations.left(config, model, cursor.position.lineNumber, cursor.position.column - (noOfColumns - 1));
lineNumber = r.lineNumber;
column = r.column;
}
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lineNumber, column, 0, true, CursorChangeReason.Explicit);
}
示例3: 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);
}
示例4: moveDown
public static moveDown(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, linesCount: number): SingleMoveOperationResult {
let lineNumber: number,
column: number;
if (cursor.hasSelection() && !inSelectionMode) {
// If we are in selection mode, move down acts relative to the end of selection
lineNumber = cursor.selection.endLineNumber;
column = cursor.selection.endColumn;
} else {
lineNumber = cursor.position.lineNumber;
column = cursor.position.column;
}
let r = MoveOperations.down(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true);
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns, true, CursorChangeReason.Explicit);
}
示例5: 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 isInPrevWord = (prevWord && prevWord.wordType === WordType.Regular && prevWord.start < position.column - 1 && position.column - 1 <= prevWord.end);
let nextWord = WordOperations._findNextWordOnLine(wordSeparators, model, position);
let isInNextWord = (nextWord && nextWord.wordType === WordType.Regular && nextWord.start < position.column - 1 && position.column - 1 <= nextWord.end);
if (!inSelectionMode || !cursor.hasSelection()) {
// Entering word selection for the first time
let startColumn: number;
let endColumn: number;
if (isInPrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isInNextWord) {
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
);
}
let startColumn: number;
let endColumn: number;
if (isInPrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isInNextWord) {
startColumn = nextWord.start + 1;
endColumn = nextWord.end + 1;
} else {
startColumn = position.column;
endColumn = position.column;
}
let lineNumber = position.lineNumber;
let column: number;
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(cursor.hasSelection(), lineNumber, column, 0);
}
示例6: word
public static word(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, position: Position): SingleMoveOperationResult {
let prevWord = WordOperations.findPreviousWordOnLine(config, model, position);
let isInPrevWord = (prevWord && prevWord.wordType === WordType.Regular && prevWord.start < position.column - 1 && position.column - 1 <= prevWord.end);
let nextWord = WordOperations.findNextWordOnLine(config, model, position);
let isInNextWord = (nextWord && nextWord.wordType === WordType.Regular && nextWord.start < position.column - 1 && position.column - 1 <= nextWord.end);
if (!inSelectionMode || !cursor.hasSelection()) {
let startColumn: number;
let endColumn: number;
if (isInPrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isInNextWord) {
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 SingleMoveOperationResult(
new SingleCursorState(
new Range(position.lineNumber, startColumn, position.lineNumber, endColumn), 0,
new Position(position.lineNumber, endColumn), 0
),
false,
CursorChangeReason.Explicit
);
}
let startColumn: number;
let endColumn: number;
if (isInPrevWord) {
startColumn = prevWord.start + 1;
endColumn = prevWord.end + 1;
} else if (isInNextWord) {
startColumn = nextWord.start + 1;
endColumn = nextWord.end + 1;
} else {
startColumn = position.column;
endColumn = position.column;
}
let lineNumber = position.lineNumber;
let column: number;
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 SingleMoveOperationResult.fromMove(cursor, cursor.hasSelection(), lineNumber, column, 0, false, CursorChangeReason.Explicit);
}