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


TypeScript linesLayout.LinesLayout類代碼示例

本文整理匯總了TypeScript中vs/editor/common/viewLayout/linesLayout.LinesLayout的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinesLayout類的具體用法?TypeScript LinesLayout怎麽用?TypeScript LinesLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test

	test('LinesLayout 1', () => {

		// Start off with 10 lines
		let linesLayout = new LinesLayout(10, 10);

		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: -
		assert.equal(linesLayout.getLinesTotalHeight(), 100);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 20);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 30);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 40);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 50);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 60);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 70);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 80);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 90);

		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(5), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(11), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(15), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(19), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(21), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(29), 3);

		// Add whitespace of height 5px after 2nd line
		linesLayout.insertWhitespace(2, 0, 5, 0);
		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: a(2,5)
		assert.equal(linesLayout.getLinesTotalHeight(), 105);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 25);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 35);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 45);

		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(21), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(24), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(25), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(35), 4);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(45), 5);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(104), 10);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(105), 10);

		// Add two more whitespaces of height 5px
		linesLayout.insertWhitespace(3, 0, 5, 0);
		linesLayout.insertWhitespace(4, 0, 5, 0);
		// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
		// whitespace: a(2,5), b(3, 5), c(4, 5)
		assert.equal(linesLayout.getLinesTotalHeight(), 115);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 10);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 25);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 40);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 55);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 65);

		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(19), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(34), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(35), 4);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(49), 4);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(50), 5);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(64), 5);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(65), 6);

		assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(0), 20); // 20 -> 25
		assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(1), 35); // 35 -> 40
		assert.equal(linesLayout.getVerticalOffsetForWhitespaceIndex(2), 50);

		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(0), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(19), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(20), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(21), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(22), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(23), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(24), 0);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(25), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(26), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(34), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(35), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(36), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(39), 1);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(40), 2);
		assert.equal(linesLayout.getWhitespaceIndexAtOrAfterVerticallOffset(41), 2);
//.........這裏部分代碼省略.........
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:101,代碼來源:linesLayout.test.ts

示例2: saveState

	public saveState(): { scrollTop: number; scrollTopWithoutViewZones: number; scrollLeft: number; } {
		const currentScrollPosition = this.scrollable.getFutureScrollPosition();
		let scrollTop = currentScrollPosition.scrollTop;
		let firstLineNumberInViewport = this._linesLayout.getLineNumberAtOrAfterVerticalOffset(scrollTop);
		let whitespaceAboveFirstLine = this._linesLayout.getWhitespaceAccumulatedHeightBeforeLineNumber(firstLineNumberInViewport);
		return {
			scrollTop: scrollTop,
			scrollTopWithoutViewZones: scrollTop - whitespaceAboveFirstLine,
			scrollLeft: currentScrollPosition.scrollLeft
		};
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:11,代碼來源:viewLayout.ts

示例3: _computeScrollWidth

	private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number {
		let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping;
		if (!isViewportWrapping) {
			const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
			const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth();
			return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth, whitespaceMinWidth);
		}
		return Math.max(maxLineWidth, viewportWidth);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:9,代碼來源:viewLayout.ts

示例4: getLinesViewportDataAtScrollTop

	public getLinesViewportDataAtScrollTop(scrollTop: number): IPartialViewLinesViewportData {
		// do some minimal validations on scrollTop
		const scrollDimensions = this.scrollable.getScrollDimensions();
		if (scrollTop + scrollDimensions.height > scrollDimensions.scrollHeight) {
			scrollTop = scrollDimensions.scrollHeight - scrollDimensions.height;
		}
		if (scrollTop < 0) {
			scrollTop = 0;
		}
		return this._linesLayout.getLinesViewportData(scrollTop, scrollTop + scrollDimensions.height);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:11,代碼來源:viewLayout.ts

示例5: _getTotalHeight

	private _getTotalHeight(): number {
		const scrollDimensions = this.scrollable.getScrollDimensions();

		let result = this._linesLayout.getLinesTotalHeight();
		if (this._configuration.editor.viewInfo.scrollBeyondLastLine) {
			result += scrollDimensions.height - this._configuration.editor.lineHeight;
		} else {
			result += this._getHorizontalScrollbarHeight(scrollDimensions);
		}

		return Math.max(scrollDimensions.height, result);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:12,代碼來源:viewLayout.ts

示例6: onConfigurationChanged

	public onConfigurationChanged(e: IConfigurationChangedEvent): void {
		if (e.lineHeight) {
			this._linesLayout.setLineHeight(this._configuration.editor.lineHeight);
		}
		if (e.layoutInfo) {
			this.scrollable.setScrollDimensions({
				width: this._configuration.editor.layoutInfo.contentWidth,
				height: this._configuration.editor.layoutInfo.contentHeight
			});
		}
		if (e.viewInfo) {
			this._configureSmoothScrollDuration();
		}
		this._updateHeight();
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:15,代碼來源:viewLayout.ts

示例7: onLinesInserted

	public onLinesInserted(fromLineNumber: number, toLineNumber: number): void {
		this._linesLayout.onLinesInserted(fromLineNumber, toLineNumber);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:3,代碼來源:viewLayout.ts

示例8: onFlushed

	public onFlushed(lineCount: number): void {
		this._linesLayout.onFlushed(lineCount);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:3,代碼來源:viewLayout.ts

示例9: addWhitespace

	public addWhitespace(afterLineNumber: number, ordinal: number, height: number, minWidth: number): number {
		return this._linesLayout.insertWhitespace(afterLineNumber, ordinal, height, minWidth);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:3,代碼來源:viewLayout.ts


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