1
0
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:
Sean Smith
2019-05-07 20:49:46 -04:00
committed by Chris Cummer
parent aedcf9dd51
commit 018d2af3ae
48 changed files with 194 additions and 412 deletions

View File

@@ -30,7 +30,8 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
app *tview.Application
stories []Story
selected int
settings *Settings
@@ -89,9 +90,7 @@ func (widget *Widget) Refresh() {
widget.stories = stories
}
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@@ -101,12 +100,11 @@ func (widget *Widget) display() {
return
}
widget.View.SetWrap(false)
widget.View.Clear()
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %sstories", widget.CommonSettings.Title, widget.settings.storyType)))
widget.View.SetText(widget.contentFrom(widget.stories))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
title := fmt.Sprintf("%s - %sstories", widget.CommonSettings.Title, widget.settings.storyType)
widget.Redraw(title, widget.contentFrom(widget.stories), false)
widget.app.QueueUpdateDraw(func() {
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
})
}
func (widget *Widget) contentFrom(stories []Story) string {