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. Segment selection comes from Minga.Config.Options, and custom segments come from Minga.Config.ModelineSegments.

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 built-in modeline segment names.

Returns the cursor shape for the given mode.

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.

context()

@type context() :: %{
  data: modeline_data(),
  theme: MingaEditor.UI.Theme.t(),
  bar_bg: non_neg_integer(),
  bar_fg: non_neg_integer(),
  info_bg: non_neg_integer(),
  info_fg: non_neg_integer(),
  mode_bg: non_neg_integer(),
  mode_fg: non_neg_integer()
}

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.

gui_segment()

@type gui_segment() ::
  {atom(), String.t(), non_neg_integer(), non_neg_integer(), keyword(),
   atom() | nil}

gui_segments()

@type gui_segments() :: %{left: [gui_segment()], right: [gui_segment()]}

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,
  optional(:safe_mode) => boolean(),
  :file_name => String.t(),
  :workspace_label => String.t(),
  :workspace_draft_count => non_neg_integer(),
  :workspace_conflict_count => non_neg_integer(),
  :merge_conflict_count => non_neg_integer(),
  :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(:active_tool_name) => String.t() | nil,
  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,
  optional(:indent_type) => :spaces | :tabs,
  optional(:indent_size) => pos_integer(),
  optional(:selection_info) =>
    {:chars, non_neg_integer()} | {:lines, pos_integer()} | nil,
  optional(:background_subagent_count) => non_neg_integer(),
  optional(:active_background_subagent_label) => String.t() | nil
}

Data for rendering the modeline.

parser_status()

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

Parser availability status for the modeline indicator.

render_segment()

@type render_segment() :: Minga.Config.ModelineSegment.render_segment()

segment_group()

@type segment_group() :: %{
  name: atom(),
  priority: integer(),
  segments: [render_segment()]
}

Functions

built_in_segments()

@spec built_in_segments() :: [atom()]

Returns the built-in modeline segment names.

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).

gui_segments(data, theme \\ MingaEditor.UI.Theme.get!(MingaEditor.UI.Theme.default()), modeline_segments_table \\ ModelineSegments)

Returns configured modeline segments for native GUI status bars.