MingaEditor.Frontend (Minga v0.1.0)

Copy Markdown View Source

Frontend communication domain facade.

External callers tell the frontend WHAT to do through semantic operations. The Frontend domain handles HOW (binary encoding, batching, protocol versioning) internally.

Render frames

The Editor builds a Frame struct (display list of styled text runs). send_render_frame/2 encodes and sends it to the frontend.

Parser commands

Tree-sitter parsing runs in a separate Zig process. Parser commands (setup_buffer, update_buffer, set_queries) encode the appropriate wire messages and send them to the parser port.

Configuration

Font, title, theme, and window background are set through individual semantic operations.

Summary

Functions

Returns the frontend capabilities struct.

Sends a clipboard write command to the GUI frontend.

Decodes a binary event from the frontend or parser process.

Returns the default capabilities struct.

Returns true if the frontend supports GUI chrome opcodes.

Returns true if the frontend is ready to receive commands.

Returns true if the frontend supports semantic render-model opcodes.

Sends a list of pre-encoded commands to the frontend process.

Sends a bare, content-free frame transaction to the frontend (#2219).

Sends the per-frame render batch and stamps a monotonic send time so the frontend emits a [:minga, :render, :hop_latency] (hop: :send_commands) sample for the Renderer.Server → Port.Manager scheduling delay.

Toggles the GUI go-to-definition link cursor (#2630).

Subscribes the calling process to frontend events.

Returns the terminal dimensions {width, height}.

Functions

capabilities(server \\ MingaEditor.Frontend.Manager)

Returns the frontend capabilities struct.

clipboard_write(port, text, pasteboard \\ :general)

Sends a clipboard write command to the GUI frontend.

configure_font(port, family, size, ligatures, weight, fallbacks \\ [])

Configures the editor font.

decode_event(data)

@spec decode_event(binary()) ::
  {:ok, MingaEditor.Frontend.Protocol.input_event()}
  | {:error, :unknown_opcode | :malformed}

Decodes a binary event from the frontend or parser process.

default_capabilities()

@spec default_capabilities() :: MingaEditor.Frontend.Capabilities.t()

Returns the default capabilities struct.

gui?(caps)

Returns true if the frontend supports GUI chrome opcodes.

ready?(server \\ MingaEditor.Frontend.Manager)

@spec ready?(GenServer.server()) :: boolean()

Returns true if the frontend is ready to receive commands.

semantic_ui?(caps)

@spec semantic_ui?(MingaEditor.Frontend.Capabilities.t()) :: boolean()

Returns true if the frontend supports semantic render-model opcodes.

send_commands(server \\ MingaEditor.Frontend.Manager, commands)

@spec send_commands(GenServer.server() | nil, [binary()]) ::
  MingaEditor.Frontend.Adapter.admission()

Sends a list of pre-encoded commands to the frontend process.

send_frame_boundary(port, frame_seq, base_frame_seq, input_seq \\ 0)

Sends a bare, content-free frame transaction to the frontend (#2219).

Used by frame-synchronization contracts that must emit a frame boundary without re-rendering (the operator-pending no-op optimization). Brackets nothing with begin_frame ++ commit_frame. frame_seq is the strictly monotonic global frame sequence; base_frame_seq names the previously emitted frame (0 for the first). input_seq is the echoed input correlation sequence (ticket #2215, default 0).

send_render_commands(server \\ MingaEditor.Frontend.Manager, commands)

@spec send_render_commands(GenServer.server() | nil, [binary()]) ::
  MingaEditor.Frontend.Adapter.admission()

Sends the per-frame render batch and stamps a monotonic send time so the frontend emits a [:minga, :render, :hop_latency] (hop: :send_commands) sample for the Renderer.Server → Port.Manager scheduling delay.

set_title(port \\ MingaEditor.Frontend.Manager, title)

Sets the window title.

set_window_bg(port \\ MingaEditor.Frontend.Manager, color)

Sets the window background color.

subscribe(server \\ MingaEditor.Frontend.Manager)

@spec subscribe(GenServer.server()) :: :ok

Subscribes the calling process to frontend events.

terminal_size(server \\ MingaEditor.Frontend.Manager)

@spec terminal_size(GenServer.server()) :: {pos_integer(), pos_integer()} | nil

Returns the terminal dimensions {width, height}.