1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Renormalize the redraw function

Have all instances take a function
Update the remaining modules to take this into account
Numerous smaller refactors to make some widgets work more or less the same
This commit is contained in:
Sean Smith
2019-08-27 21:51:37 -04:00
parent 67658e172c
commit 14e7619075
53 changed files with 209 additions and 182 deletions

View File

@@ -34,18 +34,17 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
// Refresh updates the onscreen contents of the widget
func (widget *Widget) Refresh() {
if log.LogFileMissing() {
return
}
logLines := widget.tailFile()
widget.Redraw(widget.CommonSettings().Title, widget.contentFrom(logLines), false)
widget.Redraw(widget.content)
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) contentFrom(logLines []string) string {
func (widget *Widget) content() (string, string, bool) {
if log.LogFileMissing() {
return widget.CommonSettings().Title, "File missing", false
}
logLines := widget.tailFile()
str := ""
for _, line := range logLines {
@@ -61,7 +60,7 @@ func (widget *Widget) contentFrom(logLines []string) string {
}
}
return str
return widget.CommonSettings().Title, str, false
}
func (widget *Widget) tailFile() []string {