本文整理汇总了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
};
}
示例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);
});
示例3: getLineNumberAtVerticalOffset
public getLineNumberAtVerticalOffset(verticalOffset: number): number {
return this._linesLayout.getLineNumberAtOrAfterVerticalOffset(verticalOffset);
}