summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-04-28 12:04:35 -0500
committerSean E. Russell <ser@ser1.net>2020-04-28 12:04:35 -0500
commitc2cb7a4304e2e1bfc3dcd819346fb4cb611fe08f (patch)
tree57151e03cd953cce23bbb658bb1df5cd93507f3b
parent285d4d02972e5d3e52efa6554fcbb08b42577f7c (diff)
Fine tuning for extensions
-rw-r--r--cmd/gotop/main.go16
-rw-r--r--devices/devices.go5
-rw-r--r--termui/linegraph.go1
3 files changed, 14 insertions, 8 deletions
diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go
index 291179f..40b304c 100644
--- a/cmd/gotop/main.go
+++ b/cmd/gotop/main.go
@@ -335,6 +335,7 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) {
// TODO: Abstract out the UI toolkit. mum4k/termdash, VladimirMarkelov/clui, gcla/gowid, rivo/tview, marcusolsson/tui-go might work better for some OS/Archs. Performance/memory use comparison would be interesting.
// TODO: all of the go vet stuff, more unit tests, benchmarks, finish remote.
// TODO: color bars for memory, a-la bashtop
+// TODO: add verbose debugging option
func main() {
// For performance testing
//go func() {
@@ -376,6 +377,14 @@ func run() int {
}
defer logfile.Close()
+ errs := devices.Startup(conf.ExtensionVars)
+ if len(errs) > 0 {
+ for _, err := range errs {
+ stderrLogger.Print(err)
+ }
+ return 1
+ }
+
lstream, err := getLayout(conf)
if err != nil {
stderrLogger.Print(err)
@@ -387,13 +396,6 @@ func run() int {
return runTests(conf)
}
- errs := devices.Startup(conf.ExtensionVars)
- if len(errs) > 0 {
- for _, err := range errs {
- stderrLogger.Print(err)
- }
- return 1
- }
if err = ui.Init(); err != nil {
stderrLogger.Print(err)
return 1
diff --git a/devices/devices.go b/devices/devices.go
index a804fab..c3cad42 100644
--- a/devices/devices.go
+++ b/devices/devices.go
@@ -30,7 +30,10 @@ func RegisterStartup(f func(vars map[string]string) error) {
_startup = append(_startup, f)
}
-// Called after configuration has been parsed
+// Startup is after configuration has been parsed, and provides extensions with
+// any configuration data provided by the user. An extension's registered
+// startup function should process and populate data at least once so that the
+// widgets have a full list of sensors, for (e.g.) setting up colors.
func Startup(vars map[string]string) []error {
rv := make([]error, 0)
for _, f := range _startup {
diff --git a/termui/linegraph.go b/termui/linegraph.go
index fd50520..55aacbd 100644
--- a/termui/linegraph.go
+++ b/termui/linegraph.go
@@ -61,6 +61,7 @@ func (self *LineGraph) Draw(buf *Buffer) {
seriesLineColor, ok := self.LineColors[seriesName]
if !ok {
seriesLineColor = self.DefaultLineColor
+ self.LineColors[seriesName] = seriesLineColor
}
// coordinates of last point