MingaEditor (Minga v0.1.0)

Copy Markdown View Source

Editor orchestration GenServer.

Ties together the buffer, port manager, viewport, and modal FSM. Receives input events from the Port Manager, routes them through Minga.Mode.process/3, executes the resulting commands against the buffer, recomputes the visible region, and sends render commands back to the Zig renderer.

The editor starts in Normal mode (Vim-style). The status line reflects the current mode: -- NORMAL --, -- INSERT --, etc.

Summary

Types

Options for starting the editor.

Internal state.

Functions

Send an async message to the Editor GenServer. Used by background tasks.

Renders the supplied editor state immediately or through the async renderer.

Ensures a buffer exists for the given file path, opening one if needed.

Opens a file in the editor.

Opens a native IPC target and applies request-local editor mode.

Rebuilds the cached native settings snapshot (#2119).

Triggers a full re-render of the current state.

Starts an Editor owner with an existing generation-owned effect scheduler.

OTP child start for the Editor owner inside a generation boundary.

Types

start_opt()

@type start_opt() ::
  {:name, GenServer.name()}
  | {:backend, MingaEditor.State.backend()}
  | {:port_manager, GenServer.server()}
  | {:parser_manager, GenServer.server()}
  | {:keymap_server, GenServer.server()}
  | {:options_server, GenServer.server() | nil}
  | {:events_registry, Minga.Events.registry()}
  | {:effect_scheduler, GenServer.server()}
  | {:buffer, pid()}
  | {:width, pos_integer()}
  | {:height, pos_integer()}
  | {:editing_model, :vim | :cua}
  | {:view_mode, Minga.CLI.view_mode()}
  | {:shell, :traditional | module()}
  | {:project_root, String.t() | nil}
  | {:swap_dir, String.t()}
  | {:session_dir, String.t()}
  | {:suppress_tool_prompts, boolean()}

Options for starting the editor.

state()

@type state() :: MingaEditor.State.t()

Internal state.

Functions

apply_diagnostic_decorations(state, uri)

@spec apply_diagnostic_decorations(state(), String.t()) :: :ok

apply_runtime_config_option(state, name, theme_name)

@spec apply_runtime_config_option(MingaEditor.State.t(), atom(), term()) ::
  MingaEditor.State.t()

cast(msg, server \\ __MODULE__)

@spec cast(term(), GenServer.server()) :: :ok

Send an async message to the Editor GenServer. Used by background tasks.

do_render(state)

@spec do_render(state()) :: state()

Renders the supplied editor state immediately or through the async renderer.

ensure_buffer_for_path(path, server \\ __MODULE__)

@spec ensure_buffer_for_path(String.t(), GenServer.server()) ::
  {:ok, pid()} | {:error, term()}

Ensures a buffer exists for the given file path, opening one if needed.

Delegates to the Editor GenServer so it can use the editor's options server for buffer creation, then registers the buffer in the workspace (buffer list, monitoring, log message). The buffer is added in the background without switching the active window.

Layer 2 callers that need workspace registration should use this function. Layer 1 callers (agent tools) should use Buffer.ensure_for_path/1 directly.

maybe_refresh_tool_picker(state)

@spec maybe_refresh_tool_picker(state()) :: state()

open_file(server \\ __MODULE__, file_path)

@spec open_file(GenServer.server(), String.t()) :: :ok | {:error, term()}

Opens a file in the editor.

open_native(path, editor_mode?, server \\ __MODULE__)

@spec open_native(String.t(), boolean(), GenServer.server()) :: :ok | {:error, term()}

Opens a native IPC target and applies request-local editor mode.

open_wait(path, editor_mode?, request_id, waiter, server \\ __MODULE__, wait_tracker \\ Minga.Frontend.WaitRequests)

@spec open_wait(
  String.t(),
  boolean(),
  String.t(),
  pid(),
  GenServer.server(),
  GenServer.server()
) :: :ok | {:error, term()}

Opens and target-binds a native IPC wait request.

refresh_git_repo(git_root)

@spec refresh_git_repo(String.t()) :: :ok

refresh_gui_config_state(state)

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

Rebuilds the cached native settings snapshot (#2119).

The snapshot is emitted in-frame as the config_state semantic model, so this only refreshes the cached struct on EditorState; the next render delivers it inside the frame transaction. A keyframe re-emits it for free. For non-GUI frontends the snapshot stays nil and nothing is emitted.

render(server \\ __MODULE__)

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

Triggers a full re-render of the current state.

reset_nav_flash_tracking(state)

@spec reset_nav_flash_tracking(state()) :: state()

resolve_git_root()

@spec resolve_git_root() :: String.t() | nil

schedule_render(state, delay_ms)

@spec schedule_render(state(), non_neg_integer()) :: state()

schedule_render_delay_ms(state, delay_ms)

@spec schedule_render_delay_ms(state(), non_neg_integer()) :: non_neg_integer()

start_link(opts \\ [])

@spec start_link([start_opt()]) :: GenServer.on_start()

Starts an Editor owner with an existing generation-owned effect scheduler.

start_owner_link(opts)

@spec start_owner_link([start_opt()]) :: GenServer.on_start()

OTP child start for the Editor owner inside a generation boundary.