本文整理汇总了TypeScript中vs/editor/common/viewLayout/verticalObjects.VerticalObjects.getCenteredLineInViewport方法的典型用法代码示例。如果您正苦于以下问题:TypeScript VerticalObjects.getCenteredLineInViewport方法的具体用法?TypeScript VerticalObjects.getCenteredLineInViewport怎么用?TypeScript VerticalObjects.getCenteredLineInViewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/viewLayout/verticalObjects.VerticalObjects
的用法示例。
在下文中一共展示了VerticalObjects.getCenteredLineInViewport方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('VerticalObjects getCenteredLineInViewport', () => {
var verticalObjects = new VerticalObjects();
verticalObjects.replaceLines(10);
verticalObjects.insertWhitespace(6, 0, 10);
// 10 lines
// whitespace: - a(6,10)
assert.equal(verticalObjects.getTotalHeight(1), 20);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(1, 1), 0);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(2, 1), 1);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(3, 1), 2);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(4, 1), 3);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(5, 1), 4);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(6, 1), 5);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(7, 1), 16);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(8, 1), 17);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(9, 1), 18);
assert.equal(verticalObjects.getVerticalOffsetForLineNumber(10, 1), 19);
// Find centered line in viewport 1
// line [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// vertical: [0, 1, 2, 3, 4, 5, 16, 17, 18, 19]
assert.equal(verticalObjects.getCenteredLineInViewport(0, 1, 1), 1);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 2, 1), 2);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 3, 1), 2);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 4, 1), 3);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 5, 1), 3);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 6, 1), 4);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 7, 1), 4);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 8, 1), 5);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 9, 1), 5);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 10, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 11, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 12, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 13, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 14, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 15, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 16, 1), 6);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 17, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 18, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 19, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 21, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 22, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 23, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 24, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 25, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 26, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 27, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 28, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 29, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 30, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 31, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 32, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(0, 33, 1), 7);
// Find centered line in viewport 2
// line [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// vertical: [0, 1, 2, 3, 4, 5, 16, 17, 18, 19]
assert.equal(verticalObjects.getCenteredLineInViewport(0, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(1, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(2, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(3, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(4, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(5, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(6, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(7, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(8, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(9, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(10, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(11, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(12, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(13, 20, 1), 7);
assert.equal(verticalObjects.getCenteredLineInViewport(14, 20, 1), 8);
assert.equal(verticalObjects.getCenteredLineInViewport(15, 20, 1), 8);
assert.equal(verticalObjects.getCenteredLineInViewport(16, 20, 1), 9);
assert.equal(verticalObjects.getCenteredLineInViewport(17, 20, 1), 9);
assert.equal(verticalObjects.getCenteredLineInViewport(18, 20, 1), 10);
assert.equal(verticalObjects.getCenteredLineInViewport(19, 20, 1), 10);
assert.equal(verticalObjects.getCenteredLineInViewport(20, 23, 1), 10);
assert.equal(verticalObjects.getCenteredLineInViewport(21, 23, 1), 10);
assert.equal(verticalObjects.getCenteredLineInViewport(22, 23, 1), 10);
});
示例2: getCenteredLineInViewport
/**
* Get the line that appears visually in the center of `viewport`.
*
* @param viewport The viewport.
* @return The line number that is closest to the center of `viewport`.
*/
public getCenteredLineInViewport(visibleBox:editorCommon.Viewport): number {
return this.verticalObjects.getCenteredLineInViewport(visibleBox.top, visibleBox.top + visibleBox.height, this._lineHeight);
}
示例3: getCenteredLineInViewport
/**
* Get the line that appears visually in the center of `viewport`.
*
* @param viewport The viewport.
* @return The line number that is closest to the center of `viewport`.
*/
public getCenteredLineInViewport(visibleBox:EditorCommon.IViewport): number {
return this.verticalObjects.getCenteredLineInViewport(visibleBox.top, visibleBox.top + visibleBox.height, this.configuration.editor.lineHeight);
}