本文整理匯總了TypeScript中vs/editor/common/editorCommon.ICommonCodeEditor.getSelection方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ICommonCodeEditor.getSelection方法的具體用法?TypeScript ICommonCodeEditor.getSelection怎麽用?TypeScript ICommonCodeEditor.getSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/editorCommon.ICommonCodeEditor
的用法示例。
在下文中一共展示了ICommonCodeEditor.getSelection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let selection = editor.getSelection();
if (selection.isEmpty()) {
return;
}
let model = editor.getModel();
let newSelections = new Array<ISelection>();
let selectionStart = selection.getStartPosition();
let selectionEnd = selection.getEndPosition();
for (var i = selectionStart.lineNumber; i <= selectionEnd.lineNumber; i++) {
if (i !== selectionEnd.lineNumber) {
let currentLineMaxColumn = model.getLineMaxColumn(i);
newSelections.push({
selectionStartLineNumber: i,
selectionStartColumn: currentLineMaxColumn,
positionLineNumber: i,
positionColumn: currentLineMaxColumn
});
} else if (selectionEnd.column > 0) {
newSelections.push({
selectionStartLineNumber: selectionEnd.lineNumber,
selectionStartColumn: selectionEnd.column,
positionLineNumber: selectionEnd.lineNumber,
positionColumn: selectionEnd.column
});
}
}
editor.setSelections(newSelections);
}
示例2: assertFindState
function assertFindState(editor: ICommonCodeEditor, cursor: number[], highlighted: number[], findDecorations: number[][]): void {
assert.deepEqual(fromRange(editor.getSelection()), cursor, 'cursor');
let expectedState = {
highlighted: highlighted ? [highlighted] : [],
findDecorations: findDecorations
};
assert.deepEqual(_getFindState(editor), expectedState, 'state');
}
示例3: _tmCurrentLine
private _tmCurrentLine(): string {
const { positionLineNumber } = this._editor.getSelection();
return this._editor.getModel().getValueInRange({ startLineNumber: positionLineNumber, startColumn: 1, endLineNumber: positionLineNumber, endColumn: Number.MAX_VALUE });
}
示例4: _tmLineNumber
private _tmLineNumber(): string {
return String(this._editor.getSelection().positionLineNumber);
}