diff --git a/modules/gerrit/display.go b/modules/gerrit/display.go index c09226c1..e7ba5161 100644 --- a/modules/gerrit/display.go +++ b/modules/gerrit/display.go @@ -5,11 +5,14 @@ import ( ) func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { project := widget.currentGerritProject() if project == nil { - widget.Redraw(widget.CommonSettings().Title, "Gerrit project data is unavailable", true) - return + return widget.CommonSettings().Title, "Gerrit project data is unavailable", true } title := fmt.Sprintf("%s- %s", widget.CommonSettings().Title, widget.title(project)) @@ -25,7 +28,7 @@ func (widget *Widget) display() { str += " [red]My Outgoing Reviews[white]\n" str += widget.displayMyOutgoingReviews(project, widget.settings.username) - widget.Redraw(title, str, false) + return title, str, false } func (widget *Widget) displayMyIncomingReviews(project *GerritProject, username string) string { diff --git a/modules/git/display.go b/modules/git/display.go index 263f1f3d..f7d9a30e 100644 --- a/modules/git/display.go +++ b/modules/git/display.go @@ -7,10 +7,13 @@ import ( ) func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { repoData := widget.currentData() if repoData == nil { - widget.Redraw(widget.CommonSettings().Title, " Git repo data is unavailable ", false) - return + return widget.CommonSettings().Title, " Git repo data is unavailable ", false } title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings().Title, repoData.Repository) @@ -24,7 +27,7 @@ func (widget *Widget) display() { str += "\n" str += widget.formatCommits(repoData.Commits) - widget.Redraw(title, str, false) + return title, str, false } func (widget *Widget) formatChanges(data []string) string { diff --git a/modules/github/display.go b/modules/github/display.go index 3fd10508..94634648 100644 --- a/modules/github/display.go +++ b/modules/github/display.go @@ -7,11 +7,14 @@ import ( ) func (widget *Widget) display() { + widget.TextWidget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { repo := widget.currentGithubRepo() title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(repo)) if repo == nil { - widget.TextWidget.Redraw(title, " GitHub repo data is unavailable ", false) - return + return title, " GitHub repo data is unavailable ", false } _, _, width, _ := widget.View.GetRect() @@ -27,7 +30,7 @@ func (widget *Widget) display() { str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage) } - widget.TextWidget.Redraw(title, str, false) + return title, str, false } func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string { diff --git a/modules/gitlab/display.go b/modules/gitlab/display.go index fca1796d..11b8d98d 100644 --- a/modules/gitlab/display.go +++ b/modules/gitlab/display.go @@ -5,11 +5,14 @@ import ( ) func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { project := widget.currentGitlabProject() if project == nil { - widget.Redraw(widget.CommonSettings().Title, " Gitlab project data is unavailable ", true) - return + return widget.CommonSettings().Title, " Gitlab project data is unavailable ", true } title := fmt.Sprintf("%s- %s", widget.CommonSettings().Title, widget.title(project)) @@ -24,7 +27,8 @@ func (widget *Widget) display() { str += "\n" str += " [red]My Merge Requests[white]\n" str += widget.displayMyMergeRequests(project, widget.settings.username) - widget.Redraw(title, str, false) + + return title, str, false } func (widget *Widget) displayMyMergeRequests(project *GitlabProject, username string) string { diff --git a/modules/mercurial/display.go b/modules/mercurial/display.go index 18b1a45d..28ffdc7e 100644 --- a/modules/mercurial/display.go +++ b/modules/mercurial/display.go @@ -7,10 +7,13 @@ import ( ) func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { repoData := widget.currentData() if repoData == nil { - widget.Redraw(widget.CommonSettings().Title, " Mercurial repo data is unavailable ", false) - return + return widget.CommonSettings().Title, " Mercurial repo data is unavailable ", false } title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings().Title, repoData.Repository) @@ -24,7 +27,7 @@ func (widget *Widget) display() { str += "\n" str += widget.formatCommits(repoData.Commits) - widget.Redraw(title, str, false) + return title, str, false } func (widget *Widget) formatChanges(data []string) string { diff --git a/modules/textfile/widget.go b/modules/textfile/widget.go index 9e68d96b..ebcfc62d 100644 --- a/modules/textfile/widget.go +++ b/modules/textfile/widget.go @@ -71,6 +71,10 @@ func (widget *Widget) HelpText() string { /* -------------------- Unexported Functions -------------------- */ func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource()) _, _, width, _ := widget.View.GetRect() @@ -82,7 +86,7 @@ func (widget *Widget) display() { text += widget.plainText() } - widget.Redraw(title, text, widget.settings.wrapText) + return title, text, widget.settings.wrapText } func (widget *Widget) fileName() string { diff --git a/modules/twitter/widget.go b/modules/twitter/widget.go index 766f837c..69c3ca77 100644 --- a/modules/twitter/widget.go +++ b/modules/twitter/widget.go @@ -62,6 +62,10 @@ func (widget *Widget) HelpText() string { /* -------------------- Unexported Functions -------------------- */ func (widget *Widget) display() { + widget.RedrawFunc(widget.content) +} + +func (widget *Widget) content() (string, string, bool) { widget.client.screenName = widget.CurrentSource() tweets := widget.client.Tweets() @@ -69,8 +73,7 @@ func (widget *Widget) display() { if len(tweets) == 0 { str := fmt.Sprintf("\n\n\n%s", utils.CenterText("[lightblue]No Tweets[white]", 50)) - widget.Redraw(title, str, true) - return + return title, str, true } _, _, width, _ := widget.View.GetRect() @@ -79,7 +82,7 @@ func (widget *Widget) display() { str += widget.format(tweet) } - widget.Redraw(title, str, true) + return title, str, true } // If the tweet's Username is the same as the account we're watching, no