MingaEditor.Shell.Traditional.Modeline (Minga v0.1.0)

Copy Markdown View Source

Doom Emacs-style modeline rendering.

Renders the colored status line at row N-2. Takes a data map and viewport width; returns a list of draw tuples and a list of clickable regions. Has no dependency on the GenServer or any mutable state, just a pure data → {draws, click_regions} transformation.

Click regions are {col_start, col_end, command} tuples attached to segments at render time, matching how Doom Emacs embeds local-map text properties and Neovim embeds %@ClickHandler@ markers. The mouse handler looks up the command for a clicked column without reverse-engineering the layout.

Summary

Types

A clickable region: column range mapping to a command.

Git diff summary: {added, modified, deleted} line counts.

LSP connection status for the modeline indicator.

Data for rendering the modeline.

Parser availability status for the modeline indicator.

Functions

Returns the cursor shape for the given mode.

Renders the modeline at the given row using the provided data.

Types

click_region()

@type click_region() ::
  {col_start :: non_neg_integer(), col_end :: non_neg_integer(),
   command :: atom()}

A clickable region: column range mapping to a command.

git_diff_summary()

@type git_diff_summary() ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer()} | nil

Git diff summary: {added, modified, deleted} line counts.

lsp_status()

@type lsp_status() :: :ready | :initializing | :starting | :error | :none

LSP connection status for the modeline indicator.

modeline_data()

@type modeline_data() :: %{
  :mode => Minga.Mode.mode(),
  :mode_state => Minga.Mode.state() | nil,
  :file_name => String.t(),
  :filetype => atom(),
  :dirty_marker => String.t(),
  :cursor_line => non_neg_integer(),
  :cursor_col => non_neg_integer(),
  :line_count => non_neg_integer(),
  :buf_index => pos_integer(),
  :buf_count => non_neg_integer(),
  :macro_recording => {true, String.t()} | false,
  optional(:agent_status) => MingaEditor.State.Agent.status(),
  optional(:agent_theme_colors) => MingaEditor.UI.Theme.Agent.t() | nil,
  optional(:mode_override) => String.t() | nil,
  optional(:lsp_status) => lsp_status(),
  optional(:parser_status) => parser_status(),
  optional(:git_branch) => String.t() | nil,
  optional(:git_diff_summary) => git_diff_summary(),
  optional(:diagnostic_counts) =>
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
    | nil
}

Data for rendering the modeline.

parser_status()

@type parser_status() :: :available | :unavailable | :restarting

Parser availability status for the modeline indicator.

Functions

cursor_shape(arg1)

Returns the cursor shape for the given mode.

Accepts either a bare mode atom or the full vim state map. When the vim state is passed, pending: :replace in normal mode produces an underline cursor (matching Vim's r feedback).

render(row, cols, data, theme \\ MingaEditor.UI.Theme.get!(:doom_one), col_off \\ 0)

Renders the modeline at the given row using the provided data.

Returns {draw_commands, click_regions} where click_regions is a list of {col_start, col_end, command_atom} tuples for mouse hit-testing.