本文整理匯總了TypeScript中vs/editor/common/viewLayout/linesLayout.LinesLayout.onLinesInserted方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinesLayout.onLinesInserted方法的具體用法?TypeScript LinesLayout.onLinesInserted怎麽用?TypeScript LinesLayout.onLinesInserted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/viewLayout/linesLayout.LinesLayout
的用法示例。
在下文中一共展示了LinesLayout.onLinesInserted方法的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);
});
示例2: onLinesInserted
public onLinesInserted(fromLineNumber: number, toLineNumber: number): void {
this._linesLayout.onLinesInserted(fromLineNumber, toLineNumber);
}