• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript cursorCommon.CursorColumns类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/editor/common/controller/cursorCommon.CursorColumns的典型用法代码示例。如果您正苦于以下问题:TypeScript CursorColumns类的具体用法?TypeScript CursorColumns怎么用?TypeScript CursorColumns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CursorColumns类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: down

	public static down(config: CursorConfiguration, model: ICursorSimpleModel, lineNumber: number, column: number, leftoverVisibleColumns: number, count: number, allowMoveOnLastLine: boolean): CursorPosition {
		const currentVisibleColumn = CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize) + leftoverVisibleColumns;

		lineNumber = lineNumber + count;
		let lineCount = model.getLineCount();
		if (lineNumber > lineCount) {
			lineNumber = lineCount;
			if (allowMoveOnLastLine) {
				column = model.getLineMaxColumn(lineNumber);
			} else {
				column = Math.min(model.getLineMaxColumn(lineNumber), column);
				if (CursorColumns.isInsideSurrogatePair(model, lineNumber, column)) {
					column = column - 1;
				}
			}
		} else {
			column = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, currentVisibleColumn);
			if (CursorColumns.isInsideSurrogatePair(model, lineNumber, column)) {
				column = column - 1;
			}
		}

		leftoverVisibleColumns = currentVisibleColumn - CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize);

		return new CursorPosition(lineNumber, column, leftoverVisibleColumns);
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:26,代码来源:cursorMoveOperations.ts


示例2: deleteLeft

	public static deleteLeft(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): [boolean, ICommand[]] {

		if (this._isAutoClosingPairDelete(config, model, selections)) {
			return this._runAutoClosingPairDelete(config, model, selections);
		}

		let commands: ICommand[] = [];
		let shouldPushStackElementBefore = (prevEditOperationType !== EditOperationType.DeletingLeft);
		for (let i = 0, len = selections.length; i < len; i++) {
			const selection = selections[i];

			let deleteSelection: Range = selection;

			if (deleteSelection.isEmpty()) {
				let position = selection.getPosition();

				if (config.useTabStops && position.column > 1) {
					let lineContent = model.getLineContent(position.lineNumber);

					let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
					let lastIndentationColumn = (
						firstNonWhitespaceIndex === -1
							? /* entire string is whitespace */lineContent.length + 1
							: firstNonWhitespaceIndex + 1
					);

					if (position.column <= lastIndentationColumn) {
						let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
						let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
						let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
						deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
					} else {
						deleteSelection = new Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
					}
				} else {
					let leftOfPosition = MoveOperations.left(config, model, position.lineNumber, position.column);
					deleteSelection = new Range(
						leftOfPosition.lineNumber,
						leftOfPosition.column,
						position.lineNumber,
						position.column
					);
				}
			}

			if (deleteSelection.isEmpty()) {
				// Probably at beginning of file => ignore
				commands[i] = null;
				continue;
			}

			if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
				shouldPushStackElementBefore = true;
			}

			commands[i] = new ReplaceCommand(deleteSelection, '');
		}
		return [shouldPushStackElementBefore, commands];
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:59,代码来源:cursorDeleteOperations.ts


示例3: shiftIndentCount

	public static shiftIndentCount(line: string, column: number, tabSize: number): number {
		// Determine the visible column where the content starts
		let contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);

		let desiredTabStop = CursorColumns.nextTabStop(contentStartVisibleColumn, tabSize);

		// The `desiredTabStop` is a multiple of `tabSize` => determine the number of indents
		return desiredTabStop / tabSize;
	}
开发者ID:SeanKilleen,项目名称:vscode,代码行数:9,代码来源:shiftCommand.ts


示例4: deleteLeft

	public static deleteLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): EditOperationResult {
		let r = this.autoClosingPairDelete(config, model, cursor);
		if (r) {
			// This was a case for an auto-closing pair delete
			return r;
		}

		let deleteSelection: Range = cursor.selection;

		if (deleteSelection.isEmpty()) {
			let position = cursor.position;

			if (config.useTabStops && position.column > 1) {
				let lineContent = model.getLineContent(position.lineNumber);

				let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
				let lastIndentationColumn = (
					firstNonWhitespaceIndex === -1
						? /* entire string is whitespace */lineContent.length + 1
						: firstNonWhitespaceIndex + 1
				);

				if (position.column <= lastIndentationColumn) {
					let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
					let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
					let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
					deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
				} else {
					deleteSelection = new Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
				}
			} else {
				let leftOfPosition = MoveOperations.left(config, model, position.lineNumber, position.column);
				deleteSelection = new Range(
					leftOfPosition.lineNumber,
					leftOfPosition.column,
					position.lineNumber,
					position.column
				);
			}
		}

		if (deleteSelection.isEmpty()) {
			// Probably at beginning of file => ignore
			return null;
		}

		let shouldPushStackElementBefore = false;
		if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
			shouldPushStackElementBefore = true;
		}

		return new EditOperationResult(new ReplaceCommand(deleteSelection, ''), {
			shouldPushStackElementBefore: shouldPushStackElementBefore,
			shouldPushStackElementAfter: false
		});
	}
开发者ID:rebornix,项目名称:vscode,代码行数:56,代码来源:cursorDeleteOperations.ts


示例5: _columnSelect

	private static _columnSelect(config: CursorConfiguration, model: ICursorSimpleModel, fromLineNumber: number, fromVisibleColumn: number, toLineNumber: number, toVisibleColumn: number): IColumnSelectResult {
		let lineCount = Math.abs(toLineNumber - fromLineNumber) + 1;
		let reversed = (fromLineNumber > toLineNumber);
		let isRTL = (fromVisibleColumn > toVisibleColumn);
		let isLTR = (fromVisibleColumn < toVisibleColumn);

		let result: SingleCursorState[] = [];

		// console.log(`fromVisibleColumn: ${fromVisibleColumn}, toVisibleColumn: ${toVisibleColumn}`);

		for (let i = 0; i < lineCount; i++) {
			let lineNumber = fromLineNumber + (reversed ? -i : i);

			let startColumn = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, fromVisibleColumn);
			let endColumn = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, toVisibleColumn);
			let visibleStartColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, startColumn));
			let visibleEndColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, endColumn));

			// console.log(`lineNumber: ${lineNumber}: visibleStartColumn: ${visibleStartColumn}, visibleEndColumn: ${visibleEndColumn}`);

			if (isLTR) {
				if (visibleStartColumn > toVisibleColumn) {
					continue;
				}
				if (visibleEndColumn < fromVisibleColumn) {
					continue;
				}
			}

			if (isRTL) {
				if (visibleEndColumn > fromVisibleColumn) {
					continue;
				}
				if (visibleStartColumn < toVisibleColumn) {
					continue;
				}
			}

			result.push(new SingleCursorState(
				new Range(lineNumber, startColumn, lineNumber, startColumn), 0,
				new Position(lineNumber, endColumn), 0
			));
		}

		return {
			viewStates: result,
			reversed: reversed,
			toLineNumber: toLineNumber,
			toVisualColumn: toVisibleColumn
		};
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:51,代码来源:cursorColumnSelection.ts


示例6: shiftIndent

	public static shiftIndent(line: string, column: number, tabSize: number, indentSize: number, insertSpaces: boolean): string {
		// Determine the visible column where the content starts
		const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);

		if (insertSpaces) {
			const indent = cachedStringRepeat(' ', indentSize);
			const desiredTabStop = CursorColumns.nextIndentTabStop(contentStartVisibleColumn, indentSize);
			const indentCount = desiredTabStop / indentSize; // will be an integer
			return cachedStringRepeat(indent, indentCount);
		} else {
			const indent = '\t';
			const desiredTabStop = CursorColumns.nextRenderTabStop(contentStartVisibleColumn, tabSize);
			const indentCount = desiredTabStop / tabSize; // will be an integer
			return cachedStringRepeat(indent, indentCount);
		}
	}
开发者ID:PKRoma,项目名称:vscode,代码行数:16,代码来源:shiftCommand.ts


示例7: columnSelectRight

	public static columnSelectRight(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, toViewLineNumber: number, toViewVisualColumn: number): IColumnSelectResult {
		let maxVisualViewColumn = 0;
		let minViewLineNumber = Math.min(cursor.position.lineNumber, toViewLineNumber);
		let maxViewLineNumber = Math.max(cursor.position.lineNumber, toViewLineNumber);
		for (let lineNumber = minViewLineNumber; lineNumber <= maxViewLineNumber; lineNumber++) {
			let lineMaxViewColumn = model.getLineMaxColumn(lineNumber);
			let lineMaxVisualViewColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, lineMaxViewColumn));
			maxVisualViewColumn = Math.max(maxVisualViewColumn, lineMaxVisualViewColumn);
		}

		if (toViewVisualColumn < maxVisualViewColumn) {
			toViewVisualColumn++;
		}

		return this.columnSelect(config, model, cursor.selection.getStartPosition(), toViewLineNumber, toViewVisualColumn);
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:16,代码来源:cursorColumnSelection.ts


示例8: right

	public static right(config: CursorConfiguration, model: ICursorSimpleModel, lineNumber: number, column: number): CursorPosition {

		if (column < model.getLineMaxColumn(lineNumber)) {
			if (CursorColumns.isHighSurrogate(model, lineNumber, column - 1)) {
				// character after column is a high surrogate
				column = column + 2;
			} else {
				column = column + 1;
			}
		} else if (lineNumber < model.getLineCount()) {
			lineNumber = lineNumber + 1;
			column = model.getLineMinColumn(lineNumber);
		}

		return new CursorPosition(lineNumber, column, 0);
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:16,代码来源:cursorMoveOperations.ts


示例9: left

	public static left(config: CursorConfiguration, model: ICursorSimpleModel, lineNumber: number, column: number): CursorPosition {

		if (column > model.getLineMinColumn(lineNumber)) {
			if (CursorColumns.isLowSurrogate(model, lineNumber, column - 2)) {
				// character before column is a low surrogate
				column = column - 2;
			} else {
				column = column - 1;
			}
		} else if (lineNumber > 1) {
			lineNumber = lineNumber - 1;
			column = model.getLineMaxColumn(lineNumber);
		}

		return new CursorPosition(lineNumber, column, 0);
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:16,代码来源:cursorMoveOperations.ts


示例10: _replaceJumpToNextIndent

	private static _replaceJumpToNextIndent(config: CursorConfiguration, model: ICursorSimpleModel, selection: Selection, insertsAutoWhitespace: boolean): ReplaceCommand {
		let typeText = '';

		let position = selection.getStartPosition();
		if (config.insertSpaces) {
			let visibleColumnFromColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
			let tabSize = config.tabSize;
			let spacesCnt = tabSize - (visibleColumnFromColumn % tabSize);
			for (let i = 0; i < spacesCnt; i++) {
				typeText += ' ';
			}
		} else {
			typeText = '\t';
		}

		return new ReplaceCommand(selection, typeText, insertsAutoWhitespace);
	}
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:17,代码来源:cursorTypeOperations.ts



注:本文中的vs/editor/common/controller/cursorCommon.CursorColumns类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cursorCommon.CursorConfiguration类代码示例发布时间:2022-05-25
下一篇:
TypeScript cursorCommon.isQuote函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap