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


TypeScript IModel.getValueInRange方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/editorCommon.IModel.getValueInRange方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IModel.getValueInRange方法的具體用法?TypeScript IModel.getValueInRange怎麽用?TypeScript IModel.getValueInRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/editorCommon.IModel的用法示例。


在下文中一共展示了IModel.getValueInRange方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: resolve

	resolve(name: string): string {
		if (name === 'SELECTION' || name === 'TM_SELECTED_TEXT') {
			return this._model.getValueInRange(this._selection);

		} else if (name === 'TM_CURRENT_LINE') {
			return this._model.getLineContent(this._selection.positionLineNumber);

		} else if (name === 'TM_CURRENT_WORD') {
			const info = this._model.getWordAtPosition({
				lineNumber: this._selection.positionLineNumber,
				column: this._selection.positionColumn
			});
			return info ? info.word : '';

		} else if (name === 'TM_LINE_INDEX') {
			return String(this._selection.positionLineNumber - 1);

		} else if (name === 'TM_LINE_NUMBER') {
			return String(this._selection.positionLineNumber);

		} else if (name === 'TM_FILENAME') {
			return basename(this._model.uri.fsPath);

		} else if (name === 'TM_DIRECTORY') {
			const dir = dirname(this._model.uri.fsPath);
			return dir !== '.' ? dir : '';

		} else if (name === 'TM_FILEPATH') {
			return this._model.uri.fsPath;

		} else {
			return undefined;
		}
	}
開發者ID:hungys,項目名稱:vscode,代碼行數:34,代碼來源:snippetVariables.ts

示例2: _cursorUnselectedMessage

	private static _cursorUnselectedMessage(model: IModel, range: Range): string {
		const valueLength = model.getValueLengthInRange(range);
		if (valueLength > 512) {
			return this.xCharsUnselected(valueLength);
		}
		return this.xUnselected(model.getValueInRange(range));
	}
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:7,代碼來源:accGenerator.ts

示例3: appendValueFromRange

function appendValueFromRange(base: string, model: IModel, range: Range): string {
	var result = base;
	if (result !== '') {
		result += model.getEOL();
	}
	return result + model.getValueInRange(range);
}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:7,代碼來源:stageRanges.ts

示例4: _cursorMoveMessage

	private static _cursorMoveMessage(source: string, model: IModel, oldPosition: Position, newPosition: Position): string {

		if (source === 'moveWordCommand') {
			return model.getValueInRange(new Range(oldPosition.lineNumber, oldPosition.column, newPosition.lineNumber, newPosition.column));
		}

		const oldLineNumber = oldPosition.lineNumber;
		const oldColumn = oldPosition.column;
		const newLineNumber = newPosition.lineNumber;
		const newColumn = newPosition.column;

		// check going down via right arrow
		if (newLineNumber === oldLineNumber + 1 && newColumn === 1 && oldColumn === model.getLineMaxColumn(oldLineNumber)) {
			return this._cursorCharMessage(model, newPosition);
		}

		// check going up via up arrow
		if (newLineNumber === oldLineNumber - 1 && newColumn === model.getLineMaxColumn(newLineNumber) && oldColumn === 1) {
			return this._cursorCharMessage(model, newPosition);
		}

		const lineCount = model.getLineCount();
		if (oldLineNumber !== newLineNumber) {
			if (newLineNumber === lineCount) {
				// Last line does not have an EOL
				return model.getLineContent(newLineNumber);
			}
			return model.getLineContent(newLineNumber) + model.getEOL();
		}

		return this._cursorCharMessage(model, newPosition);
	}
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:32,代碼來源:accGenerator.ts

示例5: getDeleteOperation

	return changes.map((change, i) => {
		if (isInsertion(change)) {
			// Delete inserted range
			return getDeleteOperation(change);
		} else if (isDeletion(change)) {
			// Get the original lines and insert at the deleted position
			const value = original.getValueInRange(getLinesRangeWithOneSurroundingNewline(original, change.originalStartLineNumber, change.originalEndLineNumber));
			return EditOperation.insert(new Position(change.modifiedStartLineNumber + 1, 1), value);
		} else if (change.isCompletelySelected) {
			// If the entire change is selected, then revert the whole thing.
			const value = original.getValueInRange(new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber + 1, 1));
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber + 1, 1), value);
		} else {
			// If only a portion is selected, replace with the matching lines - e.g. if lines 2-4 are selected, replace with lines 2-4 from the original model (if they exist)
			const copyOffset = change.modifiedStartLineNumber - change.fullModifiedStartLineNumber;
			const numLinesToCopy = change.modifiedEndLineNumber - change.modifiedStartLineNumber;
			const copyStartLine = change.originalStartLineNumber + copyOffset;
			const copyEndLine = Math.min(copyStartLine + numLinesToCopy, original.getLineCount());
			if (copyStartLine > copyEndLine) {
				return getDeleteOperation(change);
			}

			// Compute the range to copy, and intersect with the full original range to validate
			const originalRange = new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber, original.getLineMaxColumn(change.originalEndLineNumber));
			const rangeToCopy = originalRange.intersectRanges(
				new Range(copyStartLine, 1, copyEndLine, original.getLineMaxColumn(copyEndLine)));

			// No intersection, so delete the added text
			if (!rangeToCopy) {
				return getDeleteOperation(change);
			}

			const value = original.getValueInRange(rangeToCopy);
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber, modified.getLineMaxColumn(change.modifiedEndLineNumber)), value);
		}
	});
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:36,代碼來源:stageRanges.ts


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