From e0165a228378dad026353736f433269307b88190 Mon Sep 17 00:00:00 2001 From: Quan Tong Date: Sat, 26 Mar 2022 15:08:44 +0700 Subject: [PATCH 1/2] Fixes test on darwin --- devices/temp_darwin_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devices/temp_darwin_test.go b/devices/temp_darwin_test.go index a7389bd..0301260 100644 --- a/devices/temp_darwin_test.go +++ b/devices/temp_darwin_test.go @@ -1,3 +1,4 @@ +//go:build darwin // +build darwin package devices @@ -5,13 +6,18 @@ package devices import ( "bytes" "encoding/csv" + "io" + "log" "testing" ) func Test_NumCols(t *testing.T) { parser := csv.NewReader(bytes.NewReader(smcData)) parser.Comma = '\t' - var line []string + var ( + line []string + err error + ) for { if line, err = parser.Read(); err == io.EOF { break @@ -23,7 +29,7 @@ func Test_NumCols(t *testing.T) { // The line is malformed if len(line) != 2, but because the asset is static // it makes no sense to report the error to downstream users. This must be // tested at/around compile time. - if len(line) == 2 { + if len(line) != 2 { t.Errorf("smc CSV data malformed: expected 2 columns, got %d", len(line)) } } From 3f903c796c26f17bfd7ee1129b94863fcb38ddfd Mon Sep 17 00:00:00 2001 From: Quan Tong Date: Sat, 26 Mar 2022 15:09:34 +0700 Subject: [PATCH 2/2] Fixes #174: different colors for download/upload --- cmd/gotop/description.txt | 2 +- colorschemes/default.go | 2 +- colorschemes/default.json | 2 +- colorschemes/default_dark.go | 2 +- colorschemes/monokai.go | 2 +- colorschemes/nord.go | 2 +- colorschemes/solarized.go | 2 +- colorschemes/solarized16_dark.go | 2 +- colorschemes/solarized16_light.go | 2 +- colorschemes/template.go | 4 ++-- colorschemes/vice.go | 2 +- layout/layout.go | 5 +++-- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cmd/gotop/description.txt b/cmd/gotop/description.txt index eb038eb..63ceff7 100644 --- a/cmd/gotop/description.txt +++ b/cmd/gotop/description.txt @@ -20,7 +20,7 @@ The keys are: BattLines -- array of ints for the colors of lines MemLines -- array of ints for the colors of lines ProcCursor -- int, color of the cursor in the process widget - Sparkline -- int, color of the graph bars + Sparklines -- array of ints for the colors of network usage DiskBar -- int, color of the disk bars TempLow -- int, color used for low temperatures TempHigh -- int, color used for high temperatures diff --git a/colorschemes/default.go b/colorschemes/default.go index 90ac3fa..10e9fcd 100644 --- a/colorschemes/default.go +++ b/colorschemes/default.go @@ -16,7 +16,7 @@ func init() { ProcCursor: 4, - Sparkline: 4, + Sparklines: [2]int{4, 5}, DiskBar: 7, diff --git a/colorschemes/default.json b/colorschemes/default.json index d6b3dc5..ec60e8e 100644 --- a/colorschemes/default.json +++ b/colorschemes/default.json @@ -15,7 +15,7 @@ "ProcCursor": 4, - "Sparkline": 4, + "Sparklines": [4, 5], "DiskBar": 7, diff --git a/colorschemes/default_dark.go b/colorschemes/default_dark.go index 7f7911c..72a2d05 100644 --- a/colorschemes/default_dark.go +++ b/colorschemes/default_dark.go @@ -16,7 +16,7 @@ func init() { ProcCursor: 33, - Sparkline: 4, + Sparklines: [2]int{4, 5}, DiskBar: 252, diff --git a/colorschemes/monokai.go b/colorschemes/monokai.go index d09f3c9..989234c 100644 --- a/colorschemes/monokai.go +++ b/colorschemes/monokai.go @@ -16,7 +16,7 @@ func init() { ProcCursor: 197, - Sparkline: 81, + Sparklines: [2]int{81, 186}, DiskBar: 102, diff --git a/colorschemes/nord.go b/colorschemes/nord.go index 028057e..47059d6 100644 --- a/colorschemes/nord.go +++ b/colorschemes/nord.go @@ -29,7 +29,7 @@ func init() { ProcCursor: 31, // blue (nord9) - Sparkline: 31, + Sparklines: [2]int{31, 96}, DiskBar: 254, diff --git a/colorschemes/solarized.go b/colorschemes/solarized.go index 4649d93..90589e4 100644 --- a/colorschemes/solarized.go +++ b/colorschemes/solarized.go @@ -19,7 +19,7 @@ func init() { ProcCursor: 136, - Sparkline: 33, + Sparklines: [2]int{33, 136}, DiskBar: 243, diff --git a/colorschemes/solarized16_dark.go b/colorschemes/solarized16_dark.go index 00c7eb6..1977ae2 100644 --- a/colorschemes/solarized16_dark.go +++ b/colorschemes/solarized16_dark.go @@ -18,7 +18,7 @@ func init() { ProcCursor: 4, - Sparkline: 4, + Sparklines: [2]int{4, 5}, DiskBar: 12, // base0 diff --git a/colorschemes/solarized16_light.go b/colorschemes/solarized16_light.go index b4157d9..b912a06 100644 --- a/colorschemes/solarized16_light.go +++ b/colorschemes/solarized16_light.go @@ -18,7 +18,7 @@ func init() { ProcCursor: 4, - Sparkline: 4, + Sparklines: [2]int{4, 5}, DiskBar: 11, // base00 diff --git a/colorschemes/template.go b/colorschemes/template.go index 514a063..b2a0b3f 100644 --- a/colorschemes/template.go +++ b/colorschemes/template.go @@ -52,8 +52,8 @@ type Colorscheme struct { // ProcCursor is used as the color for the color bar in the process widget ProcCursor int - // SparkLine determines the color of the data line in spark graphs - Sparkline int + // SparkLines define the colors used for the Network usage graphs + Sparklines [2]int // DiskBar is the color of the disk gauge bars (currently unused, // as there's no disk gauge widget) diff --git a/colorschemes/vice.go b/colorschemes/vice.go index d0dbb03..f5e42e2 100644 --- a/colorschemes/vice.go +++ b/colorschemes/vice.go @@ -16,7 +16,7 @@ func init() { ProcCursor: 159, - Sparkline: 183, + Sparklines: [2]int{183, 146}, DiskBar: 158, diff --git a/layout/layout.go b/layout/layout.go index 6ae2612..8855aa7 100644 --- a/layout/layout.go +++ b/layout/layout.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/xxxserxxx/lingo/v2" + "github.com/xxxserxxx/gotop/v4" "github.com/xxxserxxx/gotop/v4/widgets" @@ -186,9 +187,9 @@ func makeWidget(c gotop.Config, widRule widgetRule) interface{} { w = t case "net": n := widgets.NewNetWidget(c.NetInterface) - n.Lines[0].LineColor = ui.Color(c.Colorscheme.Sparkline) + n.Lines[0].LineColor = ui.Color(c.Colorscheme.Sparklines[0]) n.Lines[0].TitleColor = ui.Color(c.Colorscheme.BorderLabel) - n.Lines[1].LineColor = ui.Color(c.Colorscheme.Sparkline) + n.Lines[1].LineColor = ui.Color(c.Colorscheme.Sparklines[1]) n.Lines[1].TitleColor = ui.Color(c.Colorscheme.BorderLabel) n.Mbps = c.Mbps w = n