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 ( require (
github.com/atotto/clipboard v0.1.2 github.com/atotto/clipboard v0.1.2
github.com/derailed/popeye v0.8.8 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/drone/envsubst v1.0.2 // indirect
github.com/fatih/color v1.9.0 github.com/fatih/color v1.9.0
github.com/fsnotify/fsnotify v1.4.7 github.com/fsnotify/fsnotify v1.4.7

View File

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

View File

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

View File

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

View File

@ -112,7 +112,7 @@ func (p *Pulse) Init(ctx context.Context) error {
func (p *Pulse) StylesChanged(s *config.Styles) { func (p *Pulse) StylesChanged(s *config.Styles) {
p.SetBackgroundColor(s.Charts().BgColor.Color()) p.SetBackgroundColor(s.Charts().BgColor.Color())
for _, c := range p.charts { 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() { if c.IsDial() {
c.SetBackgroundColor(s.Charts().DialBgColor.Color()) c.SetBackgroundColor(s.Charts().DialBgColor.Color())
c.SetSeriesColors(s.Charts().DefaultDialColors.Colors()...) c.SetSeriesColors(s.Charts().DefaultDialColors.Colors()...)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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