当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript renderingContext.RenderingContext类代码示例

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


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

示例1: _prepareRender

	private _prepareRender(ctx: RenderingContext): ViewCursorRenderData {
		let textContent = '';
		let textContentClassName = '';

		if (this._cursorStyle === TextEditorCursorStyle.Line || this._cursorStyle === TextEditorCursorStyle.LineThin) {
			const visibleRange = ctx.visibleRangeForPosition(this._position);
			if (!visibleRange) {
				// Outside viewport
				return null;
			}
			let width: number;
			if (this._cursorStyle === TextEditorCursorStyle.Line) {
				width = dom.computeScreenAwareSize(this._lineCursorWidth > 0 ? this._lineCursorWidth : 2);
				if (width > 2) {
					const lineContent = this._context.model.getLineContent(this._position.lineNumber);
					textContent = lineContent.charAt(this._position.column - 1);
				}
			} else {
				width = dom.computeScreenAwareSize(1);
			}
			let left = visibleRange.left;
			if (width >= 2 && left >= 1) {
				// try to center cursor
				left -= 1;
			}
			const top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
			return new ViewCursorRenderData(top, left, width, this._lineHeight, textContent, textContentClassName);
		}

		const visibleRangeForCharacter = ctx.linesVisibleRangesForRange(new Range(this._position.lineNumber, this._position.column, this._position.lineNumber, this._position.column + 1), false);

		if (!visibleRangeForCharacter || visibleRangeForCharacter.length === 0 || visibleRangeForCharacter[0].ranges.length === 0) {
			// Outside viewport
			return null;
		}

		const range = visibleRangeForCharacter[0].ranges[0];
		const width = range.width < 1 ? this._typicalHalfwidthCharacterWidth : range.width;

		if (this._cursorStyle === TextEditorCursorStyle.Block) {
			const lineData = this._context.model.getViewLineData(this._position.lineNumber);
			textContent = lineData.content.charAt(this._position.column - 1);
			if (strings.isHighSurrogate(lineData.content.charCodeAt(this._position.column - 1))) {
				textContent += lineData.content.charAt(this._position.column);
			}
			const tokenIndex = lineData.tokens.findTokenIndexAtOffset(this._position.column - 1);
			textContentClassName = lineData.tokens.getClassName(tokenIndex);
		}

		let top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
		let height = this._lineHeight;

		// Underline might interfere with clicking
		if (this._cursorStyle === TextEditorCursorStyle.Underline || this._cursorStyle === TextEditorCursorStyle.UnderlineThin) {
			top += this._lineHeight - 2;
			height = 2;
		}

		return new ViewCursorRenderData(top, range.left, width, height, textContent, textContentClassName);
	}
开发者ID:ramesius,项目名称:vscode,代码行数:60,代码来源:viewCursor.ts

示例2: _getTopLeft

	private _getTopLeft(ctx: RenderingContext, position: Position): Coordinate {
		const visibleRange = ctx.visibleRangeForPosition(position);
		if (!visibleRange) {
			return null;
		}

		const top = ctx.getVerticalOffsetForLineNumber(position.lineNumber) - ctx.scrollTop;
		return new Coordinate(top, visibleRange.left);
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:9,代码来源:contentWidgets.ts

示例3: _renderNormalDecoration

	private _renderNormalDecoration(ctx: RenderingContext, range: Range, className: string, showIfCollapsed: boolean, lineHeight: string, visibleStartLineNumber: number, output: string[]): void {
		let linesVisibleRanges = ctx.linesVisibleRangesForRange(range, /*TODO@Alex*/className === 'findMatch');
		if (!linesVisibleRanges) {
			return;
		}

		for (let j = 0, lenJ = linesVisibleRanges.length; j < lenJ; j++) {
			let lineVisibleRanges = linesVisibleRanges[j];
			const lineIndex = lineVisibleRanges.lineNumber - visibleStartLineNumber;

			if (showIfCollapsed && lineVisibleRanges.ranges.length === 1) {
				const singleVisibleRange = lineVisibleRanges.ranges[0];
				if (singleVisibleRange.width === 0) {
					// collapsed range case => make the decoration visible by faking its width
					lineVisibleRanges.ranges[0] = new HorizontalRange(singleVisibleRange.left, this._typicalHalfwidthCharacterWidth);
				}
			}

			for (let k = 0, lenK = lineVisibleRanges.ranges.length; k < lenK; k++) {
				const visibleRange = lineVisibleRanges.ranges[k];
				const decorationOutput = (
					'<div class="cdr '
					+ className
					+ '" style="left:'
					+ String(visibleRange.left)
					+ 'px;width:'
					+ String(visibleRange.width)
					+ 'px;height:'
					+ lineHeight
					+ 'px;"></div>'
				);
				output[lineIndex] += decorationOutput;
			}
		}
	}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:35,代码来源:decorations.ts

示例4: prepareRender

	public prepareRender(ctx: RenderingContext): void {
		if (!this._enabled) {
			this._renderResult = null;
			return;
		}

		const visibleStartLineNumber = ctx.visibleRange.startLineNumber;
		const visibleEndLineNumber = ctx.visibleRange.endLineNumber;
		const tabSize = this._context.model.getTabSize();
		const tabWidth = tabSize * this._spaceWidth;
		const lineHeight = this._lineHeight;
		const indentGuideWidth = dom.computeScreenAwareSize(1);

		let output: string[] = [];
		for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
			let lineIndex = lineNumber - visibleStartLineNumber;
			let indent = this._context.model.getLineIndentGuide(lineNumber);

			let result = '';
			let leftMostVisiblePosition = ctx.visibleRangeForPosition(new Position(lineNumber, 1));
			let left = leftMostVisiblePosition ? leftMostVisiblePosition.left : 0;
			for (let i = 0; i < indent; i++) {
				result += `<div class="cigr" style="left:${left}px;height:${lineHeight}px;width:${indentGuideWidth}px"></div>`;
				left += tabWidth;
			}

			output[lineIndex] = result;
		}
		this._renderResult = output;
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:30,代码来源:indentGuides.ts

示例5: _getTopAndBottomLeft

	/**
	 * Compute `this._topLeft`
	 */
	private _getTopAndBottomLeft(ctx: RenderingContext): [Coordinate, Coordinate] | [null, null] {
		if (!this._viewPosition) {
			return [null, null];
		}

		const visibleRangeForPosition = ctx.visibleRangeForPosition(this._viewPosition);
		if (!visibleRangeForPosition) {
			return [null, null];
		}

		const topForPosition = ctx.getVerticalOffsetForLineNumber(this._viewPosition.lineNumber) - ctx.scrollTop;
		const topLeft = new Coordinate(topForPosition, visibleRangeForPosition.left);

		let largestLineNumber = this._viewPosition.lineNumber;
		let smallestLeft = visibleRangeForPosition.left;

		if (this._viewRange) {
			const visibleRangesForRange = ctx.linesVisibleRangesForRange(this._viewRange, false);
			if (visibleRangesForRange && visibleRangesForRange.length > 0) {
				for (let i = visibleRangesForRange.length - 1; i >= 0; i--) {
					const visibleRangesForLine = visibleRangesForRange[i];
					if (visibleRangesForLine.lineNumber >= largestLineNumber) {
						if (visibleRangesForLine.lineNumber > largestLineNumber) {
							largestLineNumber = visibleRangesForLine.lineNumber;
							smallestLeft = Constants.MAX_SAFE_SMALL_INTEGER;
						}
						for (let j = 0, lenJ = visibleRangesForLine.ranges.length; j < lenJ; j++) {
							const visibleRange = visibleRangesForLine.ranges[j];

							if (visibleRange.left < smallestLeft) {
								smallestLeft = visibleRange.left;
							}
						}
					}
				}
			}
		}

		const topForBottomLine = ctx.getVerticalOffsetForLineNumber(largestLineNumber) - ctx.scrollTop;
		const bottomLeft = new Coordinate(topForBottomLine, smallestLeft);

		return [topLeft, bottomLeft];
	}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:46,代码来源:contentWidgets.ts

示例6: _renderNormalDecorations

	private _renderNormalDecorations(ctx: RenderingContext, decorations: ViewModelDecoration[], output: string[]): void {
		let lineHeight = String(this._lineHeight);
		let visibleStartLineNumber = ctx.visibleRange.startLineNumber;

		for (let i = 0, lenI = decorations.length; i < lenI; i++) {
			const d = decorations[i];

			if (d.options.isWholeLine) {
				continue;
			}

			const className = d.options.className;
			const showIfCollapsed = d.options.showIfCollapsed;

			let range = d.range;
			if (showIfCollapsed && range.endColumn === 1 && range.endLineNumber !== range.startLineNumber) {
				range = new Range(range.startLineNumber, range.startColumn, range.endLineNumber - 1, this._context.model.getLineMaxColumn(range.endLineNumber - 1));
			}

			let linesVisibleRanges = ctx.linesVisibleRangesForRange(range, /*TODO@Alex*/className === 'findMatch');
			if (!linesVisibleRanges) {
				continue;
			}

			for (let j = 0, lenJ = linesVisibleRanges.length; j < lenJ; j++) {
				let lineVisibleRanges = linesVisibleRanges[j];
				const lineIndex = lineVisibleRanges.lineNumber - visibleStartLineNumber;

				if (showIfCollapsed && lineVisibleRanges.ranges.length === 1) {
					const singleVisibleRange = lineVisibleRanges.ranges[0];
					if (singleVisibleRange.width === 0) {
						// collapsed range case => make the decoration visible by faking its width
						lineVisibleRanges.ranges[0] = new HorizontalRange(singleVisibleRange.left, this._typicalHalfwidthCharacterWidth);
					}
				}

				for (let k = 0, lenK = lineVisibleRanges.ranges.length; k < lenK; k++) {
					const visibleRange = lineVisibleRanges.ranges[k];
					const decorationOutput = (
						'<div class="cdr '
						+ className
						+ '" style="left:'
						+ String(visibleRange.left)
						+ 'px;width:'
						+ String(visibleRange.width)
						+ 'px;height:'
						+ lineHeight
						+ 'px;"></div>'
					);
					output[lineIndex] += decorationOutput;
				}
			}
		}
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:54,代码来源:decorations.ts

示例7: _getDecorations

	protected _getDecorations(ctx: RenderingContext): DecorationToRender[] {
		let decorations = ctx.getDecorationsInViewport();
		let r: DecorationToRender[] = [], rLen = 0;
		for (let i = 0, len = decorations.length; i < len; i++) {
			let d = decorations[i];
			let linesDecorationsClassName = d.options.linesDecorationsClassName;
			if (linesDecorationsClassName) {
				r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, linesDecorationsClassName);
			}
		}
		return r;
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:12,代码来源:linesDecorations.ts

示例8: _getDecorations

	protected _getDecorations(ctx: RenderingContext): DecorationToRender[] {
		let decorations = ctx.getDecorationsInViewport();
		let r: DecorationToRender[] = [];
		for (let i = 0, len = decorations.length; i < len; i++) {
			let d = decorations[i];
			let marginClassName = d.source.options.marginClassName;
			if (marginClassName) {
				r.push(new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, marginClassName));
			}
		}
		return r;
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:12,代码来源:marginDecorations.ts

示例9: _prepareRender

	private _prepareRender(ctx: RenderingContext): ViewCursorRenderData {
		if (this._cursorStyle === TextEditorCursorStyle.Line || this._cursorStyle === TextEditorCursorStyle.LineThin) {
			const visibleRange = ctx.visibleRangeForPosition(this._position);
			if (!visibleRange) {
				// Outside viewport
				return null;
			}
			let width: number;
			if (this._cursorStyle === TextEditorCursorStyle.Line) {
				width = 2;
			} else {
				width = 1;
			}
			const top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
			return new ViewCursorRenderData(top, visibleRange.left, width, '');
		}

		const visibleRangeForCharacter = ctx.linesVisibleRangesForRange(new Range(this._position.lineNumber, this._position.column, this._position.lineNumber, this._position.column + 1), false);

		if (!visibleRangeForCharacter || visibleRangeForCharacter.length === 0 || visibleRangeForCharacter[0].ranges.length === 0) {
			// Outside viewport
			return null;
		}

		const range = visibleRangeForCharacter[0].ranges[0];
		const width = range.width < 1 ? this._typicalHalfwidthCharacterWidth : range.width;

		let textContent = '';
		if (this._cursorStyle === TextEditorCursorStyle.Block) {
			const lineContent = this._context.model.getLineContent(this._position.lineNumber);
			textContent = lineContent.charAt(this._position.column - 1);
		}

		const top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
		return new ViewCursorRenderData(top, range.left, width, textContent);
	}
开发者ID:wangcheng678,项目名称:vscode,代码行数:36,代码来源:viewCursor.ts

示例10: prepareRender

	public prepareRender(ctx: RenderingContext): void {
		if (!this._enabled) {
			this._renderResult = null;
			return;
		}

		const visibleStartLineNumber = ctx.visibleRange.startLineNumber;
		const visibleEndLineNumber = ctx.visibleRange.endLineNumber;
		const tabSize = this._context.model.getTabSize();
		const tabWidth = tabSize * this._spaceWidth;
		const scrollWidth = ctx.scrollWidth;
		const lineHeight = this._lineHeight;
		const indentGuideWidth = tabWidth;

		const indents = this._context.model.getLinesIndentGuides(visibleStartLineNumber, visibleEndLineNumber);

		let activeIndentStartLineNumber = 0;
		let activeIndentEndLineNumber = 0;
		let activeIndentLevel = 0;
		if (this._primaryLineNumber) {
			const activeIndentInfo = this._context.model.getActiveIndentGuide(this._primaryLineNumber, visibleStartLineNumber, visibleEndLineNumber);
			activeIndentStartLineNumber = activeIndentInfo.startLineNumber;
			activeIndentEndLineNumber = activeIndentInfo.endLineNumber;
			activeIndentLevel = activeIndentInfo.indent;
		}

		let output: string[] = [];
		for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
			const containsActiveIndentGuide = (activeIndentStartLineNumber <= lineNumber && lineNumber <= activeIndentEndLineNumber);
			const lineIndex = lineNumber - visibleStartLineNumber;
			const indent = indents[lineIndex];

			let result = '';
			let leftMostVisiblePosition = ctx.visibleRangeForPosition(new Position(lineNumber, 1));
			let left = leftMostVisiblePosition ? leftMostVisiblePosition.left : 0;
			for (let i = 1; i <= indent; i++) {
				let className = (containsActiveIndentGuide && i === activeIndentLevel ? 'cigra' : 'cigr');
				result += `<div class="${className}" style="left:${left}px;height:${lineHeight}px;width:${indentGuideWidth}px"></div>`;
				left += tabWidth;
				if (left > scrollWidth) {
					break;
				}
			}

			output[lineIndex] = result;
		}
		this._renderResult = output;
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:48,代码来源:indentGuides.ts


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