Fine tuning for extensions

This commit is contained in:
Sean E. Russell 2020-04-28 12:04:35 -05:00
parent 285d4d0297
commit c2cb7a4304
3 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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