mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add a global Redraw method for TextWidget
Partially addresses #429, by centralizing widget drawing
This commit is contained in:
@@ -8,11 +8,11 @@ func (widget *Widget) display() {
|
||||
|
||||
project := widget.currentGitlabProject()
|
||||
if project == nil {
|
||||
widget.View.SetText(" Gitlab project data is unavailable ")
|
||||
widget.Redraw(widget.CommonSettings.Title, " Gitlab project data is unavailable ", true)
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.CommonSettings.Title, widget.title(project)))
|
||||
title := fmt.Sprintf("%s- %s", widget.CommonSettings.Title, widget.title(project))
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.GitlabProjects), widget.Idx, width) + "\n"
|
||||
@@ -24,8 +24,7 @@ func (widget *Widget) display() {
|
||||
str = str + "\n"
|
||||
str = str + " [red]My Merge Requests[white]\n"
|
||||
str = str + widget.displayMyMergeRequests(project, widget.settings.username)
|
||||
|
||||
widget.View.SetText(str)
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) displayMyMergeRequests(project *GitlabProject, username string) string {
|
||||
|
||||
@@ -26,7 +26,6 @@ type Widget struct {
|
||||
GitlabProjects []*GitlabProject
|
||||
Idx int
|
||||
|
||||
app *tview.Application
|
||||
gitlab *glb.Client
|
||||
settings *Settings
|
||||
}
|
||||
@@ -46,7 +45,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
Idx: 0,
|
||||
|
||||
app: app,
|
||||
gitlab: gitlab,
|
||||
settings: settings,
|
||||
}
|
||||
@@ -68,9 +66,7 @@ func (widget *Widget) Refresh() {
|
||||
project.Refresh()
|
||||
}
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) Next() {
|
||||
|
||||
Reference in New Issue
Block a user