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.currentGerritProject()
|
||||
if project == nil {
|
||||
widget.View.SetText(fmt.Sprintf("%s", " Gerrit project data is unavailable (1)"))
|
||||
widget.Redraw(widget.CommonSettings.Title, "Gerrit project data is unavailable", true)
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(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.GerritProjects), widget.Idx, width) + "\n"
|
||||
@@ -25,7 +25,7 @@ func (widget *Widget) display() {
|
||||
str = str + " [red]My Outgoing Reviews[white]\n"
|
||||
str = str + widget.displayMyOutgoingReviews(project, widget.settings.username)
|
||||
|
||||
widget.View.SetText(str)
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
func (widget *Widget) displayMyIncomingReviews(project *GerritProject, username string) string {
|
||||
|
||||
@@ -39,7 +39,6 @@ type Widget struct {
|
||||
GerritProjects []*GerritProject
|
||||
Idx int
|
||||
|
||||
app *tview.Application
|
||||
selected int
|
||||
settings *Settings
|
||||
}
|
||||
@@ -56,7 +55,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
Idx: 0,
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@@ -99,9 +97,7 @@ func (widget *Widget) Refresh() {
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
|
||||
return
|
||||
}
|
||||
widget.gerrit = gerrit
|
||||
@@ -111,10 +107,7 @@ func (widget *Widget) Refresh() {
|
||||
project.Refresh(widget.settings.username)
|
||||
}
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
|
||||
widget.display()
|
||||
})
|
||||
widget.display()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
Reference in New Issue
Block a user