Minga.Editing (Minga v0.1.0)

Copy Markdown View Source

Editing domain facade.

Cursor motions, text operations, search, bracket matching, comment toggling, formatting, and scroll state. This module is the only valid entry point from outside the domain.

External callers use this facade for behavior. Struct types (Minga.Editing.Completion.t(), Minga.Editing.Search.Match.t(), Minga.Editing.Scroll.t()) may be referenced directly in @spec annotations per AGENTS.md type-crossing rules. Protocols (Minga.Editing.Text.Readable) and behaviours (Minga.Editing.Model) are also part of the public API.

Summary

Functions

Returns the active editing model module from global config. Prefer active_model/1 when state is available.

Returns the active editing model module from editor state.

Apply save-time transforms (trim trailing whitespace, final newline).

Backspace, removing the matching bracket when the cursor is between a pair.

Returns the keymap binding state for scope trie resolution.

Resolve comment prefix with nil fallback.

Resolve comment prefix accounting for injection ranges.

Compute comment toggle edits for the given lines (pure, no Buffer I/O).

What cursor shape should the frontend render?

Format content using a formatter command string.

Is a leader key sequence in progress?

Insert a character, auto-inserting the matching bracket when appropriate.

Is the user currently inserting text?

Is a multi-key sequence in progress (leader key, operator-pending, etc.)?

Is a macro currently being recorded? Returns {true, register} or false.

Is the editor in a minibuffer-occupying mode (command line, search, eval)?

Current editing mode atom (e.g., :normal, :insert, :visual, :cua).

Creates a new scroll state with default values.

Pin scroll to the bottom of content.

Resolve the formatter spec for a filetype and file path.

Resolve a scroll target given total content lines and visible height.

Scroll down by the given number of lines.

Scroll to the top of content.

Scroll up by the given number of lines.

Find all matches for a pattern within a line range.

Find the next match for a pattern starting from a position.

Does the user have an active selection?

Set the scroll offset directly.

Short mode label for the status bar (e.g., 'NORMAL', 'INSERT', '').

Substitute all matches in buffer content.

Substitute matches in a single line, returning styled spans for preview.

Returns the word under the cursor, or nil.

Functions

active_model()

@spec active_model() :: module()

Returns the active editing model module from global config. Prefer active_model/1 when state is available.

active_model(arg1)

@spec active_model(map()) :: module()

Returns the active editing model module from editor state.

apply_save_transforms(content, trim, final_newline)

Apply save-time transforms (trim trailing whitespace, final newline).

backspace_with_pairs(buf, pos)

Backspace, removing the matching bracket when the cursor is between a pair.

binding_state(state)

@spec binding_state(map()) :: atom()

Returns the keymap binding state for scope trie resolution.

This is the discriminator that Scope.resolve_key/3 uses to select which trie of bindings to look up. CUA always returns :cua. Vim returns the current mode mapped to the scope-relevant subset (:normal, :insert, :input_normal).

Use this instead of manually checking cua_active? and branching on the editing model in input handlers.

change(buf, start_pos, end_pos)

See Minga.Editing.Operator.change/3.

comment_prefix(token)

Resolve comment prefix with nil fallback.

comment_prefix_at(default_token, byte_offset, injection_ranges, token_for_lang)

Resolve comment prefix accounting for injection ranges.

compute_comment_edits(lines, prefix, start_line)

Compute comment toggle edits for the given lines (pure, no Buffer I/O).

cursor_shape(state)

@spec cursor_shape(map()) :: :beam | :block | :underline

What cursor shape should the frontend render?

delete(buf, start_pos, end_pos)

See Minga.Editing.Operator.delete/3.

document_end(readable)

See Minga.Editing.Motion.document_end/1.

document_start(readable)

See Minga.Editing.Motion.document_start/1.

find_char_backward(readable, pos, char)

See Minga.Editing.Motion.find_char_backward/3.

find_char_forward(readable, pos, char)

See Minga.Editing.Motion.find_char_forward/3.

first_non_blank(readable, pos)

See Minga.Editing.Motion.first_non_blank/2.

format(content, command_string)

Format content using a formatter command string.

in_leader?(arg1)

@spec in_leader?(map()) :: boolean()

Is a leader key sequence in progress?

insert_with_pairs(buf, pos, char)

Insert a character, auto-inserting the matching bracket when appropriate.

inserting?(state)

@spec inserting?(map()) :: boolean()

Is the user currently inserting text?

key_sequence_pending?(state)

@spec key_sequence_pending?(map()) :: boolean()

Is a multi-key sequence in progress (leader key, operator-pending, etc.)?

line_end(readable, pos)

See Minga.Editing.Motion.line_end/2.

line_start(readable, pos)

See Minga.Editing.Motion.line_start/2.

macro_recording_status(map)

@spec macro_recording_status(map()) :: {true, String.t()} | false

Is a macro currently being recorded? Returns {true, register} or false.

match_bracket(readable, pos)

See Minga.Editing.Motion.match_bracket/2.

minibuffer_mode?(map)

@spec minibuffer_mode?(map()) :: boolean()

Is the editor in a minibuffer-occupying mode (command line, search, eval)?

mode(map)

@spec mode(map()) :: atom()

Current editing mode atom (e.g., :normal, :insert, :visual, :cua).

new_scroll()

Creates a new scroll state with default values.

paragraph_backward(readable, pos)

See Minga.Editing.Motion.paragraph_backward/2.

paragraph_forward(readable, pos)

See Minga.Editing.Motion.paragraph_forward/2.

pin_to_bottom(scroll)

Pin scroll to the bottom of content.

resolve_formatter(filetype, file_path)

Resolve the formatter spec for a filetype and file path.

resolve_scroll(scroll, total_lines, visible_height)

Resolve a scroll target given total content lines and visible height.

scroll_down(scroll, amount)

Scroll down by the given number of lines.

scroll_to_top(scroll)

Scroll to the top of content.

scroll_up(scroll, amount)

Scroll up by the given number of lines.

search_all_in_range(readable, pattern, range)

Find all matches for a pattern within a line range.

search_next(readable, pattern, pos, direction)

Find the next match for a pattern starting from a position.

select_around_parens(readable, pos, open, close)

See Minga.Editing.TextObject.a_parens/4.

select_around_quotes(readable, pos, quote_char)

See Minga.Editing.TextObject.a_quotes/3.

select_around_word(readable, pos)

See Minga.Editing.TextObject.a_word/2.

select_inner_parens(readable, pos, open, close)

See Minga.Editing.TextObject.inner_parens/4.

select_inner_quotes(readable, pos, quote_char)

See Minga.Editing.TextObject.inner_quotes/3.

select_inner_word(readable, pos)

See Minga.Editing.TextObject.inner_word/2.

select_structural_around(tree_data)

See Minga.Editing.TextObject.structural_around/1.

select_structural_inner(tree_data)

See Minga.Editing.TextObject.structural_inner/1.

selecting?(state)

@spec selecting?(map()) :: boolean()

Does the user have an active selection?

set_scroll_offset(scroll, offset)

Set the scroll offset directly.

status_segment(state)

@spec status_segment(map()) :: String.t()

Short mode label for the status bar (e.g., 'NORMAL', 'INSERT', '').

substitute(content, pattern, replacement, global?)

Substitute all matches in buffer content.

substitute_line_preview(readable, pattern, replacement, line)

Substitute matches in a single line, returning styled spans for preview.

till_char_backward(readable, pos, char)

See Minga.Editing.Motion.till_char_backward/3.

till_char_forward(readable, pos, char)

See Minga.Editing.Motion.till_char_forward/3.

visual_line_down(doc, pos, content_w)

See Minga.Editing.Motion.VisualLine.visual_down/3.

visual_line_end(doc, pos, content_w)

See Minga.Editing.Motion.VisualLine.visual_line_end/3.

visual_line_start(doc, pos, content_w)

See Minga.Editing.Motion.VisualLine.visual_line_start/3.

visual_line_up(doc, pos, content_w)

See Minga.Editing.Motion.VisualLine.visual_up/3.

word_backward(readable, pos)

See Minga.Editing.Motion.word_backward/2.

word_backward_big(readable, pos)

See Minga.Editing.Motion.word_backward_big/2.

word_end(readable, pos)

See Minga.Editing.Motion.word_end/2.

word_end_big(readable, pos)

See Minga.Editing.Motion.word_end_big/2.

word_forward(readable, pos)

See Minga.Editing.Motion.word_forward/2.

word_forward_big(readable, pos)

See Minga.Editing.Motion.word_forward_big/2.

word_under_cursor(readable, pos)

Returns the word under the cursor, or nil.

yank(buf, start_pos, end_pos)

See Minga.Editing.Operator.yank/3.