derailed 2020-08-01 10:14:22 -06:00
parent f4559a16cc
commit b1189acd14
11 changed files with 48 additions and 32 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.14
require (
github.com/atotto/clipboard v0.1.2
github.com/derailed/popeye v0.8.8
github.com/derailed/tview v0.4.0
github.com/derailed/tview v0.4.1
github.com/drone/envsubst v1.0.2 // indirect
github.com/fatih/color v1.9.0
github.com/fsnotify/fsnotify v1.4.7

View File

@ -126,11 +126,12 @@ type (
// Table tracks table styles.
Table struct {
FgColor Color `yaml:"fgColor"`
BgColor Color `yaml:"bgColor"`
CursorColor Color `yaml:"cursorColor"`
MarkColor Color `yaml:"markColor"`
Header TableHeader `yaml:"header"`
FgColor Color `yaml:"fgColor"`
BgColor Color `yaml:"bgColor"`
CursorFgColor Color `yaml:"cursorFgColor"`
CursorBgColor Color `yaml:"cursorBgColor"`
MarkColor Color `yaml:"markColor"`
Header TableHeader `yaml:"header"`
}
// TableHeader tracks table header styles.
@ -142,10 +143,11 @@ type (
// Xray tracks xray styles.
Xray struct {
FgColor Color `yaml:"fgColor"`
BgColor Color `yaml:"bgColor"`
CursorColor Color `yaml:"cursorColor"`
GraphicColor Color `yaml:"graphicColor"`
FgColor Color `yaml:"fgColor"`
BgColor Color `yaml:"bgColor"`
CursorColor Color `yaml:"cursorColor"`
CursorTextColor Color `yaml:"cursorTextColor"`
GraphicColor Color `yaml:"graphicColor"`
}
// Menu tracks menu styles.
@ -226,6 +228,7 @@ func newCharts() Charts {
},
}
}
func newViews() Views {
return Views{
Table: newTable(),
@ -309,20 +312,22 @@ func newInfo() Info {
func newXray() Xray {
return Xray{
FgColor: "aqua",
BgColor: "black",
CursorColor: "whitesmoke",
GraphicColor: "floralwhite",
FgColor: "aqua",
BgColor: "black",
CursorColor: "whitesmoke",
CursorTextColor: "black",
GraphicColor: "floralwhite",
}
}
func newTable() Table {
return Table{
FgColor: "aqua",
BgColor: "black",
CursorColor: "aqua",
MarkColor: "palegreen",
Header: newTableHeader(),
FgColor: "aqua",
BgColor: "black",
CursorFgColor: "black",
CursorBgColor: "aqua",
MarkColor: "palegreen",
Header: newTableHeader(),
}
}

View File

@ -13,6 +13,7 @@ type SelectTable struct {
model Tabular
selectedFn func(string) string
marks map[string]struct{}
fgColor tcell.Color
}
// SetModel sets the table model.
@ -115,7 +116,8 @@ func (s *SelectTable) selectionChanged(r, c int) {
return
}
cell := s.GetCell(r, c)
s.SetSelectedStyle(tcell.ColorBlack, cell.Color, tcell.AttrBold)
log.Debug().Msgf("COLOR %v:%v", s.fgColor, cell.Color)
s.SetSelectedStyle(s.fgColor, cell.Color, tcell.AttrBold)
}
// ClearMarks delete all marked items.
@ -143,8 +145,11 @@ func (s *SelectTable) ToggleMark() {
}
cell := s.GetCell(s.GetSelectedRowIndex(), 0)
if cell == nil {
return
}
s.SetSelectedStyle(
tcell.ColorBlack,
cell.BackgroundColor,
cell.Color,
tcell.AttrBold,
)
@ -193,7 +198,6 @@ func (s *SelectTable) markRange(prev, curr int) {
if prev > curr {
prev, curr = curr, prev
}
log.Debug().Msgf("Span Range %d::%d", prev, curr)
for i := prev + 1; i <= curr; i++ {
id, ok := s.GetRowID(i)
if !ok {
@ -205,7 +209,7 @@ func (s *SelectTable) markRange(prev, curr int) {
break
}
s.SetSelectedStyle(
tcell.ColorBlack,
cell.BackgroundColor,
cell.Color,
tcell.AttrBold,
)

View File

@ -98,10 +98,11 @@ func (t *Table) StylesChanged(s *config.Styles) {
t.SetBorderColor(s.Table().FgColor.Color())
t.SetBorderFocusColor(s.Frame().Border.FocusColor.Color())
t.SetSelectedStyle(
tcell.ColorBlack,
t.styles.Table().CursorColor.Color(),
t.styles.Table().CursorFgColor.Color(),
t.styles.Table().CursorBgColor.Color(),
tcell.AttrBold,
)
t.fgColor = s.Table().CursorFgColor.Color()
t.Refresh()
}

View File

@ -112,7 +112,7 @@ func (p *Pulse) Init(ctx context.Context) error {
func (p *Pulse) StylesChanged(s *config.Styles) {
p.SetBackgroundColor(s.Charts().BgColor.Color())
for _, c := range p.charts {
c.SetFocusColorNames(s.Table().BgColor.String(), s.Table().CursorColor.String())
c.SetFocusColorNames(s.Table().BgColor.String(), s.Table().CursorBgColor.String())
if c.IsDial() {
c.SetBackgroundColor(s.Charts().DialBgColor.Color())
c.SetSeriesColors(s.Charts().DefaultDialColors.Colors()...)

View File

@ -49,7 +49,8 @@ k9s:
table:
fgColor: *fg
bgColor: *bg
cursorColor: *fg
cursorBgColor: *fg
cursorFgColor: *bg
markColor: *mark
header:
fgColor: *dslate

View File

@ -68,7 +68,8 @@ k9s:
table:
fgColor: *foreground
bgColor: *background
cursorColor: *current_line
cursorFgColor: *foreground
cursorBgColor: *current_line
# Header row styles.
header:
fgColor: *foreground

View File

@ -57,7 +57,8 @@ k9s:
table:
fgColor: *fg
bgColor: *bg
cursorColor: *aqua
cursorFgColor: *fg
cursorBgColor: *aqua
markColor: *mslate
header:
fgColor: *fg

View File

@ -37,7 +37,8 @@ k9s:
table:
fgColor: default
bgColor: default
cursorColor: default
cursorFgColor: default
cursorBfColor: default
header:
fgColor: default
bgColor: default

View File

@ -45,7 +45,8 @@ k9s:
table:
fgColor: "#57c7ff"
bgColor: "#282a36"
cursorColor: "#5af78e"
cursorFgColor: "#57c7ff"
cursorBgColor: "#5af78e"
markColor: darkgoldenrod
header:
fgColor: white

View File

@ -45,7 +45,8 @@ k9s:
table:
fgColor: blue
bgColor: black
cursorColor: aqua
cursorFgColor: black
cursorBgColor: aqua
markColor: darkgoldenrod
header:
fgColor: white