Documentation
¶
Index ¶
- Variables
- func ApplyToAText(cs string, atext apool.AText, pool apool.APool) (*apool.AText, error)
- func ApplyToAttribution(cs string, astr string, pool apool.APool) (*string, error)
- func ApplyToText(cs string, text string) (*string, error)
- func ApplyZip(in1 string, in2 string, callback func(*Op, *Op) (*Op, error)) (*string, error)
- func AttribsFromString(str string, pool apool.APool) []apool.Attribute
- func AttribsToString(attribs []apool.Attribute, pool *apool.APool) (*string, error)
- func AttributeTester(attribPair apool.Attribute, pool *apool.APool) func(arg *string) bool
- func CheckRep(cs string) (*string, error)
- func CloneAText(atext apool.AText) apool.AText
- func Compose(cs1 string, cs2 string, pool *apool.APool) (*string, error)
- func ComposeAttributes(attribs1 string, attribs2 string, resultIsMutation bool, pool *apool.APool) string
- func DecodeAttribString(s string) ([]int, error)
- func DeserializeOps(ops string) (*[]Op, error)
- func Follow(c string, rebasedChangeset string, reverseInsertOrder bool, pool *apool.APool) (*string, error)
- func HasAttrib(attribs *AttributeMap) bool
- func Identity(n int) string
- func Inverse(cs string, lines []string, alines []string, pool *apool.APool) (*string, error)
- func JoinAttributionLines(theAlines []string) string
- func MakeAText(str string, attribs *string) apool.AText
- func MakeAttribution(text string) string
- func MakeSplice(orig string, start int, ndel int, ins string, attribs *string, ...) (string, error)
- func MoveOpsToNewPool(cs string, oldPool *apool.APool, newPool *apool.APool) string
- func MutateAttributionLines(cs string, lines *[]string, pool *apool.APool) error
- func MutateTextLines(cs string, lines *[]string) error
- func OldLen(cs string) (*int, error)
- func OpsFromAText(atext apool.AText) *[]Op
- func Pack(oldLen int, newLen int, opStr string, bank string) string
- func RandomTestChangeset(origText string, withAttribs bool) (string, string)
- func SplitAttributionLines(attrOps string, text string) ([]string, error)
- func SplitTextLines(text string) []string
- func StringToAttrib(attrib []string) (*apool.Attribute, error)
- func Subattribution(astr string, start int, optEnd *int) (*string, error)
- type AttributeManager
- type AttributeMap
- func (a *AttributeMap) Get(key string) *string
- func (a *AttributeMap) Has(key string) bool
- func (a *AttributeMap) Iter() map[string]string
- func (a *AttributeMap) Set(key string, value string) *AttributeMap
- func (a *AttributeMap) Size() int
- func (a *AttributeMap) String() string
- func (a *AttributeMap) Update(entries []apool.Attribute, emptyValueISDelete *bool) *AttributeMap
- func (a *AttributeMap) UpdateFromString(key string, emptyValueIsDelete *bool) *AttributeMap
- type Builder
- func (b *Builder) Insert(text string, attribs KeepArgs, pool *apool.APool) *Builder
- func (b *Builder) Keep(N int, L int, attribs KeepArgs, pool *apool.APool) *Builder
- func (b *Builder) KeepText(text string, attribs *KeepArgs, pool *apool.APool) *Builder
- func (b *Builder) Remove(N, L int) *Builder
- func (b *Builder) ToString() string
- type Changeset
- type Iterator
- type KeepArgs
- type MergingOpAssembler
- type Op
- type OpAssembler
- type PrepareForWireStruct
- type SmartOpAssembler
- type StringAssembler
- type StringIterator
- type TextLinesMutator
- func (m *TextLinesMutator) Close()
- func (m *TextLinesMutator) GetLines() []string
- func (m *TextLinesMutator) HasMore() bool
- func (m *TextLinesMutator) Insert(text string, L int) error
- func (m *TextLinesMutator) Remove(N, L int) string
- func (m *TextLinesMutator) RemoveLines(L int) string
- func (m *TextLinesMutator) Skip(N, L int, includeInSplice bool)
- func (m *TextLinesMutator) SkipLines(L int, includeInSplice bool)
Constants ¶
This section is empty.
Variables ¶
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
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 ApplyToAttribution ¶
func AttribsToString ¶
func AttributeTester ¶
func ComposeAttributes ¶
func DecodeAttribString ¶
func DeserializeOps ¶
func HasAttrib ¶
func HasAttrib(attribs *AttributeMap) bool
func JoinAttributionLines ¶
func MakeAttribution ¶
func MakeSplice ¶
func MoveOpsToNewPool ¶
func MutateAttributionLines ¶ added in v0.0.2
func MutateTextLines ¶ added in v0.0.2
func OpsFromAText ¶
func RandomTestChangeset ¶ added in v0.0.2
func SplitAttributionLines ¶
func SplitTextLines ¶ added in v0.0.2
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) Iter ¶ added in v0.0.2
func (a *AttributeMap) Iter() map[string]string
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 (*Builder) Insert ¶
*
- @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 ¶
*
- @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 ¶
*
- @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
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 ¶
func OpsFromText ¶
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 ¶
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) Remaining ¶
func (si *StringIterator) Remaining() int
func (*StringIterator) Skip ¶
func (si *StringIterator) Skip(n int) error
type TextLinesMutator ¶ added in v0.0.2
type TextLinesMutator struct {
// contains filtered or unexported fields
}
TextLinesMutator is a class to iterate and modify texts which have several lines. It is used for applying Changesets on arrays of lines.
Mutation operations have the same constraints as exports operations with respect to newlines, but not the other additional constraints (i.e. ins/del ordering, forbidden no-ops, non-mergeability, final newline). Can be used to mutate lists of strings where the last char of each string is not actually a newline, but for the purposes of N and L values, the caller should pretend it is, and for things to work right in that case, the input to the Insert method should be a single line with no newlines.
func NewTextLinesMutator ¶ added in v0.0.2
func NewTextLinesMutator(lines *[]string) *TextLinesMutator
NewTextLinesMutator creates a new TextLinesMutator with the given lines. Lines are mutated in place.
func (*TextLinesMutator) Close ¶ added in v0.0.2
func (m *TextLinesMutator) Close()
Close closes the splice.
func (*TextLinesMutator) GetLines ¶ added in v0.0.2
func (m *TextLinesMutator) GetLines() []string
GetLines returns the current state of the lines.
func (*TextLinesMutator) HasMore ¶ added in v0.0.2
func (m *TextLinesMutator) HasMore() bool
HasMore checks if curLine (the line we are in when curSplice is applied) is the last line in lines. Returns true if there are lines left.
func (*TextLinesMutator) Insert ¶ added in v0.0.2
func (m *TextLinesMutator) Insert(text string, L int) error
Insert inserts text into lines array.
func (*TextLinesMutator) Remove ¶ added in v0.0.2
func (m *TextLinesMutator) Remove(N, L int) string
Remove removes text from lines array.
func (*TextLinesMutator) RemoveLines ¶ added in v0.0.2
func (m *TextLinesMutator) RemoveLines(L int) string
RemoveLines removes whole lines from lines array.
func (*TextLinesMutator) Skip ¶ added in v0.0.2
func (m *TextLinesMutator) Skip(N, L int, includeInSplice bool)
Skip skips some characters. Can contain newlines.
func (*TextLinesMutator) SkipLines ¶ added in v0.0.2
func (m *TextLinesMutator) SkipLines(L int, includeInSplice bool)
SkipLines skips some newlines by putting them into the splice.