* Get the sum of heights for all objects and compute basically the `scrollHeight` for the editor content.
*
* Take into account the `scrollBeyondLastLine` and `reserveHorizontalScrollbarHeight` and produce a scrollHeight that is at least as large as `viewport`.height.
*
* @param viewport The viewport.
* @param reserveHorizontalScrollbarHeight The height of the horizontal scrollbar.
* @return Basically, the `scrollHeight` for the editor content.
* Layouting of objects that take vertical space (by having a height) and push down other objects.
*
* These objects are basically either text (lines) or spaces between those lines (whitespaces).
* This provides commodity operations for working with lines that contain whitespace that pushes lines lower (vertically).
* This is written with no knowledge of an editor in mind.
*/
exportclassVerticalObjects{
/**
* Keep track of the total number of lines.
* This is useful for doing binary searches or for doing hit-testing.
*/
privatelinesCount:number;
/**
* Contains whitespace information in pixels
*/
privatewhitespaces:WhitespaceComputer;
constructor(){
this.linesCount=0;
this.whitespaces=newWhitespaceComputer();
}
/**
* Set the number of lines.
*
* @param newLineCount New number of lines.
*/
publicreplaceLines(newLineCount:number):void{
this.linesCount=newLineCount;
}
/**
* Insert a new whitespace of a certain height after a line number.
* The whitespace has a "sticky" characteristic.
* Irrespective of edits above or below `afterLineNumber`, the whitespace will follow the initial line.
*
* @param afterLineNumber The conceptual position of this whitespace. The whitespace will follow this line as best as possible even when deleting/inserting lines above/below.
* @param heightInPx The height of the whitespace, in pixels.
* @return An id that can be used later to mutate or delete the whitespace