Documentation
¶
Index ¶
- Variables
- func ChunkWords(ctx context.Context, lines []*TokenLine)
- func Diff(x, y string) string
- func Format(ts []*Token, theme Theme) string
- func TokenizeLine(ctx context.Context, x, y string) ([]*Token, []*Token)
- type Char
- type Comparable
- type Comparables
- type Line
- type Theme
- type Token
- type TokenLine
- type Type
Constants ¶
This section is empty.
Variables ¶
var ThemeDefault = func(t Type) []gop.Style { switch t { case AddSymbol, AddWords: return []gop.Style{gop.BgGreen} case DelSymbol, DelWords: return []gop.Style{gop.BgRed} case ChunkStart: return []gop.Style{gop.BgMagenta} } return []gop.Style{gop.None} }
ThemeDefault colors for Sprint
ThemeNone colors for Sprint
Functions ¶
func ChunkWords ¶ added in v0.23.2
ChunkWords with words
Types ¶
type Comparable ¶
type Comparable interface {
// Hash for fast comparison
Hash() string
// String returns the full content
String() string
}
Comparable interface
type Comparables ¶ added in v0.25.0
type Comparables []Comparable
Comparables list
func NewText ¶
func NewText(s string) Comparables
NewText from string. It will split the s via newlines.
func (Comparables) Common ¶ added in v0.25.0
func (x Comparables) Common(y Comparables) (left, right int)
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 (Comparables) Histogram ¶ added in v0.25.0
func (x Comparables) Histogram() map[string]int
Histogram of each Comparable
func (Comparables) LCS ¶ added in v0.25.0
func (x Comparables) LCS(ctx context.Context, y Comparables) Comparables
LCS extends the standard lcs algorithm with dynamic programming and recursive line-reduction. The base algorithm we use is here: https://en.wikipedia.org/wiki/Longest_common_subsequence_problem#LCS_function_defined. TODO: implement Patience Diff http://alfedenzo.livejournal.com/170301.html
func (Comparables) Reduce ¶ added in v0.25.0
func (x Comparables) Reduce(y Comparables) Comparables
Reduce Comparables from x that doesn't exist in y
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line of a string for fast comparison.
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 )