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

Handle all the widgets that use GetRect

This commit is contained in:
Sean Smith 2019-08-24 23:19:46 -04:00
parent 264f49fd2c
commit 51e4325f0b
7 changed files with 42 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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