MingaEditor.State.Frontend (Minga v0.1.0)

Copy Markdown View Source

Per-editor frontend connection and capability state.

The value owns frontend identity, rendering policy, connection handles, terminal dimensions, capability negotiation, pressure reporting, and input correlation. Renderer-owned state lives in MingaEditor.State.Render.

Summary

Functions

Accepts frontend capability negotiation.

Begins one native file-dialog request and retains its BEAM-owned origin.

Clears a request whose frontend command was not admitted.

Drops connection-scoped file-dialog ownership without reusing its request id.

Clears connection-scoped native presentation evidence.

Correlates the next committed frame with the latest frontend input.

Builds frontend state from editor startup options.

Records the latest native presentation proven by the connected frontend.

Returns whether this editor emits rendered frames.

Records the frontend's current resource-pressure report.

Records the terminal viewport reported by the active frontend.

Takes the matching file-dialog origin and rejects stale or mismatched results.

Types

backend()

@type backend() :: :tui | :gui | :native_gui | :headless

file_dialog_request()

@type file_dialog_request() ::
  :idle
  | {:open, file_dialog_request_id()}
  | {:save_as, file_dialog_request_id(), pid()}

file_dialog_request_id()

@type file_dialog_request_id() :: 0..4_294_967_295

rendering_policy()

@type rendering_policy() :: :enabled | :disabled

t()

@type t() :: %MingaEditor.State.Frontend{
  backend: backend(),
  capabilities: MingaEditor.Frontend.Capabilities.t(),
  file_dialog: file_dialog_request(),
  last_input_seq: non_neg_integer(),
  native_presentation:
    MingaEditor.NativeIPC.NativePresentationObservation.t() | nil,
  next_file_dialog_request_id: file_dialog_request_id(),
  port_manager: GenServer.server() | nil,
  rendering: rendering_policy(),
  resource_pressure: MingaEditor.State.ResourcePressure.t(),
  terminal_viewport: MingaEditor.Viewport.t()
}

Functions

accept_capabilities(frontend, capabilities)

@spec accept_capabilities(t(), MingaEditor.Frontend.Capabilities.t()) :: t()

Accepts frontend capability negotiation.

begin_file_dialog(frontend, arg2)

@spec begin_file_dialog(t(), :open | {:save_as, pid()}) ::
  {:ok, file_dialog_request_id(), t()} | {:error, :busy}

Begins one native file-dialog request and retains its BEAM-owned origin.

cancel_file_dialog(frontend, request_id)

@spec cancel_file_dialog(t(), file_dialog_request_id()) :: t()

Clears a request whose frontend command was not admitted.

clear_file_dialog(frontend)

@spec clear_file_dialog(t()) :: t()

Drops connection-scoped file-dialog ownership without reusing its request id.

clear_native_presentation(frontend)

@spec clear_native_presentation(t()) :: t()

Clears connection-scoped native presentation evidence.

correlate_input(frontend, sequence)

@spec correlate_input(t(), non_neg_integer()) :: t()

Correlates the next committed frame with the latest frontend input.

new(opts \\ [])

@spec new(keyword()) :: t()

Builds frontend state from editor startup options.

observe_native_presentation(frontend, observation)

@spec observe_native_presentation(
  t(),
  MingaEditor.NativeIPC.NativePresentationObservation.t()
) :: t()

Records the latest native presentation proven by the connected frontend.

rendering_enabled?(frontend)

@spec rendering_enabled?(t()) :: boolean()

Returns whether this editor emits rendered frames.

report_resource_pressure(frontend, low_power?, thermal_state)

@spec report_resource_pressure(
  t(),
  boolean(),
  MingaEditor.State.ResourcePressure.thermal_state()
) ::
  t()

Records the frontend's current resource-pressure report.

resize_terminal(frontend, viewport)

@spec resize_terminal(t(), MingaEditor.Viewport.t()) :: t()

Records the terminal viewport reported by the active frontend.

take_file_dialog(frontend, request_id)

@spec take_file_dialog(t(), file_dialog_request_id()) ::
  {:ok, file_dialog_request(), t()} | :stale

Takes the matching file-dialog origin and rejects stale or mismatched results.