#viewer/common/view_layout

    DOM-free scrolling, line/whitespace layout, view zones, and view-line rendering.

    Everything about where things are — the scroll position, which lines fall in the viewport, how tall a view zone makes the document, where a reveal should scroll to — is computed here, with no DOM and no requestAnimationFrame. Animation scheduling and the clock are injected, which is what makes this package testable on the native target.

    flowchart TB L["line_height × line_count"] --> LL["LinesLayout<br>prefix sums"] WZ["view zones / whitespace<br>(incremental transaction)"] --> LL LL --> CH["content height"] MW["max measured line width"] --> CW["content width"] CH --> VL["ViewLayout<br>single scroll truth"] CW --> VL VL --> SC["Scrollable<br>current + future position"] SC --> VP["Viewport / visible line window"] SC --> RV["reveal computation"]

    #The vertical map

    LinesLayout, prefix-sum computers, and whitespace accessors map line/view-zone heights to vertical offsets. With no whitespace, the map is just line_height × (n - 1).

    ///|
    fn layout(line_count : Int32) -> @view_layout.ViewLayout {
    ViewLayout(line_height=20, line_count~)
    }

    ///|
    test "vertical offsets are the prefix sum of line heights" {
    let view = layout(10)
    debug_inspect(
    (
    view.get_content_height(),
    view.get_vertical_offset_for_line_number(1),
    view.get_vertical_offset_for_line_number(3),
    view.get_line_height_for_line_number(3),
    ),
    content=(
    #|(200, 0, 40, 20)
    ),
    )
    }

    The current viewer assumes one uniform view-line height; variable line heights are outside the readonly contract.

    #Scrolling and the viewport

    ScrollState retains raw and validated positions; Scrollable owns current and future positions plus the cubic smooth-animation state machine. EditorScrollable normalizes editor content dimensions, while ScrollbarState contains pure slider geometry and provides a field-for-field clone for gesture snapshots. ViewLayout is the viewer's single scroll truth.

    A scroll position is validated against the content, so a caller cannot scroll past the end or to a negative offset.

    ///|
    test "scroll positions are clamped to the scrollable content" {
    let view = layout(100)
    view.set_viewport_size(width=400.0, height=200.0) |> ignore
    view.scroll_to(scroll_top=50.0) |> ignore
    let inside = view.get_current_scroll_top()
    view.scroll_to(scroll_top=-10.0) |> ignore
    let negative = view.get_current_scroll_top()
    view.scroll_to(scroll_top=999999.0) |> ignore
    let past_end = view.get_current_scroll_top()
    debug_inspect(
    (inside, negative, past_end, view.get_scroll_height()),
    content=(
    #|(50, 0, 1800, 2000)
    ),
    )
    }

    The viewport is derived, not stored separately: it is the scroll position plus the measured dimensions, and the visible line window follows from the vertical map.

    ///|
    test "the visible line window follows from scroll top and height" {
    let view = layout(100)
    view.set_viewport_size(width=400.0, height=200.0) |> ignore
    view.scroll_to(scroll_top=0.0) |> ignore
    let at_top = view.completely_visible_line_range()
    view.scroll_to(scroll_top=210.0) |> ignore
    let scrolled = view.completely_visible_line_range()
    debug_inspect(
    (at_top, scrolled, view.get_current_viewport().top),
    content=(
    #|((1, 10), (12, 20), 210)
    ),
    )
    }

    ViewLayout retains the maximum measured rendered-line width, derives content width, and feeds horizontal-scrollbar visibility back into the bottom content extent. set_max_line_width publishes the width transition before recomputing the horizontal-scrollbar contribution to content height. Listeners observe those two source-ordered events; the method's local ScrollChange? compatibility return merges them into one complete old-to-new transition.

    ///|
    test "a wider measured line grows the content width" {
    let view = layout(10)
    view.set_viewport_size(width=400.0, height=200.0) |> ignore
    let narrow = view.get_content_width()
    view.set_max_line_width(1200.0) |> ignore
    debug_inspect(
    (narrow, view.get_content_width()),
    content=(
    #|(0, 1214)
    ),
    )
    }

    #Whitespace and view zones

    ViewZones use only the incremental whitespace transaction and generated-ID APIs; the former reduced whole-array adapter and zone indexes are gone. Browser DOM mounting and the public mutable delegate live above this package. Adding whitespace after a line pushes every later line down.

    ///|
    test "whitespace inserted after a line shifts the lines below it" {
    let view = layout(10)
    let before = view.get_vertical_offset_for_line_number(5)
    let changed = view.change_whitespace(accessor => {
    accessor.insert_whitespace(3, 0, 60, 0) |> ignore
    })
    debug_inspect(
    (
    changed,
    before,
    view.get_vertical_offset_for_line_number(5),
    view.get_content_height(),
    ),
    content=(
    #|(true, 80, 140, 260)
    ),
    )
    }

    Removing it restores the map exactly, so a zone's lifetime cannot leak height.

    ///|
    test "removing whitespace restores the previous vertical map" {
    let view = layout(10)
    let baseline = view.get_content_height()
    let id = Ref("")
    view.change_whitespace(accessor => {
    id.val = accessor.insert_whitespace(3, 0, 60, 0)
    })
    |> ignore
    let with_zone = view.get_content_height()
    view.change_whitespace(accessor => accessor.remove_whitespace(id.val))
    |> ignore
    debug_inspect(
    (baseline, with_zone, view.get_content_height()),
    content=(
    #|(200, 260, 200)
    ),
    )
    }

    Whitespace height and minimum-width inputs stay Double until the accessor applies exact JavaScript ToInt32, including signed zero, non-finite values, and 32-bit wrap. Retained leaf heights remain Int, while prefix sums, total heights, line-height products, and public vertical offsets use Double like JavaScript Number; multiple valid Int32 heights therefore never re-enter 32-bit arithmetic. Source-owned downstream |0 coercion points in searches and viewport entry remain explicit. Pending operations commit in cleanup even when a raising callback exits the transaction. ViewLayout exposes that incremental transaction plus ID-bearing whitespace hit, viewport, all-data, explicit-scroll-top, and saved-scroll facades.

    #Reveal

    Reveal answers "what scroll top makes this line range visible", and the answer depends on how you want it revealed. Vertical reveal math composes against the future viewport, while measured horizontal reveal uses the current viewport like ViewLines; both accept the source/minimal contract and omit their ordinary padding for minimal cursor reveals.

    ///|
    test "reveal type decides where a line lands in the viewport" {
    let view = layout(100)
    view.set_viewport_size(width=400.0, height=200.0) |> ignore
    view.scroll_to(scroll_top=0.0) |> ignore
    debug_inspect(
    (
    view.compute_scroll_top_to_reveal_range(50, 50, Simple),
    view.compute_scroll_top_to_reveal_range(50, 50, Center),
    view.compute_scroll_top_to_reveal_range(50, 50, Top),
    ),
    content=(
    #|(820, 890, 980)
    ),
    )
    }

    #Geometry reductions

    Geometry configuration is deliberately reduced to typed setters and fixed readonly-product arms: line padding is zero, horizontal scrollbar visibility is Auto, scrollBeyondLastLine and horizontal-scrollbar-height ignoring are false, and there is no minimap or overlay-widget minimum-width owner. .view-line-content measurement already contains the fixed 16px CSS right padding, replacing the unavailable scrollBeyondLastColumn * halfwidth option before ViewLayout adds the vertical-scrollbar and whitespace-minimum candidates. Wrapped width is the measured maximum because the only source threshold adjustment belongs to the absent right-side minimap.

    #Rendering a view line

    render_view_line* converts RenderLineInput into escaped HTML plus CharacterMapping/DomPosition, preserving the source-to-DOM mapping used by hit testing and selections. The input retains Monaco's normalized render-space width/glyph identity rather than the raw middot candidates. This package also owns decoration normalization and current-line-highlight decisions. Renderer output retains Monaco's two foreign-element bits as the closed None/Before/After/BeforeAndAfter states so lines decorated on both sides preserve both geometry facts.

    #Boundaries and checks

    ViewportData, ViewLineRenderingData, and ID-based ViewWhitespaceViewportData live here as dependency-bottom data. Their model-dependent factory is view_model.viewport_data_from_view_model, keeping the dependency one-way.

    The Monaco map is the pinned src/vs/editor/common/viewLayout/{viewLayout,linesLayout,viewLinesViewportData,viewLineRenderer}.ts, src/vs/base/common/scrollable.ts, and the base browser scrollbar state.

    This package depends only on base/common and the value-only viewer/common/editor_api, declares no FFI, and must not import view-model, root viewer, browser, server, transport, workspace, or host packages. See pkg.generated.mbti.

    moon test --target js viewer/common/view_layout

    CharacterMapping

    pub struct CharacterMapping {
    length : Int
    entries : Array[CharacterMappingEntry]
    } derive(Eq,
    Debug
    )

    Column-to-DOM mapping produced while rendering a line.

    CharacterMapping::CharacterMapping

    fn CharacterMapping::CharacterMapping(length : Int) -> CharacterMapping

    Creates a mapping with length column slots.

    CharacterMapping::column_horizontal_offset

    fn CharacterMapping::column_horizontal_offset(self : CharacterMapping, column : Int, space_width~ : Double) -> Double

    Horizontal CSS-pixel offset for a one-based line column.

    CharacterMapping::equal

    CharacterMapping::get_column

    fn CharacterMapping::get_column(self : CharacterMapping, dom_position : DomPosition, part_length : Int) -> Int

    Returns the one-based line column nearest a DOM position, transcribing Monaco's CharacterMapping.getColumn/partDataToCharOffset. The mapping entries are laid out left-to-right, so their (part_index, char_index) ranks increase monotonically; a binary search brackets the DOM position between two columns and returns the nearer one. part_length bounds the "sitting between parts" case, where the upper column starts a new part.

    CharacterMapping::get_dom_position

    fn CharacterMapping::get_dom_position(self : CharacterMapping, column : Int) -> DomPosition

    Returns the DOM position nearest a one-based line column.

    CharacterMapping::get_horizontal_offset

    fn CharacterMapping::get_horizontal_offset(self : CharacterMapping, column : Int) -> Int

    Visible monospace column for a one-based line column.

    CharacterMapping::inflate

    Copies the raw mapping entries for diagnostics and tests.

    CharacterMapping::not_equal

    fn CharacterMapping::not_equal(x : CharacterMapping, y : CharacterMapping) -> Bool

    CharacterMapping::set_column_info

    fn CharacterMapping::set_column_info(self : CharacterMapping, column : Int, part_index : Int, char_index : Int, visible_column : Int) -> Unit

    Stores DOM and visible-column info for a one-based line column.

    CharacterMappingEntry

    pub struct CharacterMappingEntry {
    part_index : Int
    char_index : Int
    visible_column : Int
    } derive(Eq,
    Debug
    )

    Mapping entry from one line column to rendered DOM coordinates and visible monospace column.

    CharacterMappingEntry::equal

    CharacterMappingEntry::not_equal

    ConstantTimePrefixSumComputer

    pub struct ConstantTimePrefixSumComputer {
    values : Array[Int]
    is_valid : Bool
    valid_end_index : Int
    prefix_sum : Array[Int]
    index_by_sum : Array[Int]
    }

    O(1) amortized get_index_of variant that materializes a full index-by-sum table on first query and re-builds it lazily after mutations.

    ConstantTimePrefixSumComputer::ConstantTimePrefixSumComputer

    fn ConstantTimePrefixSumComputer::ConstantTimePrefixSumComputer(values : ArrayView[Int]) -> ConstantTimePrefixSumComputer

    ConstantTimePrefixSumComputer::get_index_of

    ConstantTimePrefixSumComputer::get_prefix_sum

    fn ConstantTimePrefixSumComputer::get_prefix_sum(self : ConstantTimePrefixSumComputer, count : Int) -> Int

    Returns the sum of the first count many items: SUM(0 <= j < count, values[j]).

    ConstantTimePrefixSumComputer::get_total_sum

    ConstantTimePrefixSumComputer::insert_values

    fn ConstantTimePrefixSumComputer::insert_values(self : ConstantTimePrefixSumComputer, insert_index : Int, insert_arr : Array[Int]) -> Unit

    ConstantTimePrefixSumComputer::remove_values

    fn ConstantTimePrefixSumComputer::remove_values(self : ConstantTimePrefixSumComputer, start : Int, delete_count : Int) -> Unit

    ConstantTimePrefixSumComputer::set_value

    fn ConstantTimePrefixSumComputer::set_value(self : ConstantTimePrefixSumComputer, index : Int, value : Int) -> Unit

    ContentSizeChange

    pub(all) struct ContentSizeChange {
    old_content_width : Double
    old_content_height : Double
    content_width : Double
    content_height : Double
    } derive(Eq,
    Debug
    )

    ContentSizeChange::equal

    ContentSizeChange::not_equal

    fn ContentSizeChange::not_equal(x : ContentSizeChange, y : ContentSizeChange) -> Bool

    DecorationSegment

    pub(all) struct DecorationSegment {
    start_offset : Int
    end_offset : Int
    class_name : String
    metadata : Int
    } derive(Eq,
    Debug
    )

    Normalized decoration segment in zero-based offsets.

    DecorationSegment::equal

    DecorationSegment::not_equal

    fn DecorationSegment::not_equal(x : DecorationSegment, y : DecorationSegment) -> Bool

    DomPosition

    pub(all) struct DomPosition {
    part_index : Int
    char_index : Int
    } derive(Eq,
    Debug
    )

    DOM span/character coordinate for a rendered line.

    DomPosition::equal

    fn DomPosition::equal(DomPosition, DomPosition) -> Bool

    DomPosition::not_equal

    fn DomPosition::not_equal(x : DomPosition, y : DomPosition) -> Bool

    EditorScrollDimensions

    pub struct EditorScrollDimensions {
    width : Double
    content_width : Double
    scroll_width : Double
    height : Double
    content_height : Double
    scroll_height : Double
    } derive(Eq,
    Debug
    )

    Monaco EditorScrollDimensions (viewLayout.ts:19-71).

    EditorScrollDimensions::EditorScrollDimensions

    fn EditorScrollDimensions::EditorScrollDimensions(width : Double, content_width : Double, height : Double, content_height : Double) -> EditorScrollDimensions

    EditorScrollDimensions::equal

    EditorScrollDimensions::not_equal

    EditorScrollable

    type EditorScrollable

    Complete Monaco EditorScrollable (viewLayout.ts:73-154).

    EditorScrollable::EditorScrollable

    fn EditorScrollable::EditorScrollable(smooth_scroll_duration : Double, schedule_at_next_animation_frame : (() -> Unit) ->
    Disposable
    , now : () -> Double) -> EditorScrollable

    EditorScrollable::dimensions

    EditorScrollable::dispose

    fn EditorScrollable::dispose(self : EditorScrollable) -> Unit

    EditorScrollable::editor_dimensions

    EditorScrollable::future_position

    fn EditorScrollable::future_position(self : EditorScrollable) -> ScrollPosition

    EditorScrollable::get_scrollable

    fn EditorScrollable::get_scrollable(self : EditorScrollable) -> Scrollable

    EditorScrollable::has_pending_scroll_animation

    fn EditorScrollable::has_pending_scroll_animation(self : EditorScrollable) -> Bool

    EditorScrollable::on_did_content_size_change

    EditorScrollable::on_did_scroll

    EditorScrollable::position

    EditorScrollable::scroll_by

    fn EditorScrollable::scroll_by(self : EditorScrollable, delta_left? : Double, delta_top? : Double) -> ScrollChange?

    EditorScrollable::set_editor_dimensions

    fn EditorScrollable::set_editor_dimensions(self : EditorScrollable, dimensions : EditorScrollDimensions) -> ScrollChange?

    EditorScrollable::set_position_now

    fn EditorScrollable::set_position_now(self : EditorScrollable, update : ScrollPositionUpdate) -> ScrollChange?

    EditorScrollable::set_position_smooth

    fn EditorScrollable::set_position_smooth(self : EditorScrollable, update : ScrollPositionUpdate) -> Unit

    EditorScrollable::set_smooth_scroll_duration

    fn EditorScrollable::set_smooth_scroll_duration(self : EditorScrollable, duration : Double) -> Unit

    EditorScrollable::validate_scroll_position

    fn EditorScrollable::validate_scroll_position(self : EditorScrollable, update : ScrollPositionUpdate) -> ScrollPosition

    EditorWhitespace

    pub struct EditorWhitespace {
    id : String
    after_line_number : Int
    ordinal : Int
    height : Int
    min_width : Int
    prefix_sum : Double
    } derive(Eq,
    Debug
    )

    A whitespace (view zone) that displaces the lines after after_line_number.

    EditorWhitespace::EditorWhitespace

    fn EditorWhitespace::EditorWhitespace(id : String, after_line_number : Int, ordinal : Int, height : Int, min_width : Int) -> EditorWhitespace

    Constructs a whitespace; prefix_sum starts at 0 (lazily computed).

    EditorWhitespace::equal

    EditorWhitespace::not_equal

    fn EditorWhitespace::not_equal(x : EditorWhitespace, y : EditorWhitespace) -> Bool

    ForeignElementType

    pub(all) enum ForeignElementType {
    None
    Before
    After
    BeforeAndAfter
    } derive(Eq,
    Debug
    )

    Whether a rendered line contains pseudo-elements before or after text.

    ForeignElementType::equal

    ForeignElementType::not_equal

    InlineDecoration

    pub struct InlineDecoration {
    range :
    OffsetRange

    class_name : String
    decoration_type : InlineDecorationType
    } derive(Eq,
    Debug
    )

    Inline decoration over a line-local offset range.

    InlineDecoration::InlineDecoration

    fn InlineDecoration::InlineDecoration(range :
    OffsetRange
    , class_name : String, decoration_type? : InlineDecorationType) -> InlineDecoration

    Builds an inline decoration.

    InlineDecoration::equal

    InlineDecoration::not_equal

    fn InlineDecoration::not_equal(x : InlineDecoration, y : InlineDecoration) -> Bool

    InlineDecorationType

    pub(all) enum InlineDecorationType {
    Regular
    Before
    After
    RegularAffectingLetterSpacing
    } derive(Eq,
    Debug
    )

    Inline decoration placement relative to source text.

    InlineDecorationType::equal

    InlineDecorationType::not_equal

    LineDecoration

    pub struct LineDecoration {
    start_column : Int
    end_column : Int
    class_name : String
    decoration_type : InlineDecorationType
    } derive(Eq,
    Debug
    )

    One-based line decoration range plus CSS class.

    LineDecoration::LineDecoration

    fn LineDecoration::LineDecoration(start_column : Int, end_column : Int, class_name : String, decoration_type? : InlineDecorationType) -> LineDecoration

    Builds a line decoration.

    LineDecoration::compare

    fn LineDecoration::compare(left : LineDecoration, right : LineDecoration) -> Int

    Sort order used before decoration normalization.

    LineDecoration::equal

    LineDecoration::not_equal

    fn LineDecoration::not_equal(x : LineDecoration, y : LineDecoration) -> Bool

    LineDecorationsNormalizer

    pub struct LineDecorationsNormalizer {
    }

    Normalizes overlapping line decorations into contiguous CSS segments.

    LineDecorationsNormalizer::normalize

    fn LineDecorationsNormalizer::normalize(line_content : String, line_decorations : Array[LineDecoration]) -> Array[DecorationSegment]

    Converts sorted line decorations into renderer segments, preserving surrogate-pair boundaries.

    LinePart

    pub struct LinePart {
    end_index : Int
    class_name : String
    metadata : Int
    contains_rtl : Bool
    } derive(Eq,
    Debug
    )

    Tokenized segment ending at end_index with CSS and metadata flags.

    LinePart::LinePart

    fn LinePart::LinePart(end_index : Int, class_name : String, metadata? : Int, contains_rtl? : Bool) -> LinePart

    Builds a line part.

    LinePart::equal

    fn LinePart::equal(LinePart, LinePart) -> Bool

    LinePart::is_pseudo_after

    fn LinePart::is_pseudo_after(self : LinePart) -> Bool

    Whether this part is an after pseudo-element.

    LinePart::is_pseudo_before

    fn LinePart::is_pseudo_before(self : LinePart) -> Bool

    Whether this part is a before pseudo-element.

    LinePart::is_whitespace

    fn LinePart::is_whitespace(self : LinePart) -> Bool

    Whether this part represents visible whitespace.

    LinePart::not_equal

    fn LinePart::not_equal(x : LinePart, y : LinePart) -> Bool

    LinePart::to_repr

    LineWindow

    pub(all) struct LineWindow {
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A half-open range of 1-based view-line numbers the view should render: covers lines start ..< end in Monaco's view coordinate space.

    LineWindow::equal

    fn LineWindow::equal(LineWindow, LineWindow) -> Bool

    LineWindow::not_equal

    fn LineWindow::not_equal(x : LineWindow, y : LineWindow) -> Bool

    LinesLayout

    type LinesLayout

    Vertical line layout: lines (uniform default_line_height) and the whitespaces (view zones) that push them down.

    LinesLayout::LinesLayout

    fn LinesLayout::LinesLayout(line_count : Int, default_line_height : Int, padding_top : Int, padding_bottom : Int) -> LinesLayout

    Creates a lines layout. custom_line_height_data is accepted for shape parity with Monaco but ignored (uniform heights — see file deviation).

    LinesLayout::change_whitespace

    fn LinesLayout::change_whitespace(self : LinesLayout, callback : (WhitespaceChangeAccessor) -> Unit raise?) -> Bool raise?

    Run callback with a whitespace-change accessor, then commit the batch. Returns whether anything changed.

    LinesLayout::find_insertion_index

    fn LinesLayout::find_insertion_index(arr : Array[EditorWhitespace], after_line_number : Int, ordinal : Int) -> Int

    Find the insertion index for a new whitespace inside a sorted array. If the value is already present, the index is after the existing one.

    LinesLayout::get_after_line_number_for_whitespace_index

    fn LinesLayout::get_after_line_number_for_whitespace_index(self : LinesLayout, index : Int) -> Int

    The afterLineNumber of the whitespace at index.

    LinesLayout::get_first_whitespace_index_after_line_number

    fn LinesLayout::get_first_whitespace_index_after_line_number(self : LinesLayout, line_number : Int) -> Int

    Index of the first whitespace with afterLineNumber >= line_number, or -1 if there is none.

    LinesLayout::get_height_for_whitespace_index

    fn LinesLayout::get_height_for_whitespace_index(self : LinesLayout, index : Int) -> Int

    The height of the whitespace at index.

    LinesLayout::get_id_for_whitespace_index

    fn LinesLayout::get_id_for_whitespace_index(self : LinesLayout, index : Int) -> String

    The id of the whitespace at index.

    LinesLayout::get_line_height_for_line_number

    fn LinesLayout::get_line_height_for_line_number(self : LinesLayout, _line_number : Int) -> Int

    The (uniform) height of line_number.

    LinesLayout::get_line_number_at_or_after_vertical_offset

    fn LinesLayout::get_line_number_at_or_after_vertical_offset(self : LinesLayout, vertical_offset : Double) -> Int

    First line number at or after vertical offset vertical_offset.

    LinesLayout::get_lines_total_height

    fn LinesLayout::get_lines_total_height(self : LinesLayout) -> Double

    The sum of heights for all objects (lines + whitespaces + padding).

    LinesLayout::get_lines_viewport_data

    fn LinesLayout::get_lines_viewport_data(self : LinesLayout, vertical_offset1 : Double, vertical_offset2 : Double) -> PartialViewLinesViewportData

    All lines (and their relative vertical offsets) positioned between vertical_offset1 and vertical_offset2.

    LinesLayout::get_vertical_offset_after_line_number

    fn LinesLayout::get_vertical_offset_after_line_number(self : LinesLayout, line_number : Int, include_view_zones? : Bool) -> Double

    Vertical offset including line_number's own height.

    LinesLayout::get_vertical_offset_for_line_number

    fn LinesLayout::get_vertical_offset_for_line_number(self : LinesLayout, line_number : Int, include_view_zones? : Bool) -> Double

    Vertical offset (sum of heights of everything above) of line_number.

    LinesLayout::get_vertical_offset_for_whitespace_index

    fn LinesLayout::get_vertical_offset_for_whitespace_index(self : LinesLayout, whitespace_index : Int) -> Double

    Vertical offset of the whitespace at whitespace_index.

    LinesLayout::get_whitespace_accumulated_height_before_line_number

    fn LinesLayout::get_whitespace_accumulated_height_before_line_number(self : LinesLayout, line_number : Int) -> Double

    Accumulated height of whitespaces strictly before line_number.

    LinesLayout::get_whitespace_at_vertical_offset

    fn LinesLayout::get_whitespace_at_vertical_offset(self : LinesLayout, vertical_offset : Double) -> ViewWhitespaceViewportData?

    Exactly the whitespace layouted at vertical_offset, or None.

    LinesLayout::get_whitespace_index_at_or_after_vertical_offset

    fn LinesLayout::get_whitespace_index_at_or_after_vertical_offset(self : LinesLayout, vertical_offset : Double) -> Int

    Index of the first whitespace at or after vertical offset vertical_offset, or -1 if there is none.

    LinesLayout::get_whitespace_min_width

    fn LinesLayout::get_whitespace_min_width(self : LinesLayout) -> Int

    The maximum min width over all whitespaces.

    LinesLayout::get_whitespace_viewport_data

    fn LinesLayout::get_whitespace_viewport_data(self : LinesLayout, vertical_offset1 : Double, vertical_offset2 : Double) -> Array[ViewWhitespaceViewportData]

    All whitespaces positioned between vertical_offset1 and vertical_offset2.

    LinesLayout::get_whitespaces

    fn LinesLayout::get_whitespaces(self : LinesLayout) -> Array[EditorWhitespace]

    All whitespaces (a copy).

    LinesLayout::get_whitespaces_accumulated_height

    fn LinesLayout::get_whitespaces_accumulated_height(self : LinesLayout, index : Int) -> Double

    Sum of the heights of whitespaces in [0..index] (inclusive of index).

    LinesLayout::get_whitespaces_count

    fn LinesLayout::get_whitespaces_count(self : LinesLayout) -> Int

    The number of whitespaces.

    LinesLayout::get_whitespaces_total_height

    fn LinesLayout::get_whitespaces_total_height(self : LinesLayout) -> Double

    The sum of all whitespace heights.

    LinesLayout::has_whitespace

    fn LinesLayout::has_whitespace(self : LinesLayout) -> Bool

    Whether there is any whitespace in the document.

    LinesLayout::is_after_lines

    fn LinesLayout::is_after_lines(self : LinesLayout, vertical_offset : Double) -> Bool

    Whether vertical_offset is below all lines.

    LinesLayout::is_in_bottom_padding

    fn LinesLayout::is_in_bottom_padding(self : LinesLayout, vertical_offset : Double) -> Bool

    Whether vertical_offset falls in the bottom padding.

    LinesLayout::is_in_top_padding

    fn LinesLayout::is_in_top_padding(self : LinesLayout, vertical_offset : Double) -> Bool

    Whether vertical_offset falls in the top padding.

    LinesLayout::on_flushed

    fn LinesLayout::on_flushed(self : LinesLayout, line_count : Int) -> Unit

    Set the number of lines (Monaco's onFlushed).

    LinesLayout::on_lines_deleted

    fn LinesLayout::on_lines_deleted(self : LinesLayout, from_line_number : Int, to_line_number : Int) -> Unit

    Notify that a continuous zone of lines was deleted (inclusive bounds).

    LinesLayout::on_lines_inserted

    fn LinesLayout::on_lines_inserted(self : LinesLayout, from_line_number : Int, to_line_number : Int) -> Unit

    Notify that a continuous zone of lines was inserted (inclusive bounds).

    LinesLayout::set_default_line_height

    fn LinesLayout::set_default_line_height(self : LinesLayout, line_height : Int) -> Unit

    Change the uniform line height in pixels.

    LinesLayout::set_padding

    fn LinesLayout::set_padding(self : LinesLayout, padding_top : Int, padding_bottom : Int) -> Unit

    Changes the padding used to calculate vertical offsets.

    PartialViewLinesViewportData

    pub struct PartialViewLinesViewportData {
    big_numbers_delta : Int
    start_line_number : Int
    end_line_number : Int
    relative_vertical_offset : Array[Double]
    centered_line_number : Int
    completely_visible_start_line_number : Int
    completely_visible_end_line_number : Int
    line_height : Int
    } derive(Eq,
    Debug
    )

    Lines and relative offsets positioned between two vertical offsets — the Monaco IPartialViewLinesViewportData shape.

    PartialViewLinesViewportData::not_equal

    PrefixSumComputer

    pub struct PrefixSumComputer {
    values : Array[Int]
    prefix_sum : Array[Int]
    prefix_sum_valid_index : Int
    }

    Incrementally-cached prefix-sum computer over a mutable array of values. get_index_of is O(log n); mutations invalidate only the affected suffix of the cached prefix sums.

    PrefixSumComputer::PrefixSumComputer

    fn PrefixSumComputer::PrefixSumComputer(values : ArrayView[Int]) -> PrefixSumComputer

    PrefixSumComputer::get_count

    fn PrefixSumComputer::get_count(self : PrefixSumComputer) -> Int

    PrefixSumComputer::get_index_of

    fn PrefixSumComputer::get_index_of(self : PrefixSumComputer, sum : Int) -> PrefixSumIndexOfResult

    PrefixSumComputer::get_prefix_sum

    fn PrefixSumComputer::get_prefix_sum(self : PrefixSumComputer, index : Int) -> Int

    Returns the sum of the first index + 1 many items, i.e. SUM(0 <= j <= index, values[j]). A negative index yields 0.

    PrefixSumComputer::get_total_sum

    fn PrefixSumComputer::get_total_sum(self : PrefixSumComputer) -> Int

    PrefixSumComputer::insert_values

    fn PrefixSumComputer::insert_values(self : PrefixSumComputer, insert_index : Int, insert_values : Array[Int]) -> Bool

    PrefixSumComputer::remove_values

    fn PrefixSumComputer::remove_values(self : PrefixSumComputer, start_index : Int, count : Int) -> Bool

    PrefixSumComputer::set_value

    fn PrefixSumComputer::set_value(self : PrefixSumComputer, index : Int, value : Int) -> Bool

    PrefixSumIndexOfResult

    pub(all) struct PrefixSumIndexOfResult {
    index : Int
    remainder : Int
    } derive(Eq,
    Debug
    )

    Result of PrefixSumComputer::get_index_of: the index whose range contains the queried sum, plus the remainder into that index.

    PrefixSumIndexOfResult::equal

    PrefixSumIndexOfResult::not_equal

    RenderLineInput

    pub struct RenderLineInput {
    use_monospace_optimizations : Bool
    can_use_halfwidth_rightwards_arrow : Bool
    line_content : String
    continues_with_wrapped_line : Bool
    is_basic_ascii : Bool
    contains_rtl : Bool
    faux_indent_length : Int
    line_tokens : Array[LinePart]
    line_decorations : Array[LineDecoration]
    tab_size : Int
    start_visible_column : Int
    space_width : Double
    render_space_width : Double
    render_space_char_code : Int
    stop_rendering_line_after : Int
    render_whitespace :
    RenderWhitespace

    render_control_characters : Bool
    font_ligatures : Bool
    selections_on_line : Array[
    OffsetRange
    ]
    text_direction : TextDirection
    vertical_scrollbar_size : Double
    render_new_line_when_empty : Bool
    } derive(Eq,
    Debug
    )

    Fully normalized input for rendering one view line to HTML.

    RenderLineInput::equal

    RenderLineInput::from_view_line

    fn RenderLineInput::from_view_line(data : ViewLineRenderingData, line_decorations? : Array[LineDecoration], use_monospace_optimizations? : Bool, can_use_halfwidth_rightwards_arrow? : Bool, faux_indent_length? : Int, space_width? : Double, middot_width? : Double, wsmiddot_width? : Double, stop_rendering_line_after? : Int, render_whitespace? :
    RenderWhitespace
    , render_control_characters? : Bool, font_ligatures? : Bool, selections_on_line? : Array[
    OffsetRange
    ], vertical_scrollbar_size? : Double, render_new_line_when_empty? : Bool) -> RenderLineInput

    Builds line-renderer input from viewport line data plus runtime rendering options.

    RenderLineInput::not_equal

    fn RenderLineInput::not_equal(x : RenderLineInput, y : RenderLineInput) -> Bool

    RenderLineOutput

    pub struct RenderLineOutput {
    character_mapping : CharacterMapping
    contains_foreign_elements : ForeignElementType
    } derive(Eq,
    Debug
    )

    Render output when the caller owns the output builder.

    RenderLineOutput::equal

    RenderLineOutput::not_equal

    fn RenderLineOutput::not_equal(x : RenderLineOutput, y : RenderLineOutput) -> Bool

    RenderLineOutput2

    pub struct RenderLineOutput2 {
    html : String
    character_mapping : CharacterMapping
    contains_foreign_elements : ForeignElementType
    } derive(Eq,
    Debug
    )

    Render output including generated HTML.

    RenderLineOutput2::equal

    RenderLineOutput2::not_equal

    fn RenderLineOutput2::not_equal(x : RenderLineOutput2, y : RenderLineOutput2) -> Bool

    SavedScrollState

    pub struct SavedScrollState {
    scroll_top : Double
    scroll_top_without_view_zones : Double
    scroll_left : Double
    } derive(Eq,
    Debug
    )

    SavedScrollState::equal

    SavedScrollState::not_equal

    fn SavedScrollState::not_equal(x : SavedScrollState, y : SavedScrollState) -> Bool

    ScrollChange

    pub(all) struct ScrollChange {
    position : ScrollPosition
    delta_left : Double
    delta_top : Double
    left_changed : Bool
    top_changed : Bool
    dimensions_changed : Bool
    in_smooth_scrolling : Bool
    old_width : Double
    old_scroll_width : Double
    old_scroll_left : Double
    width : Double
    scroll_width : Double
    scroll_left : Double
    old_height : Double
    old_scroll_height : Double
    old_scroll_top : Double
    height : Double
    scroll_height : Double
    scroll_top : Double
    width_changed : Bool
    scroll_width_changed : Bool
    scroll_left_changed : Bool
    height_changed : Bool
    scroll_height_changed : Bool
    scroll_top_changed : Bool
    } derive(Eq,
    Debug
    )

    Monaco ScrollEvent plus the compatibility facts existing viewer callers consume. Old/new geometry and all six change flags are exact source data.

    ScrollChange::equal

    ScrollChange::not_equal

    fn ScrollChange::not_equal(x : ScrollChange, y : ScrollChange) -> Bool

    ScrollDimensions

    pub(all) struct ScrollDimensions {
    width : Double
    scroll_width : Double
    height : Double
    scroll_height : Double
    } derive(Eq,
    Debug
    )

    ScrollDimensions::equal

    ScrollDimensions::not_equal

    fn ScrollDimensions::not_equal(x : ScrollDimensions, y : ScrollDimensions) -> Bool

    ScrollDimensionsUpdate

    pub(all) struct ScrollDimensionsUpdate {
    width : Double?
    scroll_width : Double?
    height : Double?
    scroll_height : Double?
    } derive(Eq,
    Debug
    )

    ScrollDimensionsUpdate::equal

    ScrollDimensionsUpdate::not_equal

    ScrollPosition

    pub(all) struct ScrollPosition {
    scroll_left : Double
    scroll_top : Double
    } derive(Eq,
    Debug
    )

    ScrollPosition::equal

    ScrollPosition::not_equal

    fn ScrollPosition::not_equal(x : ScrollPosition, y : ScrollPosition) -> Bool

    ScrollPositionUpdate

    pub(all) struct ScrollPositionUpdate {
    scroll_left : Double?
    scroll_top : Double?
    } derive(Eq,
    Debug
    )

    ScrollPositionUpdate::equal

    ScrollPositionUpdate::not_equal

    ScrollState

    pub struct ScrollState {
    force_integer_values : Bool
    raw_scroll_left : Double
    raw_scroll_top : Double
    width : Double
    scroll_width : Double
    scroll_left : Double
    height : Double
    scroll_height : Double
    scroll_top : Double
    } derive(Eq,
    Debug
    )

    Complete Monaco ScrollState (scrollable.ts:43-179). Raw positions are retained before validation so a later dimension expansion can recover a position that was temporarily clamped.

    ScrollState::ScrollState

    fn ScrollState::ScrollState(force_integer_values~ : Bool, width : Double, scroll_width : Double, scroll_left : Double, height : Double, scroll_height : Double, scroll_top : Double) -> ScrollState

    ScrollState::create_scroll_event

    fn ScrollState::create_scroll_event(self : ScrollState, previous : ScrollState, in_smooth_scrolling : Bool) -> ScrollChange

    ScrollState::equal

    fn ScrollState::equal(ScrollState, ScrollState) -> Bool

    ScrollState::equals

    fn ScrollState::equals(self : ScrollState, other : ScrollState) -> Bool

    ScrollState::not_equal

    fn ScrollState::not_equal(x : ScrollState, y : ScrollState) -> Bool

    ScrollState::with_scroll_dimensions

    fn ScrollState::with_scroll_dimensions(self : ScrollState, update : ScrollDimensionsUpdate, use_raw_scroll_positions : Bool) -> ScrollState

    ScrollState::with_scroll_position

    fn ScrollState::with_scroll_position(self : ScrollState, update : ScrollPositionUpdate) -> ScrollState

    Scrollable

    type Scrollable

    Complete Monaco Scrollable state machine (scrollable.ts:225-395). The scheduler and clock are injected so this package remains DOM/FFI-free.

    Scrollable::Scrollable

    fn Scrollable::Scrollable(force_integer_values~ : Bool, smooth_scroll_duration? : Double, schedule_at_next_animation_frame? : (() -> Unit) ->
    Disposable
    , now? : () -> Double) -> Scrollable

    Scrollable::dimensions

    fn Scrollable::dimensions(self : Scrollable) -> ScrollDimensions

    Scrollable::dispose

    fn Scrollable::dispose(self : Scrollable) -> Unit

    Scrollable::future_position

    fn Scrollable::future_position(self : Scrollable) -> ScrollPosition

    Scrollable::has_pending_scroll_animation

    fn Scrollable::has_pending_scroll_animation(self : Scrollable) -> Bool

    Scrollable::on_scroll

    Scrollable::position

    fn Scrollable::position(self : Scrollable) -> ScrollPosition

    Scrollable::scroll_by

    fn Scrollable::scroll_by(self : Scrollable, delta_left? : Double, delta_top? : Double) -> ScrollChange?

    Scrollable::set_dimensions

    fn Scrollable::set_dimensions(self : Scrollable, dimensions : ScrollDimensions) -> ScrollChange?

    Scrollable::set_position

    fn Scrollable::set_position(self : Scrollable, position : ScrollPosition) -> ScrollChange?

    Scrollable::set_position_now

    fn Scrollable::set_position_now(self : Scrollable, update : ScrollPositionUpdate) -> ScrollChange?

    Scrollable::set_position_smooth

    fn Scrollable::set_position_smooth(self : Scrollable, update : ScrollPositionUpdate, reuse_animation? : Bool) -> Unit

    Scrollable::set_scroll_dimensions

    fn Scrollable::set_scroll_dimensions(self : Scrollable, update : ScrollDimensionsUpdate, use_raw_scroll_positions : Bool) -> ScrollChange?

    Scrollable::set_smooth_scroll_duration

    fn Scrollable::set_smooth_scroll_duration(self : Scrollable, duration : Double) -> Unit

    Scrollable::validate_scroll_position

    fn Scrollable::validate_scroll_position(self : Scrollable, update : ScrollPositionUpdate) -> ScrollPosition

    ScrollbarState

    type ScrollbarState

    Custom-scrollbar geometry, the Monaco ScrollbarState role: pure arithmetic between scroll state and slider (thumb) geometry along one axis. For the vertical bar the "size" axis is height and the slider moves with scroll_top; for the horizontal bar substitute width and scroll_left. Pixel inputs round to whole CSS pixels like the reference.

    ScrollbarState::ScrollbarState

    fn ScrollbarState::ScrollbarState(arrow_size? : Double, scrollbar_size~ : Double, opposite_scrollbar_size? : Double) -> ScrollbarState

    Creates scrollbar geometry state for one axis.

    ScrollbarState::clone

    Field-for-field geometry snapshot used by pointer gestures. Monaco's AbstractScrollbar._sliderPointerDown clones its state before monitoring so later layout mutations cannot change the drag mapping.

    ScrollbarState::desired_position_from_delta

    fn ScrollbarState::desired_position_from_delta(self : ScrollbarState, delta : Double) -> Double

    The scroll position that moves the slider by delta track pixels: wheel-style relative moves.

    ScrollbarState::desired_position_from_offset

    fn ScrollbarState::desired_position_from_offset(self : ScrollbarState, offset : Double) -> Double

    The scroll position that centers the slider on a track offset: track page jumps that land the thumb under the mouse.

    ScrollbarState::desired_position_from_offset_paged

    fn ScrollbarState::desired_position_from_offset_paged(self : ScrollbarState, offset : Double) -> Double

    The scroll position one page up or down from the current one, depending on whether the track offset is before or after the slider.

    ScrollbarState::desired_position_from_slider

    fn ScrollbarState::desired_position_from_slider(self : ScrollbarState, slider_position : Double) -> Double

    The scroll position that puts the slider at an absolute track position: thumb drags track the slider position captured at drag start plus the pointer travel, like the reference.

    ScrollbarState::is_needed

    fn ScrollbarState::is_needed(self : ScrollbarState) -> Bool

    Whether the content overflows the viewport on this axis.

    ScrollbarState::rectangle_large_size

    fn ScrollbarState::rectangle_large_size(self : ScrollbarState) -> Double

    The track length: the viewport minus the paired scrollbar's thickness.

    ScrollbarState::rectangle_small_size

    fn ScrollbarState::rectangle_small_size(self : ScrollbarState) -> Double

    The scrollbar's thickness.

    ScrollbarState::scroll_position

    fn ScrollbarState::scroll_position(self : ScrollbarState) -> Double

    Current scroll position along this axis.

    ScrollbarState::set_scroll_position

    fn ScrollbarState::set_scroll_position(self : ScrollbarState, scroll_position : Double) -> Bool

    Sets the scroll position along this axis. Answers whether geometry changed.

    ScrollbarState::set_scroll_size

    fn ScrollbarState::set_scroll_size(self : ScrollbarState, scroll_size : Double) -> Bool

    The content extent along this scrollbar's axis.

    ScrollbarState::set_visible_size

    fn ScrollbarState::set_visible_size(self : ScrollbarState, visible_size : Double) -> Bool

    The viewport extent along this scrollbar's axis. Answers whether the geometry changed.

    ScrollbarState::slider_position

    fn ScrollbarState::slider_position(self : ScrollbarState) -> Double

    Computed slider offset inside the track.

    ScrollbarState::slider_size

    fn ScrollbarState::slider_size(self : ScrollbarState) -> Double

    Computed slider length in CSS pixels.

    SmoothScrollPosition

    pub(all) struct SmoothScrollPosition {
    scroll_left : Double
    scroll_top : Double
    width : Double
    height : Double
    } derive(Eq,
    Debug
    )

    SmoothScrollPosition::equal

    SmoothScrollPosition::not_equal

    SmoothScrollingOperation

    pub struct SmoothScrollingOperation {
    from : SmoothScrollPosition
    to : SmoothScrollPosition
    duration : Double
    start_time : Double
    animation_frame_disposable :
    Disposable
    ?
    scroll_left_animation : (Double) -> Double
    scroll_top_animation : (Double) -> Double
    }

    Monaco SmoothScrollingOperation (scrollable.ts:431-514).

    SmoothScrollingOperation::SmoothScrollingOperation

    fn SmoothScrollingOperation::SmoothScrollingOperation(from : SmoothScrollPosition, to : SmoothScrollPosition, start_time : Double, duration : Double) -> SmoothScrollingOperation

    SmoothScrollingOperation::accept_scroll_dimensions

    fn SmoothScrollingOperation::accept_scroll_dimensions(self : SmoothScrollingOperation, state : ScrollState) -> Unit

    SmoothScrollingOperation::combine

    SmoothScrollingOperation::dispose

    SmoothScrollingOperation::start

    fn SmoothScrollingOperation::start(from : SmoothScrollPosition, to : SmoothScrollPosition, duration : Double, now : Double) -> SmoothScrollingOperation

    SmoothScrollingOperation::tick_at

    SmoothScrollingUpdate

    pub struct SmoothScrollingUpdate {
    scroll_left : Double
    scroll_top : Double
    is_done : Bool
    } derive(Eq,
    Debug
    )

    SmoothScrollingUpdate::SmoothScrollingUpdate

    fn SmoothScrollingUpdate::SmoothScrollingUpdate(scroll_left : Double, scroll_top : Double, is_done : Bool) -> SmoothScrollingUpdate

    SmoothScrollingUpdate::equal

    SmoothScrollingUpdate::not_equal

    TextDirection

    pub(all) enum TextDirection {
    LTR
    RTL
    } derive(Eq,
    Debug
    )

    Direction metadata for a rendered line.

    TextDirection::equal

    TextDirection::not_equal

    fn TextDirection::not_equal(x : TextDirection, y : TextDirection) -> Bool

    VerticalRevealType

    pub(all) enum VerticalRevealType {
    Simple
    Center
    CenterIfOutsideViewport
    NearTop
    NearTopIfOutsideViewport
    Top
    Bottom
    } derive(Eq,
    Debug
    )

    Monaco's VerticalRevealType (vs/editor/common/viewEvents.ts): how a reveal aligns the target range inside the viewport.

    VerticalRevealType::equal

    VerticalRevealType::not_equal

    ViewLayout

    pub struct ViewLayout {
    scrollable : EditorScrollable
    // private fields
    }

    The Monaco ViewLayout role: combines the scroll truth (Scrollable) with the line layout (LinesLayout) and derives the render viewport from them via get_lines_viewport_data. Pure model state — input capture and DOM application stay backend-side.

    Like Monaco, the entire view layer is 1-based, so ViewLayout and the LinesLayout it holds share one coordinate space — line-number arguments pass straight through with no translation. View-zone whitespace carries Monaco's afterLineNumber directly. The LinesLayout held here is exactly the type the conformance suite validates.

    ViewLayout::ViewLayout

    fn ViewLayout::ViewLayout(line_height~ : Int, line_count? : Int, smooth_scrolling? : Bool, is_viewport_wrapping? : Bool, vertical_scrollbar_width? : Double, horizontal_scrollbar_height? : Double, schedule_at_next_animation_frame? : (() -> Unit) ->
    Disposable
    , now? : () -> Double) -> ViewLayout

    Creates a view layout with a fixed line height and optional line count.

    ViewLayout::big_numbers_delta_for_window

    fn ViewLayout::big_numbers_delta_for_window(self : ViewLayout, window : LineWindow) -> Int

    Monaco LinesLayout.getLinesViewportData's large-number rail origin. The second alignment keeps the delta divisible by the default line height.

    ViewLayout::change_whitespace

    fn ViewLayout::change_whitespace(self : ViewLayout, callback : (WhitespaceChangeAccessor) -> Unit raise?) -> Bool raise?

    Runs one source-shaped incremental whitespace transaction. A changed batch updates the vertical extent before returning; empty batches return false. The callback effect is polymorphic, so ordinary callers remain non-raising while a raised callback still receives LinesLayout's finally commit.

    ViewLayout::completely_visible_line_range

    fn ViewLayout::completely_visible_line_range(self : ViewLayout) -> (Int, Int)

    The 1-based view line range fully on screen at the current scroll, Monaco's ViewLayout.getLinesViewportData().completelyVisible{Start,End}LineNumber. Returns (1, 1) for an empty document so callers never index a missing line.

    ViewLayout::compute_scroll_left_to_reveal

    fn ViewLayout::compute_scroll_left_to_reveal(self : ViewLayout, ranges : Array[(Double, Double)], vertical_scrollbar_width~ : Double, minimal_reveal? : Bool) -> Double?

    The minimal scroll_left that brings a horizontal box into view, the pure half of Monaco's ViewLines._computeScrollLeftToReveal (viewLines.ts:784). The DOM measurement (measure_line_selection) lives on Viewer; ranges are its (left, width) client rects in content coordinates (0 = line start). Returns None when there is nothing to measure (the line is not rendered, or the range collapsed to a zero-width caret the measurement helper drops).

    vertical_scrollbar_width is passed in because the scrollbar geometry is a rendering concern owned by Viewer, not by the pure layout core.

    ViewLayout::compute_scroll_top_to_reveal_range

    fn ViewLayout::compute_scroll_top_to_reveal_range(self : ViewLayout, start_line : Int, end_line : Int, vertical_type : VerticalRevealType, source? : String, minimal_reveal? : Bool) -> Double

    The minimal scroll_top that brings the 1-based view-line range [start_line, end_line] into the viewport, aligned per vertical_type. A 1:1 port of Monaco's ViewLines._computeScrollTopToRevealRange (vs/editor/browser/viewParts/viewLines/viewLines.ts:693).

    Pure model state: works entirely in view coordinates, so it stays moon test-able without a browser. Model→view conversion happens at the Viewer boundary before this is called (with word-wrap on, model line ≠ view line).

    Scope cuts vs. Monaco (all confirmed absent in the viewer):
    • No cursorSurroundingLines / sticky-scroll scroll-off padding, so paddingTop = paddingBottom = 0 (viewLines.ts:720–:736). Only the behavioral +1 line bottom pad for Simple / Bottom survives (:737–:742) only when minimal_reveal=false. Mouse-source regular reveals add the source's one-line top pad; minimal cursor reveals add no top/bottom padding.
    • No multi-selection. The box is always a single range, so an oversized box reveals its top (Monaco's single-range branch, :754) instead of returning the -1 abort sentinel — that sentinel is reserved for the oversized multi-cursor case the viewer never exposes. This port therefore does not produce -1.0; Viewer::send_reveal_range still guards on it defensively.

    The returned value is unclamped (it may be negative, e.g. a NearTop reveal near the document top); Scrollable::set_position clamps it into the valid scroll range, mirroring Monaco's validateScrollPosition step.

    ViewLayout::delta_scroll_now

    fn ViewLayout::delta_scroll_now(self : ViewLayout, delta_scroll_left : Double, delta_scroll_top : Double) -> Unit

    ViewLayout::dimensions

    fn ViewLayout::dimensions(self : ViewLayout) -> ScrollDimensions

    Current viewport and content dimensions.

    ViewLayout::dispose

    fn ViewLayout::dispose(self : ViewLayout) -> Unit

    ViewLayout::future_position

    fn ViewLayout::future_position(self : ViewLayout) -> ScrollPosition

    ViewLayout::get_content_height

    fn ViewLayout::get_content_height(self : ViewLayout) -> Double

    Total retained content height, including view zones and the fixed product horizontal scrollbar when horizontal overflow is present.

    ViewLayout::get_content_width

    fn ViewLayout::get_content_width(self : ViewLayout) -> Double

    The derived horizontal content extent (measured maximum plus the applicable fixed layout additions), Monaco's ViewLayout.getContentWidth / scroll-dimensions contentWidth. Read by CodeEditorWidget.getContentWidth.

    ViewLayout::get_current_scroll_left

    fn ViewLayout::get_current_scroll_left(self : ViewLayout) -> Double

    Current horizontal scroll offset, Monaco's ViewLayout.getCurrentScrollLeft.

    ViewLayout::get_current_scroll_top

    fn ViewLayout::get_current_scroll_top(self : ViewLayout) -> Double

    Current vertical scroll offset, Monaco's ViewLayout.getCurrentScrollTop.

    ViewLayout::get_current_viewport

    fn ViewLayout::get_current_viewport(self : ViewLayout) -> Viewport

    ViewLayout::get_future_viewport

    fn ViewLayout::get_future_viewport(self : ViewLayout) -> Viewport

    ViewLayout::get_line_height_for_line_number

    fn ViewLayout::get_line_height_for_line_number(self : ViewLayout, line_number : Int) -> Int

    The (uniform) height of a 1-based view line, Monaco's ViewLayout.getLineHeightForLineNumber.

    ViewLayout::get_lines_viewport_data

    fn ViewLayout::get_lines_viewport_data(self : ViewLayout) -> PartialViewLinesViewportData

    All lines (and their relative vertical offsets) inside the current viewport, Monaco's ViewLayout.getLinesViewportData (delegates to LinesLayout with the viewport [scrollTop, scrollTop + height]).

    ViewLayout::get_lines_viewport_data_at_scroll_top

    fn ViewLayout::get_lines_viewport_data_at_scroll_top(self : ViewLayout, scroll_top : Double) -> PartialViewLinesViewportData

    Monaco getLinesViewportDataAtScrollTop: minimally clamps an explicit scroll top against the current scroll dimensions, then derives the same line viewport without mutating scroll state.

    ViewLayout::get_scroll_height

    fn ViewLayout::get_scroll_height(self : ViewLayout) -> Double

    Scrollable content height = max(viewport height, content height), Monaco's ViewLayout.getScrollHeight.

    ViewLayout::get_scroll_width

    fn ViewLayout::get_scroll_width(self : ViewLayout) -> Double

    Scrollable content width = max(viewport width, content width), Monaco's ViewLayout.getScrollWidth. Backed by sync_dimensions' scroll_width.

    ViewLayout::get_scrollable

    fn ViewLayout::get_scrollable(self : ViewLayout) -> Scrollable

    ViewLayout::get_vertical_offset_after_line_number

    fn ViewLayout::get_vertical_offset_after_line_number(self : ViewLayout, line_number : Int, include_view_zones? : Bool) -> Double

    Content-space bottom of a 1-based view line (its top plus its height), Monaco's ViewLayout.getVerticalOffsetAfterLineNumber.

    ViewLayout::get_vertical_offset_for_line_number

    fn ViewLayout::get_vertical_offset_for_line_number(self : ViewLayout, line_number : Int, include_view_zones? : Bool) -> Double

    Content-space top of a 1-based view line, Monaco's ViewLayout.getVerticalOffsetForLineNumber (delegates straight to LinesLayout). include_view_zones controls whether the whitespace immediately above the line counts toward the offset.

    ViewLayout::get_whitespace_at_vertical_offset

    fn ViewLayout::get_whitespace_at_vertical_offset(self : ViewLayout, vertical_offset : Double) -> ViewWhitespaceViewportData?

    Monaco IViewLayout.getWhitespaceAtVerticalOffset (viewLayout.ts): the whitespace (view zone) whose band contains a content-space vertical offset, forwarded to LinesLayout.

    ViewLayout::get_whitespace_viewport_data

    fn ViewLayout::get_whitespace_viewport_data(self : ViewLayout) -> Array[ViewWhitespaceViewportData]

    All ID-bearing whitespaces in the current viewport. The result uses content-space vertical offsets and the source half-open viewport end.

    ViewLayout::get_whitespaces

    fn ViewLayout::get_whitespaces(self : ViewLayout) -> Array[EditorWhitespace]

    A shallow array snapshot of every whitespace. The returned array is independent while its EditorWhitespace elements retain source identity.

    ViewLayout::has_pending_scroll_animation

    fn ViewLayout::has_pending_scroll_animation(self : ViewLayout) -> Bool

    ViewLayout::is_after_lines

    fn ViewLayout::is_after_lines(self : ViewLayout, vertical_offset : Double) -> Bool

    Monaco IViewLayout.isAfterLines: whether a content-space vertical offset sits below every line (and every trailing view zone), forwarded to LinesLayout.

    ViewLayout::is_in_bottom_padding

    fn ViewLayout::is_in_bottom_padding(self : ViewLayout, vertical_offset : Double) -> Bool

    Monaco IViewLayout.isInBottomPadding, forwarded to LinesLayout.

    ViewLayout::is_in_top_padding

    fn ViewLayout::is_in_top_padding(self : ViewLayout, vertical_offset : Double) -> Bool

    Monaco IViewLayout.isInTopPadding, forwarded to LinesLayout (the viewer carries no padding options, so its paddings are 0).

    ViewLayout::line_at_vertical_offset

    fn ViewLayout::line_at_vertical_offset(self : ViewLayout, offset : Double) -> Int

    The 1-based line whose band contains a content-space vertical offset, clamped to the document (1 for an empty one).

    ViewLayout::line_count

    fn ViewLayout::line_count(self : ViewLayout) -> Int

    Current number of lines.

    ViewLayout::line_height

    fn ViewLayout::line_height(self : ViewLayout) -> Int

    The uniform line height in pixels (fontInfo.lineHeight).

    ViewLayout::on_did_content_size_change

    fn ViewLayout::on_did_content_size_change(self : ViewLayout, listener : (ContentSizeChange) -> Unit) ->
    Disposable

    ViewLayout::on_did_scroll

    ViewLayout::on_flushed

    fn ViewLayout::on_flushed(self : ViewLayout, line_count : Int) -> Unit

    The document was replaced — Monaco's ViewLayout.onFlushed(lineCount): this._linesLayout.onFlushed(lineCount). Whitespaces (view zones) survive a flush like the source's; the browser ViewZones owner recomputes mutable mapping facts on its corresponding view-model event. The scroll dimensions re-derive in on_height_maybe_changed, exactly the source split.

    ViewLayout::on_height_maybe_changed

    fn ViewLayout::on_height_maybe_changed(self : ViewLayout) -> ScrollChange?

    Re-derives the scroll dimensions after the content height may have changed — Monaco's ViewLayout.onHeightMaybeChanged (_updateHeight); a shrunken document clamps the scroll position here.

    ViewLayout::position

    fn ViewLayout::position(self : ViewLayout) -> ScrollPosition

    Current synthetic scroll position.

    ViewLayout::relative_vertical_offset_for_line

    fn ViewLayout::relative_vertical_offset_for_line(self : ViewLayout, window : LineWindow, line : Int) -> Double

    Top offset of 1-based line relative to Monaco's bigNumbersDelta for the rendered window (linesLayout.ts:738-750). Below 500000px this is the absolute content offset; above it the large aligned delta is subtracted.

    ViewLayout::save_state

    fn ViewLayout::save_state(self : ViewLayout) -> SavedScrollState

    ViewLayout::scroll_by

    fn ViewLayout::scroll_by(self : ViewLayout, delta_left? : Double, delta_top? : Double) -> ScrollChange?

    Applies a relative synthetic scroll delta.

    ViewLayout::scroll_to

    fn ViewLayout::scroll_to(self : ViewLayout, scroll_top~ : Double, scroll_left? : Double) -> ScrollChange?

    Sets the synthetic scroll position, preserving horizontal position unless scroll_left is supplied.

    ViewLayout::scroll_to_smooth

    fn ViewLayout::scroll_to_smooth(self : ViewLayout, scroll_top~ : Double, scroll_left? : Double) -> Unit

    ViewLayout::set_content_width

    fn ViewLayout::set_content_width(self : ViewLayout, max_line_width : Double) -> ScrollChange?

    Compatibility spelling for callers that predate ViewLayout's ownership of the measured maximum. The value is a max-line-width input, not a final content width; new ViewLines wiring should call set_max_line_width.

    ViewLayout::set_is_viewport_wrapping

    fn ViewLayout::set_is_viewport_wrapping(self : ViewLayout, is_viewport_wrapping : Bool) -> ScrollChange?

    Updates the retained viewport-wrapping fact consumed by content-width computation. The local configuration path is split across typed setters; Monaco reads the same fact from EditorOption.wrappingInfo.

    ViewLayout::set_line_count

    fn ViewLayout::set_line_count(self : ViewLayout, line_count : Int) -> ScrollChange?

    Replaces the document extent (line count) and re-derives the scroll dimensions; the position re-clamps when the document shrank.

    ViewLayout::set_line_height

    fn ViewLayout::set_line_height(self : ViewLayout, line_height : Int) -> ScrollChange?

    Applies a changed line height and re-derives the scroll dimensions — Monaco's ViewLayout.onConfigurationChanged lineHeight branch (this._linesLayout.setLineHeight(...)).

    ViewLayout::set_max_line_width

    fn ViewLayout::set_max_line_width(self : ViewLayout, max_line_width : Double) -> ScrollChange?

    Monaco ViewLayout.setMaxLineWidth: retain the measured widest rendered line without clamping, update content width, then recompute height because horizontal-scrollbar visibility contributes to the bottom extent.

    ViewLayout::set_smooth_scrolling

    fn ViewLayout::set_smooth_scrolling(self : ViewLayout, enabled : Bool) -> Unit

    ViewLayout::set_viewport_size

    fn ViewLayout::set_viewport_size(self : ViewLayout, width~ : Double, height~ : Double) -> ScrollChange?

    Sets the viewport box measured by the backend.

    ViewLayout::validate_scroll_position

    fn ViewLayout::validate_scroll_position(self : ViewLayout, position : ScrollPositionUpdate) -> ScrollPosition

    ViewLayout::vertical_offset_for_line

    fn ViewLayout::vertical_offset_for_line(self : ViewLayout, line : Int) -> Double

    The top of a 1-based line in content space. Line numbers clamp to the document so callers can probe one-past-the-end (line_count + 1) for a bottom edge.

    ViewLayout::visible_window

    fn ViewLayout::visible_window(self : ViewLayout) -> LineWindow

    The half-open window of view lines intersecting the current viewport — the [startLineNumber, endLineNumber] band of Monaco's ViewLayout.getLinesViewportData(), partially visible edge lines included. Recomputed every frame; the view renders exactly these lines.

    ViewLayout::window_origin

    fn ViewLayout::window_origin(self : ViewLayout, window : LineWindow) -> Double

    The content-space top of a window's first line: the translation the view applies to the lines layer (window_origin - scroll_top).

    ViewLineRenderingData

    pub(all) struct ViewLineRenderingData {
    min_column : Int
    max_column : Int
    content : String
    continues_with_wrapped_line : Bool
    contains_rtl : Bool
    is_basic_ascii : Bool
    tokens : Array[LinePart]
    inline_decorations : Array[InlineDecoration]
    tab_size : Int
    start_visible_column : Int
    text_direction : TextDirection
    has_variable_fonts : Bool
    } derive(Eq,
    Debug
    )

    View-model line data before it is expanded into full render input.

    ViewLineRenderingData::equal

    ViewLineRenderingData::not_equal

    ViewWhitespaceViewportData

    pub struct ViewWhitespaceViewportData {
    id : String
    after_line_number : Int
    vertical_offset : Double
    height : Int
    } derive(Eq,
    Debug
    )

    One whitespace positioned relative to a viewport — the Monaco IViewWhitespaceViewportData shape.

    ViewWhitespaceViewportData::equal

    ViewWhitespaceViewportData::not_equal

    Viewport

    pub struct Viewport {
    top : Double
    left : Double
    width : Double
    height : Double
    } derive(Eq,
    Debug
    )

    Viewport::equal

    fn Viewport::equal(Viewport, Viewport) -> Bool

    Viewport::not_equal

    fn Viewport::not_equal(x : Viewport, y : Viewport) -> Bool

    Viewport::to_repr

    ViewportData

    pub(all) struct ViewportData {
    start_line_number : Int
    end_line_number : Int
    relative_vertical_offset : Array[Double]
    line_height : Int
    visible_range :
    Range

    big_numbers_delta : Int
    lines : Array[ViewLineRenderingData]
    line_decorations : Array[Array[LineDecoration]]
    view_zones : Array[ViewWhitespaceViewportData]
    } derive(Eq,
    Debug
    )

    Line-renderer viewport data derived from the backend-neutral view model and layout state.

    ViewportData::decorations_for_line

    fn ViewportData::decorations_for_line(self : ViewportData, line_number : Int) -> Array[LineDecoration]

    Line decorations for a one-based line number inside this viewport.

    ViewportData::decorations_in_viewport

    fn ViewportData::decorations_in_viewport(self : ViewportData) -> Array[LineDecoration]

    Flattened decorations for every line in this viewport.

    ViewportData::equal

    ViewportData::line_data

    fn ViewportData::line_data(self : ViewportData, line_number : Int) -> ViewLineRenderingData?

    Line-rendering data for a one-based line number inside this viewport.

    ViewportData::not_equal

    fn ViewportData::not_equal(x : ViewportData, y : ViewportData) -> Bool

    WhitespaceChangeAccessor

    type WhitespaceChangeAccessor

    Mutable accessor handed to change_whitespace, mirroring Monaco's IWhitespaceChangeAccessor.

    WhitespaceChangeAccessor::change_one_whitespace

    fn WhitespaceChangeAccessor::change_one_whitespace(self : WhitespaceChangeAccessor, id : String, new_after_line_number : Int, new_height : Double, new_min_width? : Double) -> Unit

    Queues a whitespace afterLineNumber/height change.

    WhitespaceChangeAccessor::insert_whitespace

    fn WhitespaceChangeAccessor::insert_whitespace(self : WhitespaceChangeAccessor, after_line_number : Int, ordinal : Int, height_in_px : Double, min_width : Double) -> String

    Queues a whitespace insertion; returns its freshly minted id.

    WhitespaceChangeAccessor::remove_whitespace

    fn WhitespaceChangeAccessor::remove_whitespace(self : WhitespaceChangeAccessor, id : String) -> Unit

    Queues a whitespace removal.

    current_line_content_class

    fn current_line_content_class(in_margin~ : Bool, exact~ : Bool) -> String

    CurrentLineHighlightOverlay._renderOne's class string (currentLineHighlight.ts:210).

    current_line_margin_class

    fn current_line_margin_class(in_margin~ : Bool, other~ : Bool, exact~ : Bool) -> String

    CurrentLineMarginHighlightOverlay._renderOne's class string (currentLineHighlight.ts:226).

    render_view_line

    fn render_view_line(input : RenderLineInput, html : StringBuilder) -> RenderLineOutput

    Renders one line into html and returns mapping/foreign-element metadata.

    render_view_line2

    fn render_view_line2(input : RenderLineInput) -> RenderLineOutput2

    Renders one line and returns the generated HTML with metadata.

    should_render_line_highlight_in_content

    fn should_render_line_highlight_in_content(mode :
    RenderLineHighlight
    , only_when_focus : Bool, focused : Bool, selection_is_empty : Bool) -> Bool

    AbstractLineHighlightOverlay._shouldRenderInContent (currentLineHighlight.ts:191-197): the content fill/border renders only while the selection is empty.

    should_render_line_highlight_in_margin

    fn should_render_line_highlight_in_margin(mode :
    RenderLineHighlight
    , only_when_focus : Bool, focused : Bool) -> Bool

    AbstractLineHighlightOverlay._shouldRenderInMargin (currentLineHighlight.ts:184-189).

    view_line_span_of_model_line

    fn view_line_span_of_model_line(view_line_number : Int, line_count : Int, model_line_of : (Int) -> Int) -> (Int, Int)

    The first and last one-based view lines of the model line containing view_line_number — the wrapped-line pass's converter round-trip (currentLineHighlight.ts:146-149), realized as a scan over the view→model line mapping (same result: view lines of one model line are contiguous). model_line_of is the caller's model_line_number_of_view_line; line_count is the view line count.