當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ICommonCodeEditor.getSelection方法代碼示例

本文整理匯總了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);
	}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:30,代碼來源:multicursor.ts

示例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');
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:9,代碼來源:findModel.test.ts

示例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 });
	}
開發者ID:hungys,項目名稱:vscode,代碼行數:4,代碼來源:snippetVariables.ts

示例4: _tmLineNumber

	private _tmLineNumber(): string {
		return String(this._editor.getSelection().positionLineNumber);
	}
開發者ID:hungys,項目名稱:vscode,代碼行數:3,代碼來源:snippetVariables.ts


注:本文中的vs/editor/common/editorCommon.ICommonCodeEditor.getSelection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。