changeset

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_LINE_ATTRIBUTES = []string{
	"author", "lmkr", "insertorder", "start",
}

Some of these attributes are kept for compatibility purposes. Not sure if we need all of them

View Source
var LineAttributes = []string{lineMarkerAttribute, "list"}

If one of these attributes are set to the first character of a line it is considered as a line attribute marker i.e. attributes set on this marker are applied to the whole line. The list attribute is only maintained for compatibility reasons

Functions

func ApplyToAText

func ApplyToAText(cs string, atext apool.AText, pool apool.APool) apool.AText

func ApplyToAttribution

func ApplyToAttribution(cs string, astr string, pool apool.APool) string

func ApplyToText

func ApplyToText(cs string, text string) (*string, error)

func ApplyZip

func ApplyZip(in1 string, in2 string, callback func(*Op, *Op) Op) string

func AttribsFromString

func AttribsFromString(str string, pool apool.APool) []apool.Attribute

func AttribsToString

func AttribsToString(attribs []apool.Attribute, pool *apool.APool) (*string, error)

func AttributeTester

func AttributeTester(attribPair apool.Attribute, pool *apool.APool) func(arg *string) bool

func CheckRep

func CheckRep(cs string) (*string, error)

func CloneAText

func CloneAText(atext apool.AText) apool.AText

func Compose

func Compose(cs1 string, cs2 string, pool apool.APool) string

func ComposeAttributes

func ComposeAttributes(attribs1 string, attribs2 string, resultIsMutation bool, pool apool.APool) string

func DecodeAttribString

func DecodeAttribString(s string) ([]int, error)

func DeserializeOps

func DeserializeOps(ops string) (*[]Op, error)

func Follow

func Follow(c string, rebasedChangeset string, reverseInsertOrder bool, pool *apool.APool) string

func HasAttrib

func HasAttrib(attribs AttributeMap) bool

func Identity

func Identity(n int) string

func JoinAttributionLines

func JoinAttributionLines(theAlines []string) string

func MakeAText

func MakeAText(str string, attribs *string) apool.AText

func MakeAttribution

func MakeAttribution(text string) string

func MakeSplice

func MakeSplice(orig string, start int, ndel int, ins string, attribs *string, pool *apool.APool) (string, error)

func MoveOpsToNewPool

func MoveOpsToNewPool(cs string, oldPool *apool.APool, newPool *apool.APool) string

func OldLen

func OldLen(cs string) int

func OpsFromAText

func OpsFromAText(atext apool.AText) *[]Op

func Pack

func Pack(oldLen int, newLen int, opStr string, bank string) string

func SplitAttributionLines

func SplitAttributionLines(attrOps string, text string) ([]string, error)

func StringToAttrib

func StringToAttrib(attrib []string) (*apool.Attribute, error)

Types

type AttributeManager

type AttributeManager struct {
}

type AttributeMap

type AttributeMap struct {
	// contains filtered or unexported fields
}

func FromString

func FromString(s string, pool apool.APool) AttributeMap

func NewAttributeMap

func NewAttributeMap(pool *apool.APool) AttributeMap

func (*AttributeMap) Get

func (a *AttributeMap) Get(key string) string

func (*AttributeMap) Has

func (a *AttributeMap) Has(key string) bool

func (*AttributeMap) Set

func (a *AttributeMap) Set(key string, value string) *AttributeMap

func (*AttributeMap) Size

func (a *AttributeMap) Size() int

func (*AttributeMap) String

func (a *AttributeMap) String() string

func (*AttributeMap) Update

func (a *AttributeMap) Update(entries []apool.Attribute, emptyValueISDelete *bool) *AttributeMap

*

  • @param {Iterable<Attribute>} entries - [key, value] pairs to insert into this map.
  • @param {boolean} [emptyValueIsDelete] - If true and an entry's value is the empty string, the
  • key is removed from this map (if present).
  • @returns {AttributeMap} `this` (for chaining).

func (*AttributeMap) UpdateFromString

func (a *AttributeMap) UpdateFromString(key string, emptyValueIsDelete *bool) *AttributeMap

*

  • @param {AttributeString} str - The attribute string identifying the attributes to insert into
  • this map.
  • @param {boolean} [emptyValueIsDelete] - If true and an entry's value is the empty string, the
  • key is removed from this map (if present).
  • @returns {AttributeMap} `this` (for chaining).

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(oldLen int) Builder

func (Builder) Insert

func (b Builder) Insert(text string, attribs KeepArgs, pool *apool.APool) Builder

*

  • @param {string} text - Text to insert.
  • @param {(string|Attribute[])} attribs - Either [[key1,value1],[key2,value2],...] or '*0*1...'
  • (no pool needed in latter case).
  • @param {?AttributePool} pool - Attribute pool, only required if `attribs` is a list of
  • attribute key, value pairs.
  • @returns {Builder} this

func (Builder) Keep

func (b Builder) Keep(N int, L int, attribs KeepArgs, pool apool.APool) Builder

*

  • @param {number} N - Number of characters to keep.
  • @param {number} L - Number of newlines among the `N` characters. If positive, the last
  • character must be a newline.
  • @param {(string|Attribute[])} attribs - Either [[key1,value1],[key2,value2],...] or '*0*1...'
  • (no pool needed in latter case).
  • @param {?AttributePool} pool - Attribute pool, only required if `attribs` is a list of
  • attribute key, value pairs.
  • @returns {Builder} this

func (Builder) KeepText

func (b Builder) KeepText(text string, attribs KeepArgs, pool *apool.APool) Builder

*

  • @param {string} text - Text to keep.
  • @param {(string|Attribute[])} attribs - Either [[key1,value1],[key2,value2],...] or '*0*1...'
  • (no pool needed in latter case).
  • @param {?AttributePool} pool - Attribute pool, only required if `attribs` is a list of
  • attribute key, value pairs.
  • @returns {Builder} this

func (Builder) Remove

func (b Builder) Remove(N, L int) Builder

func (Builder) ToString

func (b Builder) ToString() string

type Changeset

type Changeset struct {
	OldLen   int
	NewLen   int
	Ops      string
	CharBank string
}

func Unpack

func Unpack(cs string) (*Changeset, error)

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

func (*Iterator[T]) Next

func (it *Iterator[T]) Next() (*T, bool)

Next returns the next element in the iterator and a boolean indicating if it's the last element

type KeepArgs

type KeepArgs struct {
	// contains filtered or unexported fields
}

type MergingOpAssembler

type MergingOpAssembler struct {
	// contains filtered or unexported fields
}

func NewMergingOpAssembler

func NewMergingOpAssembler() MergingOpAssembler

func (*MergingOpAssembler) Append

func (m *MergingOpAssembler) Append(op Op)

func (*MergingOpAssembler) Clear

func (m *MergingOpAssembler) Clear()

func (*MergingOpAssembler) EndDocument

func (m *MergingOpAssembler) EndDocument()

func (*MergingOpAssembler) String

func (m *MergingOpAssembler) String() string

type Op

type Op struct {
	OpCode  string
	Chars   int
	Lines   int
	Attribs string
}

func NewOp

func NewOp(opCode *string) Op

func OpsFromText

func OpsFromText(opcode string, text string, attribs interface{}, pool *apool.APool) []Op

func SlicerZipperFunc

func SlicerZipperFunc(attOp *Op, csOp *Op, pool *apool.APool) (*Op, error)

func (*Op) String

func (op *Op) String() string

type OpAssembler

type OpAssembler struct {
	// contains filtered or unexported fields
}

func NewOpAssembler

func NewOpAssembler() OpAssembler

func (*OpAssembler) Append

func (oa *OpAssembler) Append(op Op)

func (*OpAssembler) Clear

func (oa *OpAssembler) Clear()

func (*OpAssembler) String

func (oa *OpAssembler) String() string

type PrepareForWireStruct

type PrepareForWireStruct struct {
	Translated string
	Pool       apool.APool
}

func PrepareForWire

func PrepareForWire(cs string, pool apool.APool) PrepareForWireStruct

type SmartOpAssembler

type SmartOpAssembler struct {
	// contains filtered or unexported fields
}

func NewSmartOpAssembler

func NewSmartOpAssembler() *SmartOpAssembler

func (*SmartOpAssembler) Append

func (sm *SmartOpAssembler) Append(op Op)

func (*SmartOpAssembler) Clear

func (sm *SmartOpAssembler) Clear()

func (*SmartOpAssembler) EndDocument

func (sm *SmartOpAssembler) EndDocument()

func (*SmartOpAssembler) FlushKeeps

func (sm *SmartOpAssembler) FlushKeeps()

func (*SmartOpAssembler) LengthChange

func (sm *SmartOpAssembler) LengthChange() int

func (*SmartOpAssembler) String

func (sm *SmartOpAssembler) String() string

type StringAssembler

type StringAssembler struct {
	// contains filtered or unexported fields
}

func NewStringAssembler

func NewStringAssembler() StringAssembler

func (*StringAssembler) Append

func (sa *StringAssembler) Append(s string)

func (*StringAssembler) Clear

func (sa *StringAssembler) Clear()

func (*StringAssembler) String

func (sa *StringAssembler) String() string

type StringIterator

type StringIterator struct {
	// contains filtered or unexported fields
}

func NewStringIterator

func NewStringIterator(str string) StringIterator

func (*StringIterator) AssertRemaining

func (si *StringIterator) AssertRemaining(n int) error

func (*StringIterator) Peek

func (si *StringIterator) Peek(n int) string

func (*StringIterator) Remaining

func (si *StringIterator) Remaining() int

func (*StringIterator) Skip

func (si *StringIterator) Skip(n int) error

func (*StringIterator) Take

func (si *StringIterator) Take(n int) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL