Documentation
¶
Index ¶
- Variables
- func Diff(x, y string) string
- func Format(ts []*Token, theme Theme) string
- func LIS(x []int) []int
- 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 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) [][]int
- 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.Black, gop.BgGreen} case DelWords: return []gop.Style{gop.Black, gop.BgRed} case ChunkStart: return []gop.Style{gop.Black, gop.BgMagenta} } return []gop.Style{gop.None} }
ThemeDefault colors for Sprint
ThemeNone colors for Sprint
Functions ¶
func LIS ¶ added in v0.28.3
LIS returns the longest increasing subsequence of s. https://en.wikipedia.org/wiki/Longest_increasing_subsequence
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. https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
func (Sequence) Occurrence ¶ added in v0.28.3
Occurrence returns the position of each element of x in y.
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 )