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


TypeScript LinesLayout.getWhitespaceIndexAtOrAfterVerticallOffset方法代码示例

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


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


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