Yank region flash after a yank operation.
Briefly highlights the yanked region with a bright background that fades back to the editor background over several steps, providing visual confirmation of what was copied (like Neovim's YankHighlight).
This is a pure calculation module. It returns structs and side-effect
instructions ({:send_after, msg, interval}, {:cancel_timer, ref}).
The Editor GenServer executes the side effects.
Summary
Types
Position as {line, col}.
Whether the yanked region is charwise or linewise.
Side-effect instruction returned to the caller.
Active yank flash state tracking the highlighted region and animation progress.
Functions
Advances the flash to the next step.
Returns side effects needed to cancel an active flash.
Computes the flash background color for the current step.
Computes the highlight bounds for the flash decoration.
Creates a new yank flash for the given buffer and range.
Types
@type position() :: {non_neg_integer(), non_neg_integer()}
Position as {line, col}.
@type range_type() :: :charwise | :linewise
Whether the yanked region is charwise or linewise.
@type side_effect() :: {:send_after, atom(), pos_integer()} | {:cancel_timer, reference()}
Side-effect instruction returned to the caller.
@type t() :: %MingaEditor.YankFlash{ buf: pid(), end_pos: position(), max_steps: pos_integer(), range_type: range_type(), start_pos: position(), step: non_neg_integer(), timer: reference() | nil }
Active yank flash state tracking the highlighted region and animation progress.
Functions
@spec advance(t()) :: {:continue, t(), [side_effect()]} | :done
Advances the flash to the next step.
Returns {:continue, updated_flash, side_effects} if more steps
remain, or :done if the flash is complete.
@spec cancel_effects(t() | nil) :: [side_effect()]
Returns side effects needed to cancel an active flash.
@spec color_for_step(t(), non_neg_integer(), non_neg_integer()) :: non_neg_integer()
@spec default_flash_bg() :: non_neg_integer()
Computes the flash background color for the current step.
Interpolates between flash_bg (step 0) and target_bg (final step)
linearly.
@spec flash_group() :: atom()
Computes the highlight bounds for the flash decoration.
Charwise ranges pass through unchanged. Linewise ranges expand to full line width using the buffer's line content.
@spec start(pid(), position(), position(), range_type(), reference() | nil) :: {t(), [side_effect()]}
Creates a new yank flash for the given buffer and range.
Returns {flash, side_effects}. The caller must execute the side
effects (cancel old timer, schedule new one).