-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.go
117 lines (106 loc) · 3.13 KB
/
const.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package cdiff
import (
"fmt"
"github.com/gookit/color"
)
// DiffType is an option of Diff()
type DiffType int
const (
// LineByLine returns simple result
LineByLine DiffType = iota + 1
// WordByWord returns complex result that includes word by word diffs in line by line diffs
WordByWord
)
// Ope defines the operation of a diff item.
type Ope int8
func (o Ope) String() string {
switch o {
case Delete:
return "@Delete"
case Insert:
return "@Insert"
case Keep:
return "@Keep"
}
panic(fmt.Sprintf("unknown value of Ope: %d", int(o)))
}
const (
// Delete item represents a delete diff.
Delete Ope = -1
// Insert item represents an insert diff.
Insert Ope = 1
// Keep item represents an equal diff.
Keep Ope = 0
)
// Tag is for formatting text
type Tag int
const (
OpenDeletedLine Tag = iota + 1
CloseDeletedLine
OpenDeletedModified
CloseDeletedModified
OpenDeletedNotModified
CloseDeletedNotModified
OpenInsertedLine
CloseInsertedLine
OpenInsertedModified
CloseInsertedModified
OpenInsertedNotModified
CloseInsertedNotModified
OpenKeepLine
CloseKeepLine
OpenSection
CloseSection
OpenHeader
CloseHeader
)
// GooKitColorTag is a theme for Result.Format() method for coloring console
var GooKitColorTag = map[Tag]string{
OpenDeletedLine: "",
CloseDeletedLine: "\n",
OpenDeletedModified: "<fg=black;bg=red;>",
CloseDeletedModified: "</>",
OpenDeletedNotModified: "<red>",
CloseDeletedNotModified: "</>",
OpenInsertedLine: "",
CloseInsertedLine: "\n",
OpenInsertedModified: "<fg=black;bg=green;>",
CloseInsertedModified: "</>",
OpenInsertedNotModified: "<green>",
CloseInsertedNotModified: "</>",
OpenKeepLine: "",
CloseKeepLine: "\n",
OpenSection: "<cyan>",
CloseSection: "</>\n",
OpenHeader: "",
CloseHeader: "\n",
}
// GooKitColorTheme is a theme for Result.Format() method for coloring console
var GooKitColorTheme = map[Tag]color.Style{
OpenDeletedLine: nil,
OpenDeletedModified: color.New(color.FgBlack, color.BgRed),
OpenDeletedNotModified: color.New(color.Red),
OpenInsertedLine: nil,
OpenInsertedModified: color.New(color.FgBlack, color.BgGreen),
OpenInsertedNotModified: color.New(color.Green),
OpenKeepLine: nil,
OpenSection: color.New(color.Cyan),
OpenHeader: nil,
}
// HTMLTheme is a theme for Result.Format() method for generating HTML
var HTMLTag = map[Tag]string{
OpenDeletedLine: `<div style="background-color: #ffecec;">`,
CloseDeletedLine: `</div>`,
OpenDeletedModified: `<span style="background-color: #f8cbcb;">`,
CloseDeletedModified: `</span>`,
OpenDeletedNotModified: "",
CloseDeletedNotModified: "",
OpenInsertedLine: `<div style="background-color: #eaffea;">`,
CloseInsertedLine: `</div>`,
OpenInsertedModified: `<span style="background-color: #a6f3a6;">`,
CloseInsertedModified: `</span>`,
OpenInsertedNotModified: "",
CloseInsertedNotModified: "",
OpenKeepLine: `<div style="background-color: #ffffff;">`,
CloseKeepLine: "</div>",
}