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


TypeScript dom.computeScreenAwareSize函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。