MingaEditor.RenderPipeline.Input (Minga v0.1.0)

Copy Markdown View Source

Narrow rendering contract between the Editor GenServer and the render pipeline.

Bundles exactly the fields that the pipeline stages read from EditorState, excluding ~15 fields the pipeline never touches (render_timer, buffer_monitors, focus_stack, lsp, parser_status, pending_quit, session, git_remote_op, etc.).

The Editor builds this before calling RenderPipeline.run/1. Pipeline stages read from Input and never reach back into EditorState. After the pipeline completes, the caller writes mutations back via EditorState.apply_render_output/2.

Structural compatibility

Pipeline modules pattern-match on state.workspace.X throughout. Input keeps a workspace field (a plain map, not a WorkspaceState struct) so those pattern-matches work unchanged. Top-level fields (theme, capabilities, shell, shell_state, etc.) are directly on Input, matching EditorState's shape.

Field sources

From state (top-level): theme, capabilities, shell, shell_state, port_manager, font_registry, message_store, face_override_registries, editing_model, backend, layout

From state.workspace (per-tab editing context, stored as workspace map): windows, buffers, viewport, file_tree, highlight, agent_ui, completion, editing, document_highlights, search, keymap_scope

Summary

Types

t()

Workspace-shaped map containing per-tab rendering fields.

Functions

Computes a fingerprint of chrome-relevant fields for dirty tracking.

Builds a render pipeline Input from the full editor state.

Syncs the active window's cursor from the buffer process.

Types

t()

@type t() :: %MingaEditor.RenderPipeline.Input{
  backend: MingaEditor.State.backend(),
  capabilities: MingaEditor.Frontend.Capabilities.t(),
  editing_model: :vim | :cua,
  face_override_registries: %{
    required(pid()) => MingaEditor.UI.Face.Registry.t()
  },
  font_registry: MingaEditor.UI.FontRegistry.t(),
  layout: MingaEditor.Layout.t() | nil,
  lsp: MingaEditor.State.LSP.t(),
  message_store: MingaEditor.UI.Panel.MessageStore.t(),
  parser_status: atom(),
  port_manager: GenServer.server() | nil,
  shell: module(),
  shell_state:
    MingaEditor.Shell.Traditional.State.t() | MingaEditor.Shell.Board.State.t(),
  theme: MingaEditor.UI.Theme.t(),
  workspace: workspace()
}

workspace()

@type workspace() :: %{
  windows: MingaEditor.State.Windows.t(),
  buffers: MingaEditor.State.Buffers.t(),
  viewport: MingaEditor.Viewport.t(),
  file_tree: MingaEditor.State.FileTree.t(),
  highlight: MingaEditor.State.Highlighting.t(),
  agent_ui: MingaEditor.Agent.UIState.t(),
  completion: Minga.Editing.Completion.t() | nil,
  editing: MingaEditor.VimState.t(),
  document_highlights: [MingaEditor.State.document_highlight()] | nil,
  mouse: MingaEditor.State.Mouse.t(),
  search: MingaEditor.State.Search.t(),
  keymap_scope: Minga.Keymap.Scope.scope_name()
}

Workspace-shaped map containing per-tab rendering fields.

Keeps the same state.workspace.X access pattern that pipeline modules use, so existing pattern-matches work unchanged.

Functions

chrome_fingerprint(input)

@spec chrome_fingerprint(t()) :: integer()

Computes a fingerprint of chrome-relevant fields for dirty tracking.

The chrome stage is expensive (tab bar, status bar, file tree, overlays). When the fingerprint matches the previous frame's, the chrome stage can reuse cached draws. The fingerprint covers all fields that affect chrome output; buffer content changes (which only affect the Content stage) do not change the fingerprint.

Returns an integer hash suitable for fast equality comparison.

from_editor_state(state)

@spec from_editor_state(MingaEditor.State.t()) :: t()

Builds a render pipeline Input from the full editor state.

Extracts exactly the fields that the pipeline's seven stages read, leaving GenServer-only fields (render_timer, buffer_monitors, focus_stack, session, pending_quit, etc.) behind.

sync_active_window_cursor(input)

@spec sync_active_window_cursor(t()) :: t()

Syncs the active window's cursor from the buffer process.

Equivalent to EditorState.sync_active_window_cursor/1 but operates on the Input's workspace map.