-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.go
53 lines (41 loc) · 1009 Bytes
/
color.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
package render
import (
"github.com/gdamore/tcell/v2"
)
var (
// ModColor row modified color.
ModColor tcell.Color
// AddColor row added color.
AddColor tcell.Color
// PendingColor row added color.
PendingColor tcell.Color
// ErrColor row err color.
ErrColor tcell.Color
// StdColor row default color.
StdColor tcell.Color
// HighlightColor row highlight color.
HighlightColor tcell.Color
// KillColor row deleted color.
KillColor tcell.Color
// CompletedColor row completed color.
CompletedColor tcell.Color
)
// ColorerFunc represents a resource row colorer.
type ColorerFunc func(ns string, h Header, re RowEvent) tcell.Color
// DefaultColorer set the default table row colors.
func DefaultColorer(ns string, h Header, re RowEvent) tcell.Color {
if !Happy(ns, h, re.Row) {
return ErrColor
}
// nolint:exhaustive
switch re.Kind {
case EventAdd:
return AddColor
case EventUpdate:
return ModColor
case EventDelete:
return KillColor
default:
return StdColor
}
}