View Source PieceTable.Change (piece_table v0.1.2)
A struct to hold changes in the PieceTable
usage
Usage
iex> table = PieceTable.Change.new!(:ins, "test", 3)
%PieceTable.Change{change: :ins, position: 3, text: "test"}
Link to this section Summary
Functions
Inverts the operation of a PieceTable.Change struct.
Inverts the operation of a PieceTable.Change struct.
Creates a new PieceTable.Change struct. This is intended the only method to build it.
Creates a new PieceTable.Change struct. This is intended the only method to build it.
Link to this section Types
Link to this section Functions
Inverts the operation of a PieceTable.Change struct.
parameters
Parameters
chg
(PieceTable.Change.t()): The change to invert
returns
Returns
{:ok, %PieceTable.Change{}}
{:error, any}
examples
Examples
iex> PieceTable.Change.invert(%PieceTable.Change{change: :ins, text: "random", position: 5})
{:ok, %PieceTable.Change{change: :del, text: "random", position: 5}}
Inverts the operation of a PieceTable.Change struct.
parameters
Parameters
chg
(PieceTable.Change.t()): The change to invert
returns
Returns
%PieceTable.Change{}
examples
Examples
iex> PieceTable.Change.invert(%PieceTable.Change{change: :ins, text: "random", position: 5})
{:ok, %PieceTable.Change{change: :del, text: "random", position: 5}}
Creates a new PieceTable.Change struct. This is intended the only method to build it.
parameters
Parameters
change
(atom()): The operation it represents [:ins | :del]text
(String.t()): The text to editposition
(integer()): The position at which the edit occurs
returns
Returns
{:ok, %PieceTable.Change{}}
{:error, {:wrong, "edit", -1}}
examples
Examples
iex> PieceTable.Change.new(:ins, "test", 4)
{:ok, %PieceTable.Change{change: :ins, text: "test", position: 4}}
Creates a new PieceTable.Change struct. This is intended the only method to build it.
parameters
Parameters
change
(atom()): The operation it represents [:ins | :del]text
(String.t()): The text to editposition
(integer()): The position at which the edit occurs
returns
Returns
%PieceTable.Change{}
examples
Examples
iex> PieceTable.Change.new!(:ins, "test", 4)
%PieceTable.Change{change: :ins, text: "test", position: 4}