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


TypeScript LinesLayout.changeWhitespace方法代碼示例

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


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

示例1: test

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

		// Start off with 10 lines and one whitespace after line 2, of height 5
		let linesLayout = new LinesLayout(10, 1);
		let a = linesLayout.insertWhitespace(2, 0, 5, 0);

		// 10 lines
		// whitespace: - a(2,5)
		assert.equal(linesLayout.getLinesTotalHeight(), 15);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(1), 0);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(2), 1);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(3), 7);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(4), 8);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(5), 9);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 10);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 11);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 12);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 13);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 14);

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

		// Change whitespace position
		// 10 lines
		// whitespace: - a(5,10)
		linesLayout.changeWhitespace(a, 5, 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), 15);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 18);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 19);

		// Pretend that lines 5 and 6 were deleted
		// 8 lines
		// whitespace: - a(4,10)
		linesLayout.onLinesDeleted(5, 6);
		assert.equal(linesLayout.getLinesTotalHeight(), 18);
		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), 14);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(6), 15);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(7), 16);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 17);

		// Insert two lines at the beginning
		// 10 lines
		// whitespace: - a(6,10)
		linesLayout.onLinesInserted(1, 2);
		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);

		// Remove whitespace
		// 10 lines
		linesLayout.removeWhitespace(a);
		assert.equal(linesLayout.getLinesTotalHeight(), 10);
		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), 6);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(8), 7);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(9), 8);
		assert.equal(linesLayout.getVerticalOffsetForLineNumber(10), 9);
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:97,代碼來源:linesLayout.test.ts

示例2: changeWhitespace

	public changeWhitespace(id: number, newAfterLineNumber: number, newHeight: number): boolean {
		return this._linesLayout.changeWhitespace(id, newAfterLineNumber, newHeight);
	}
開發者ID:ramesius,項目名稱:vscode,代碼行數:3,代碼來源:viewLayout.ts


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