MingaEditor.State.Highlighting (Minga v0.1.0)

Copy Markdown View Source

Groups syntax-highlighting fields from EditorState.

Tracks per-buffer highlight data, a monotonic version counter for invalidation, the mapping from buffer PIDs to parser buffer IDs (monotonically incrementing u32s), and LRU timestamps for inactive tree eviction.

Highlight spans are stored per-buffer in highlights. There is no separate "current" field; the active buffer's highlight is just Map.get(highlights, active_pid).

Summary

Functions

Stores highlight data for a buffer.

Removes all highlight-related state for a buffer.

Rebuilds every buffer's highlight face registry from a new theme.

Replaces the highlight map.

Replaces syntax overrides.

Sets the highlight state version.

Types

t()

@type t() :: %MingaEditor.State.Highlighting{
  buffer_ids: %{required(pid()) => non_neg_integer()},
  highlights: %{required(pid()) => MingaEditor.UI.Highlight.t()},
  last_active_at: %{required(pid()) => integer()},
  next_buffer_id: non_neg_integer(),
  reverse_buffer_ids: %{required(non_neg_integer()) => pid()},
  syntax_overrides: %{required(pid()) => MingaEditor.UI.Theme.syntax()},
  version: non_neg_integer()
}

Functions

put_highlight(state, pid, highlight)

@spec put_highlight(t(), pid(), MingaEditor.UI.Highlight.t()) :: t()

Stores highlight data for a buffer.

remove_buffer(state, buffer_pid, buffer_id, remaining_ids)

@spec remove_buffer(t(), pid(), non_neg_integer(), %{
  required(pid()) => non_neg_integer()
}) :: t()

Removes all highlight-related state for a buffer.

retheme_all(state, theme)

@spec retheme_all(t(), MingaEditor.UI.Theme.t()) :: t()

Rebuilds every buffer's highlight face registry from a new theme.

Buffers with a stored syntax_overrides entry (e.g. the agent buffer's dimmed delimiters) keep their custom, theme-independent palette and are left untouched.

set_highlights(state, highlights)

@spec set_highlights(t(), %{required(pid()) => MingaEditor.UI.Highlight.t()}) :: t()

Replaces the highlight map.

set_syntax_overrides(state, overrides)

@spec set_syntax_overrides(t(), %{required(pid()) => MingaEditor.UI.Theme.syntax()}) ::
  t()

Replaces syntax overrides.

set_version(state, version)

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

Sets the highlight state version.