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

TypeScript dom.computeScreenAwareSize函数代码示例

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

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



在下文中一共展示了computeScreenAwareSize函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: _ensureRulersCount

	private _ensureRulersCount(): void {
		const currentCount = this._renderedRulers.length;
		const desiredCount = this._rulers.length;

		if (currentCount === desiredCount) {
			// Nothing to do
			return;
		}

		if (currentCount < desiredCount) {
			const rulerWidth = dom.computeScreenAwareSize(1);
			let addCount = desiredCount - currentCount;
			while (addCount > 0) {
				let node = createFastDomNode(document.createElement('div'));
				node.setClassName('view-ruler');
				node.setWidth(rulerWidth);
				this.domNode.appendChild(node);
				this._renderedRulers.push(node);
				addCount--;
			}
			return;
		}

		let removeCount = currentCount - desiredCount;
		while (removeCount > 0) {
			let node = this._renderedRulers.pop();
			this.domNode.removeChild(node);
			removeCount--;
		}
	}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:30,代码来源:rulers.ts


示例3: 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


示例4: _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 = dom.computeScreenAwareSize(2);
			} else {
				width = dom.computeScreenAwareSize(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:Chan-PH,项目名称:vscode,代码行数:36,代码来源:viewCursor.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript dom.createCSSRule函数代码示例发布时间:2022-05-25
下一篇:
TypeScript dom.clearNode函数代码示例发布时间: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