diff --git a/go.mod b/go.mod index b7563da0..3e0090ad 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/internal/config/styles.go b/internal/config/styles.go index 78841dfe..0c1ef12f 100644 --- a/internal/config/styles.go +++ b/internal/config/styles.go @@ -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(), } } diff --git a/internal/ui/select_table.go b/internal/ui/select_table.go index 87451a90..1166a05a 100644 --- a/internal/ui/select_table.go +++ b/internal/ui/select_table.go @@ -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, ) diff --git a/internal/ui/table.go b/internal/ui/table.go index 62d83f32..4de4adf4 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -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() } diff --git a/internal/view/pulse.go b/internal/view/pulse.go index 0ea2f72a..8bf2c7b8 100644 --- a/internal/view/pulse.go +++ b/internal/view/pulse.go @@ -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()...) diff --git a/skins/black_and_wtf.yml b/skins/black_and_wtf.yml index 514d7f5e..037b5b5a 100644 --- a/skins/black_and_wtf.yml +++ b/skins/black_and_wtf.yml @@ -49,7 +49,8 @@ k9s: table: fgColor: *fg bgColor: *bg - cursorColor: *fg + cursorBgColor: *fg + cursorFgColor: *bg markColor: *mark header: fgColor: *dslate diff --git a/skins/dracula.yml b/skins/dracula.yml index a48ae42a..0840efe3 100644 --- a/skins/dracula.yml +++ b/skins/dracula.yml @@ -68,7 +68,8 @@ k9s: table: fgColor: *foreground bgColor: *background - cursorColor: *current_line + cursorFgColor: *foreground + cursorBgColor: *current_line # Header row styles. header: fgColor: *foreground diff --git a/skins/in_the_navy.yml b/skins/in_the_navy.yml index 64b882f7..b2e97e92 100644 --- a/skins/in_the_navy.yml +++ b/skins/in_the_navy.yml @@ -57,7 +57,8 @@ k9s: table: fgColor: *fg bgColor: *bg - cursorColor: *aqua + cursorFgColor: *fg + cursorBgColor: *aqua markColor: *mslate header: fgColor: *fg diff --git a/skins/kiss.yml b/skins/kiss.yml index da7d4f31..048ffce7 100644 --- a/skins/kiss.yml +++ b/skins/kiss.yml @@ -37,7 +37,8 @@ k9s: table: fgColor: default bgColor: default - cursorColor: default + cursorFgColor: default + cursorBfColor: default header: fgColor: default bgColor: default diff --git a/skins/snazzy.yml b/skins/snazzy.yml index abf11ad7..8f7ce9ce 100644 --- a/skins/snazzy.yml +++ b/skins/snazzy.yml @@ -45,7 +45,8 @@ k9s: table: fgColor: "#57c7ff" bgColor: "#282a36" - cursorColor: "#5af78e" + cursorFgColor: "#57c7ff" + cursorBgColor: "#5af78e" markColor: darkgoldenrod header: fgColor: white diff --git a/skins/stock.yml b/skins/stock.yml index e3c9250b..aaf96d68 100644 --- a/skins/stock.yml +++ b/skins/stock.yml @@ -45,7 +45,8 @@ k9s: table: fgColor: blue bgColor: black - cursorColor: aqua + cursorFgColor: black + cursorBgColor: aqua markColor: darkgoldenrod header: fgColor: white