Documentation
¶
Index ¶
- Constants
- Variables
- func Diff(oldName, old, newName, new string, num_of_context_lines int) []byte
- func EntryPoint(parent *cli.Command)
- type AsyncResult
- type Center
- type Chunk
- type Collection
- type DiffData
- type HalfScreenLine
- type Handler
- type Hunk
- type KittyOpts
- type LineType
- type LogicalLine
- type LogicalLines
- func (self *LogicalLines) At(i int) *LogicalLine
- func (self *LogicalLines) IncrementScrollPosBy(pos *ScrollPos, amt int) (delta int)
- func (self *LogicalLines) Len() int
- func (self *LogicalLines) Minus(a, b ScrollPos) (delta int)
- func (self *LogicalLines) NumScreenLinesTo(a ScrollPos) (ans int)
- func (self *LogicalLines) ScreenLineAt(pos ScrollPos) *ScreenLine
- type Patch
- type Reference
- type ResultType
- type ScreenLine
- type ScrollPos
- type Search
- type Span
Constants ¶
const DIFF_DIFF = `diff -p -U _CONTEXT_ --`
const GIT_DIFF = `git diff --no-color --no-ext-diff --exit-code -U_CONTEXT_ --no-index --`
Variables ¶
var DefaultStyle = sync.OnceValue(func() *chroma.Style { return styles.Register(chroma.MustNewStyle("default", chroma.StyleEntries{ chroma.TextWhitespace: "#bbbbbb", chroma.Comment: "italic #3D7B7B", chroma.CommentPreproc: "noitalic #9C6500", chroma.Keyword: "bold #008000", chroma.KeywordPseudo: "nobold", chroma.KeywordType: "nobold #B00040", chroma.Operator: "#666666", chroma.OperatorWord: "bold #AA22FF", chroma.NameBuiltin: "#008000", chroma.NameFunction: "#0000FF", chroma.NameClass: "bold #0000FF", chroma.NameNamespace: "bold #0000FF", chroma.NameException: "bold #CB3F38", chroma.NameVariable: "#19177C", chroma.NameConstant: "#880000", chroma.NameLabel: "#767600", chroma.NameEntity: "bold #717171", chroma.NameAttribute: "#687822", chroma.NameTag: "bold #008000", chroma.NameDecorator: "#AA22FF", chroma.LiteralString: "#BA2121", chroma.LiteralStringDoc: "italic", chroma.LiteralStringInterpol: "bold #A45A77", chroma.LiteralStringEscape: "bold #AA5D1F", chroma.LiteralStringRegex: "#A45A77", chroma.LiteralStringSymbol: "#19177C", chroma.LiteralStringOther: "#008000", chroma.LiteralNumber: "#666666", chroma.GenericHeading: "bold #000080", chroma.GenericSubheading: "bold #800080", chroma.GenericDeleted: "#A00000", chroma.GenericInserted: "#008400", chroma.GenericError: "#E40000", chroma.GenericEmph: "italic", chroma.GenericStrong: "bold", chroma.GenericPrompt: "bold #000080", chroma.GenericOutput: "#717171", chroma.GenericTraceback: "#04D", chroma.Error: "border:#FF0000", chroma.Background: " bg:#f8f8f8", })) })
var ErrNoLexer = errors.New("No lexer available for this format")
Functions ¶
func Diff ¶
Diff returns an anchored diff of the two texts old and new in the “unified diff” format. If old and new are identical, Diff returns a nil slice (no output).
Unix diff implementations typically look for a diff with the smallest number of lines inserted and removed, which can in the worst case take time quadratic in the number of lines in the texts. As a result, many implementations either can be made to run for a long time or cut off the search after a predetermined amount of work.
In contrast, this implementation looks for a diff with the smallest number of “unique” lines inserted and removed, where unique means a line that appears just once in both old and new. We call this an “anchored diff” because the unique lines anchor the chosen matching regions. An anchored diff is usually clearer than a standard diff, because the algorithm does not try to reuse unrelated blank lines or closing braces. The algorithm also guarantees to run in O(n log n) time instead of the standard O(n²) time.
Some systems call this approach a “patience diff,” named for the “patience sorting” algorithm, itself named for a solitaire card game. We avoid that name for two reasons. First, the name has been used for a few different variants of the algorithm, so it is imprecise. Second, the name is frequently interpreted as meaning that you have to wait longer (to be patient) for the diff, meaning that it is a slower algorithm, when in fact the algorithm is faster than the standard one.
func EntryPoint ¶
Types ¶
type AsyncResult ¶
type AsyncResult struct {
// contains filtered or unexported fields
}
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) Apply ¶
func (self *Collection) Apply(f func(path, typ, changed_path string) error) error
func (*Collection) Items ¶
func (self *Collection) Items() int
func (*Collection) Len ¶
func (self *Collection) Len() int
type HalfScreenLine ¶
type HalfScreenLine struct {
// contains filtered or unexported fields
}
type LogicalLine ¶
type LogicalLine struct {
// contains filtered or unexported fields
}
func (*LogicalLine) IncrementScrollPosBy ¶
func (self *LogicalLine) IncrementScrollPosBy(pos *ScrollPos, amt int) (delta int)
type LogicalLines ¶
type LogicalLines struct {
// contains filtered or unexported fields
}
func (*LogicalLines) At ¶
func (self *LogicalLines) At(i int) *LogicalLine
func (*LogicalLines) IncrementScrollPosBy ¶
func (self *LogicalLines) IncrementScrollPosBy(pos *ScrollPos, amt int) (delta int)
func (*LogicalLines) Len ¶
func (self *LogicalLines) Len() int
func (*LogicalLines) Minus ¶
func (self *LogicalLines) Minus(a, b ScrollPos) (delta int)
a - b in terms of number of screen lines between the positions
func (*LogicalLines) NumScreenLinesTo ¶
func (self *LogicalLines) NumScreenLinesTo(a ScrollPos) (ans int)
func (*LogicalLines) ScreenLineAt ¶
func (self *LogicalLines) ScreenLineAt(pos ScrollPos) *ScreenLine
type ResultType ¶
type ResultType int
const ( COLLECTION ResultType = iota DIFF HIGHLIGHT IMAGE_LOAD IMAGE_RESIZE )
type ScreenLine ¶
type ScreenLine struct {
// contains filtered or unexported fields
}