From 8044edd041a5d607cc63a02978d132e2c79b07ed Mon Sep 17 00:00:00 2001 From: Hans Moog <hm@mkjc.net> Date: Thu, 1 Aug 2019 13:37:05 +0200 Subject: [PATCH] Fix: fixed crashing statusscreen + wrong indentation --- plugins/statusscreen/statusscreen.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 17f74843..362cf37e 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -58,6 +58,9 @@ func run(plugin *node.Plugin) { content := tview.NewGrid() content.SetBackgroundColor(tcell.ColorWhite) content.SetColumns(0) + content.SetBorders(false) + content.SetOffset(0, 0) + content.SetGap(0, 0) footer := newPrimitive("") footer.SetBackgroundColor(tcell.ColorDarkMagenta) @@ -88,8 +91,9 @@ func run(plugin *node.Plugin) { app.SetBeforeDrawFunc(func(screen tcell.Screen) bool { headerBar.Update() - rows := make([]int, 1) + rows := make([]int, 2) rows[0] = 1 + rows[1] = 1 _, _, _, height := content.GetRect() for i := 0; i < len(messageLog) && i < height-2; i++ { rows = append(rows, 1) @@ -102,12 +106,21 @@ func run(plugin *node.Plugin) { blankLine.SetBackgroundColor(tcell.ColorWhite) content.AddItem(blankLine, 0, 0, 1, 1, 0, 0, false) - for i, message := range messageLog[len(messageLog)-len(rows)-1+2:] { + logStart := len(messageLog) - (len(rows) - 2) + if logStart < 0 { + logStart = 0 + } + + for i, message := range messageLog[logStart:] { if i < height-2 { content.AddItem(NewUILogEntry(*message).Primitive, i+1, 0, 1, 1, 0, 0, false) } } + blankLine = newPrimitive("") + blankLine.SetBackgroundColor(tcell.ColorWhite) + content.AddItem(blankLine, height-1, 0, 1, 1, 0, 0, false) + return false }) -- GitLab