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


TypeScript LinesLayout.getLineNumberAtOrAfterVerticalOffset方法代码示例

本文整理汇总了TypeScript中vs/editor/common/viewLayout/linesLayout.LinesLayout.getLineNumberAtOrAfterVerticalOffset方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LinesLayout.getLineNumberAtOrAfterVerticalOffset方法的具体用法?TypeScript LinesLayout.getLineNumberAtOrAfterVerticalOffset怎么用?TypeScript LinesLayout.getLineNumberAtOrAfterVerticalOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/viewLayout/linesLayout.LinesLayout的用法示例。


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

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

示例2: test

	test('LinesLayout getLineNumberAtOrAfterVerticalOffset', () => {
		let linesLayout = new LinesLayout(10, 1);
		linesLayout.insertWhitespace(6, 0, 10, 0);

		// 10 lines
		// whitespace: - a(6,10)
		assert.equal(linesLayout.getLinesTotalHeight(), 20);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 2);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 3);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 4);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 5);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 18);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 19);

		// Do some hit testing
		// line      [1, 2, 3, 4, 5, 6,  7,  8,  9, 10]
		// vertical: [0, 1, 2, 3, 4, 5, 16, 17, 18, 19]
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(-100), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(-1), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(0), 1);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(1), 2);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(2), 3);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(3), 4);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(4), 5);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(5), 6);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(6), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(7), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(8), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(9), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(10), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(11), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(12), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(13), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(14), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(15), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(16), 7);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(17), 8);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(18), 9);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(19), 10);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(20), 10);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(21), 10);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(22), 10);
		assert.equal(linesLayout.getLineNumberAtOrAfterVerticalOffset(23), 10);
	});
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:48,代码来源:linesLayout.test.ts

示例3: getLineNumberAtVerticalOffset

	public getLineNumberAtVerticalOffset(verticalOffset: number): number {
		return this._linesLayout.getLineNumberAtOrAfterVerticalOffset(verticalOffset);
	}
开发者ID:ramesius,项目名称:vscode,代码行数:3,代码来源:viewLayout.ts


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