Documentation
¶
Index ¶
- Variables
- func BTreeFindGreater(sorted []int, x int) (y int, found bool)
- func Diff(x, y string) string
- func Format(ts []*Token, theme Theme) string
- func Split(s string) []string
- func TokenizeLine(ctx context.Context, x, y string) ([]*Token, []*Token)
- func Words(ctx context.Context, lines []*TokenLine)
- type Comparable
- type Element
- type Histogram
- type Occurrence
- type Sequence
- func (x Sequence) Common(y Sequence) (left, right int)
- func (x Sequence) Histogram() Histogram
- func (x Sequence) IsSubsequenceOf(y Sequence) bool
- func (x Sequence) LCS(ctx context.Context, y Sequence) Sequence
- func (x Sequence) Occurrence(y Sequence) Occurrence
- func (x Sequence) Reduce(y Sequence) Sequence
- func (x Sequence) String() string
- type Theme
- type Token
- type TokenLine
- type Type
Constants ¶
This section is empty.
Variables ¶
var SplitKey = struct{}{}
SplitKey for context
var ThemeDefault = func(t Type) []gop.Style { switch t { case AddSymbol: return []gop.Style{gop.Green} case DelSymbol: return []gop.Style{gop.Red} case AddWords: return []gop.Style{gop.Green} case DelWords: return []gop.Style{gop.Red} case ChunkStart: return []gop.Style{gop.Black, gop.BgMagenta} } return []gop.Style{gop.None} }
ThemeDefault colors for Sprint
ThemeNone colors for Sprint
Functions ¶
func BTreeFindGreater ¶ added in v0.30.0
BTreeFindGreater y in sorted that is greater than x
func TokenizeLine ¶
TokenizeLine two different lines
Types ¶
type Comparable ¶
type Comparable interface {
// Hash for comparison
Hash() string
// String returns the full content
String() string
}
Comparable interface
type Element ¶ added in v0.28.3
type Element struct {
// contains filtered or unexported fields
}
Element of a line or a word
type Sequence ¶ added in v0.28.3
type Sequence []Comparable
Sequence list
func (Sequence) Common ¶ added in v0.28.3
Common returns the common prefix and suffix between x and y. This function scales down the problem via the first property: https://en.wikipedia.org/wiki/Longest_common_subsequence_problem#First_property
func (Sequence) IsSubsequenceOf ¶ added in v0.28.3
IsSubsequenceOf returns true if x is a subsequence of y
func (Sequence) LCS ¶ added in v0.28.3
LCS between x and y. This implementation converts the LCS problem into LIS sub problems without recursion. The memory complexity is O(x + y). The time complexity is similar with Myer's diff algorithm, but with more modularized steps, which allows further optimization easier, it doesn't use recursion, it's much easer to understand and implement. https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
func (Sequence) Occurrence ¶ added in v0.28.3
func (x Sequence) Occurrence(y Sequence) Occurrence
Occurrence returns the position of each element of y in x.
type Token ¶
Token presents a symbol in diff layout
func SpreadTokenLines ¶ added in v0.23.2
SpreadTokenLines to tokens
type TokenLine ¶ added in v0.23.2
TokenLine of tokens
func ParseTokenLines ¶ added in v0.23.2
ParseTokenLines of tokens
type Type ¶
type Type int
Type of token
const ( // Newline type Newline Type = iota // Space type Space // ChunkStart type ChunkStart // ChunkEnd type ChunkEnd // SameSymbol type SameSymbol // SameLine type SameLine // AddSymbol type AddSymbol // AddLine type AddLine // DelSymbol typ DelSymbol // DelLine type DelLine // SameWords type SameWords // AddWords type AddWords // DelWords type DelWords // EmptyLine type EmptyLine )