ExVEx.Mutation.Shift (ExVEx v0.2.0)

Copy Markdown View Source

A row/column insertion or deletion expressed as a single data record.

axis is :row or :col. at is the 1-indexed position at which the insertion happens (everything at that position and below/right shifts); for deletion, at is the first position removed. count is how many rows/columns are affected. delta is +count for insertion and -count for deletion, pre-computed for convenience.

sheet identifies which sheet the shift applies to; when nil the shift applies across the whole workbook (used while walking formulas whose ranges don't specify a sheet).

Summary

Functions

Applies the shift to a single 1-indexed coordinate on the axis, if it is affected. Returns {:ok, new_index}, :unchanged, or :deleted if the position falls inside a deletion span.

Types

axis()

@type axis() :: :row | :col

t()

@type t() :: %ExVEx.Mutation.Shift{
  at: pos_integer(),
  axis: axis(),
  count: pos_integer(),
  delta: integer(),
  sheet: String.t() | nil
}

Functions

apply_index(shift, idx)

@spec apply_index(t(), pos_integer()) :: {:ok, pos_integer()} | :unchanged | :deleted

Applies the shift to a single 1-indexed coordinate on the axis, if it is affected. Returns {:ok, new_index}, :unchanged, or :deleted if the position falls inside a deletion span.

delete(axis, at, count, sheet)

@spec delete(axis(), pos_integer(), pos_integer(), String.t() | nil) :: t()

insert(axis, at, count, sheet)

@spec insert(axis(), pos_integer(), pos_integer(), String.t() | nil) :: t()