Cursor line flash after large jumps.
Briefly highlights the landing line with a brighter background after the cursor moves more than a configurable threshold. The flash fades in steps from a bright highlight back to the normal cursorline tint (or editor bg if cursorline is disabled).
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
Side-effect instruction returned to the caller.
Flash state: nil when inactive, struct when flashing.
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.
Creates a new flash struct for the given line.
Types
@type side_effect() :: {:send_after, atom(), pos_integer()} | {:cancel_timer, reference()}
Side-effect instruction returned to the caller.
@type t() :: %MingaEditor.NavFlash{ line: non_neg_integer(), max_steps: pos_integer(), step: non_neg_integer(), timer: reference() | nil }
Flash state: nil when inactive, struct when flashing.
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.
Returns an empty list for nil input.
@spec color_for_step(t(), non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Computes the flash background color for the current step.
Interpolates between flash_bg (step 0) and target_bg (final step)
linearly. target_bg is the cursorline bg if cursorline is enabled,
or the editor bg otherwise.
@spec start(non_neg_integer(), reference() | nil) :: {t(), [side_effect()]}
Creates a new flash struct for the given line.
Returns {flash, side_effects}. The caller must execute the side
effects (cancel old timer, schedule new one).