MingaEditor.RenderModel.Window.Builder (Minga v0.1.0)

Copy Markdown View Source

Builds a RenderWindow from the same data the Content stage uses.

Called during build_window_content/2 when the frontend has GUI capabilities. Captures the pre-resolved semantic data that the GUI needs, without duplicating the draw logic.

The builder reads from:

  • WindowScroll (viewport, lines, cursor, fold map, visible_line_map)
  • Context.t() (visual selection, search matches, highlight, decorations)
  • Buffer diagnostics (for inline ranges)

All positions are converted to display coordinates (relative to the window's content rect, with fold/wrap adjustments applied).

Summary

Types

Per-build retained-row statistics (#2287).

Functions

Builds a RenderWindow for one editor window.

Builds a RenderWindow and reports retained-row statistics (#2287).

Returns the source buffer position for a click in wrapped composed rows.

Types

build_stats()

@type build_stats() :: %{
  rasterized: non_neg_integer(),
  retained_rows: %{
    optional(non_neg_integer()) =>
      {non_neg_integer(), Minga.RenderModel.Window.Row.t()}
  },
  retained_wrap_lines: %{
    optional(non_neg_integer()) => {non_neg_integer(), [map()]}
  }
}

Per-build retained-row statistics (#2287).

  • rasterized — rows whose text and spans were freshly composed this frame.
  • retained_rows — the {row_id => {input_hash, Row.t()}} map to carry into the next frame so unchanged rows can be reused without recomposing.
  • retained_wrap_lines — the {buf_line => {input_hash, [entry]}} map to carry into the next frame so unchanged wrapped logical lines can be reused without recomposing or re-wrapping.

state()

Functions

build(state, scroll, ctx, opts \\ [])

Builds a RenderWindow for one editor window.

Called from the Content stage with the same WindowScroll and Context that drive the draw-based rendering.

build_with_stats(state, scroll, ctx, opts \\ [])

Builds a RenderWindow and reports retained-row statistics (#2287).

Identical output to build/4 but also returns how many rows were freshly rasterized and the retained-row map to carry into the next frame. Pass the previous frame's retained rows via the :retained_rows option so unchanged rows are reused verbatim instead of being recomposed.

wrapped_source_position(lines, first_line, visual_row, display_col, ctx, options)

@spec wrapped_source_position(
  [String.t()],
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer(),
  MingaEditor.Renderer.Context.t(),
  map()
) :: {:ok, non_neg_integer(), non_neg_integer()} | :error

Returns the source buffer position for a click in wrapped composed rows.