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

@ -18,7 +18,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -28,15 +27,12 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.unselect()
widget.View.SetScrollable(true)
widget.View.SetRegions(true)
@ -50,22 +46,11 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
func (widget *Widget) Refresh() {
// The last call should always be to the display function
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) display() {
widget.View.SetWrap(false)
widget.View.Clear()
widget.View.SetText("Some Text")
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
widget.Redraw(widget.CommonSettings.Title, "Some text", false)
}
func (widget *Widget) unselect() {
widget.selected = -1
widget.display()
}

View File

@ -42,10 +42,7 @@ func (widget *Widget) Refresh() {
wtf.Now().Format(wtf.DateFormat),
)
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.View.SetText(widget.contentFrom(todayItems))
})
widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(todayItems), false)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -11,7 +11,6 @@ type Widget struct {
wtf.TextWidget
*Client
app *tview.Application
settings *Settings
}
@ -20,7 +19,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
TextWidget: wtf.NewTextWidget(app, settings.common, false),
Client: NewClient(settings.apiKey),
app: app,
settings: settings,
}
@ -36,19 +34,17 @@ func (widget *Widget) Refresh() {
builds, err := widget.Client.BuildsFor()
title := fmt.Sprintf("%s - Builds", widget.CommonSettings.Title)
var content string
wrap := false
if err != nil {
widget.View.SetWrap(true)
wrap = true
content = err.Error()
} else {
widget.View.SetWrap(false)
content = widget.contentFrom(builds)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.CommonSettings.Title))
widget.View.SetText(content)
})
widget.Redraw(title, content, wrap)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -12,7 +12,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
args []string
cmd string
settings *Settings
@ -23,7 +22,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
args: settings.args,
cmd: settings.cmd,
settings: settings,
@ -41,10 +39,7 @@ func (widget *Widget) Refresh() {
ansiTitle := tview.TranslateANSI(widget.String())
ansiResult := tview.TranslateANSI(result)
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(ansiTitle)
widget.View.SetText(ansiResult)
})
widget.Redraw(ansiTitle, ansiResult, false)
}
// String returns the string representation of the widget

View File

@ -39,7 +39,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}

View File

@ -29,13 +29,12 @@ func (widget *Widget) display() {
return
}
widget.View.SetTitle(widget.ContextualTitle(widget.settings.common.Title))
widget.View.SetText(widget.contentFrom(widget.calEvents))
widget.TextWidget.Redraw(widget.settings.common.Title, widget.contentFrom(widget.calEvents), false)
}
func (widget *Widget) contentFrom(calEvents []*CalEvent) string {
if (calEvents == nil) || (len(calEvents) == 0) {
return ""
return "No calendar events"
}
var str string

View File

@ -1,8 +1,6 @@
package gcal
import (
"time"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
)
@ -12,7 +10,6 @@ type Widget struct {
app *tview.Application
calEvents []*CalEvent
ch chan struct{}
settings *Settings
}
@ -21,27 +18,21 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
ch: make(chan struct{}),
settings: settings,
}
go updateLoop(&widget)
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Disable() {
close(widget.ch)
widget.TextWidget.Disable()
}
func (widget *Widget) Refresh() {
if isAuthenticated() {
widget.app.QueueUpdateDraw(func() {
widget.fetchAndDisplayEvents()
})
widget.fetchAndDisplayEvents()
return
}
@ -59,27 +50,5 @@ func (widget *Widget) fetchAndDisplayEvents() {
widget.calEvents = calEvents
}
widget.app.QueueUpdateDraw(func() {
widget.display()
})
}
func updateLoop(widget *Widget) {
if widget.settings.textInterval == 0 {
return
}
tick := time.NewTicker(time.Duration(widget.settings.textInterval) * time.Second)
defer tick.Stop()
outer:
for {
select {
case <-tick.C:
widget.app.QueueUpdateDraw(func() {
widget.display()
})
case <-widget.ch:
break outer
}
}
widget.display()
}

View File

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

View File

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

View File

@ -9,12 +9,11 @@ import (
func (widget *Widget) display() {
repoData := widget.currentData()
if repoData == nil {
widget.View.SetText(" Git repo data is unavailable ")
widget.Redraw(widget.CommonSettings.Title, " Git repo data is unavailable ", false)
return
}
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings.Title, repoData.Repository)
widget.View.SetTitle(widget.ContextualTitle(title))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GitRepos), widget.Idx, width) + "\n"
@ -25,7 +24,7 @@ func (widget *Widget) display() {
str = str + "\n"
str = str + widget.formatCommits(repoData.Commits)
widget.View.SetText(str)
widget.Redraw(title, str, false)
}
func (widget *Widget) formatChanges(data []string) string {

View File

@ -97,9 +97,7 @@ func (widget *Widget) Refresh() {
return widget.GitRepos[i].Path < widget.GitRepos[j].Path
})
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -125,9 +123,11 @@ func (widget *Widget) addCancelButton(form *tview.Form) {
}
func (widget *Widget) modalFocus(form *tview.Form) {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
widget.app.QueueUpdateDraw(func() {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
})
}
func (widget *Widget) modalForm(lbl, text string) *tview.Form {

View File

@ -8,13 +8,12 @@ import (
func (widget *Widget) display() {
repo := widget.currentGithubRepo()
title := fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.title(repo))
if repo == nil {
widget.View.SetText(" GitHub repo data is unavailable ")
widget.TextWidget.Redraw(title, " GitHub repo data is unavailable ", false)
return
}
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.title(repo))))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width) + "\n"
str = str + " [red]Stats[white]\n"
@ -26,7 +25,7 @@ func (widget *Widget) display() {
str = str + " [red]My Pull Requests[white]\n"
str = str + widget.displayMyPullRequests(repo, widget.settings.username)
widget.View.SetText(str)
widget.TextWidget.Redraw(title, str, false)
}
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {

View File

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

View File

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

View File

@ -26,7 +26,8 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
app *tview.Application
messages []Message
selected int
settings *Settings
@ -80,19 +81,12 @@ func (widget *Widget) Refresh() {
if err != nil {
widget.View.SetWrap(true)
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.CommonSettings.Title)
widget.View.SetText(err.Error())
})
} else {
widget.messages = messages
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
return
}
widget.messages = messages
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.display()
widget.View.ScrollToEnd()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -102,11 +96,13 @@ func (widget *Widget) display() {
return
}
widget.View.SetWrap(true)
widget.View.Clear()
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.settings.roomURI)))
widget.View.SetText(widget.contentFrom(widget.messages))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
title := fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.settings.roomURI)
widget.Redraw(title, widget.contentFrom(widget.messages), true)
widget.app.QueueUpdateDraw(func() {
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
widget.View.ScrollToEnd()
})
}
func (widget *Widget) contentFrom(messages []Message) string {

View File

@ -11,7 +11,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -19,7 +18,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -31,9 +29,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
func (widget *Widget) Refresh() {
cells, _ := widget.Fetch()
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(widget.contentFrom(cells))
})
widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(cells), false)
}
/* -------------------- Unexported Functions -------------------- */

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 {

View File

@ -14,7 +14,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
result string
settings *Settings
}
@ -34,7 +33,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -46,10 +44,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
func (widget *Widget) Refresh() {
widget.ipinfo()
widget.app.QueueUpdateDraw(func() {
widget.View.Clear()
widget.View.SetText(widget.result)
})
widget.TextWidget.Redraw(widget.CommonSettings.Title, widget.result, false)
}
//this method reads the config and calls ipinfo for ip information

View File

@ -29,7 +29,8 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
app *tview.Application
selected int
settings *Settings
view *View
@ -73,17 +74,11 @@ func (widget *Widget) Refresh() {
widget.view = view
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.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -93,12 +88,12 @@ func (widget *Widget) display() {
return
}
widget.View.SetWrap(false)
title := fmt.Sprintf("%s: [red]%s", widget.CommonSettings.Title, widget.view.Name)
widget.View.Clear()
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s: [red]%s", widget.CommonSettings.Title, widget.view.Name)))
widget.View.SetText(widget.contentFrom(widget.view))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
widget.Redraw(title, widget.contentFrom(widget.view), false)
widget.app.QueueUpdateDraw(func() {
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
})
}
func (widget *Widget) contentFrom(view *View) string {

View File

@ -2,7 +2,6 @@ package jira
import (
"fmt"
"strconv"
"github.com/rivo/tview"
@ -27,7 +26,8 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
app *tview.Application
result *SearchResult
selected int
settings *Settings
@ -67,19 +67,11 @@ func (widget *Widget) Refresh() {
if err != nil {
widget.result = nil
widget.View.SetWrap(true)
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.CommonSettings.Title)
widget.View.SetText(err.Error())
})
} else {
widget.result = searchResult
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
return
}
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.result = searchResult
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -88,14 +80,13 @@ func (widget *Widget) display() {
if widget.result == nil {
return
}
widget.View.SetWrap(false)
str := fmt.Sprintf("%s- [green]%s[white]", widget.CommonSettings.Title, widget.settings.projects)
widget.View.Clear()
widget.View.SetTitle(widget.ContextualTitle(str))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.result)))
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
widget.Redraw(str, widget.contentFrom(widget.result), false)
widget.app.QueueUpdateDraw(func() {
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
})
}
func (widget *Widget) next() {

View File

@ -9,12 +9,11 @@ import (
func (widget *Widget) display() {
repoData := widget.currentData()
if repoData == nil {
widget.View.SetText(" Mercurial repo data is unavailable ")
widget.Redraw(widget.CommonSettings.Title, " Mercurial repo data is unavailable ", false)
return
}
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings.Title, repoData.Repository)
widget.View.SetTitle(widget.ContextualTitle(title))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
@ -25,7 +24,7 @@ func (widget *Widget) display() {
str = str + "\n"
str = str + widget.formatCommits(repoData.Commits)
widget.View.SetText(str)
widget.Redraw(title, str, false)
}
func (widget *Widget) formatChanges(data []string) string {

View File

@ -71,9 +71,7 @@ func (widget *Widget) Checkout() {
widget.pages.RemovePage("modal")
widget.app.SetFocus(widget.View)
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
widget.Refresh()
}
@ -86,7 +84,6 @@ func (widget *Widget) Pull() {
repoToPull := widget.Data[widget.Idx]
repoToPull.pull()
widget.Refresh()
}
func (widget *Widget) Refresh() {
@ -94,9 +91,7 @@ func (widget *Widget) Refresh() {
widget.Data = widget.mercurialRepos(repoPaths)
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -122,9 +117,11 @@ func (widget *Widget) addCancelButton(form *tview.Form) {
}
func (widget *Widget) modalFocus(form *tview.Form) {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
widget.app.QueueUpdateDraw(func() {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
})
}
func (widget *Widget) modalForm(lbl, text string) *tview.Form {

View File

@ -25,7 +25,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
language string
result string
settings *Settings
@ -40,7 +39,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}
@ -55,39 +53,32 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
}
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.nbascore()
})
widget.Redraw(widget.CommonSettings.Title, widget.nbascore(), false)
}
func (widget *Widget) nbascore() {
func (widget *Widget) nbascore() string {
cur := time.Now().AddDate(0, 0, offset) // Go back/forward offset days
curString := cur.Format("20060102") // Need 20060102 format to feed to api
client := &http.Client{}
req, err := http.NewRequest("GET", "http://data.nba.net/10s/prod/v1/"+curString+"/scoreboard.json", nil)
if err != nil {
widget.result = err.Error()
return
return err.Error()
}
req.Header.Set("Accept-Language", widget.language)
req.Header.Set("User-Agent", "curl")
response, err := client.Do(req)
if err != nil {
widget.result = err.Error()
return
return err.Error()
}
defer response.Body.Close()
if response.StatusCode != 200 {
widget.result = err.Error()
return
return err.Error()
} // Get data from data.nba.net and check if successful
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
widget.result = err.Error()
return
return err.Error()
}
result := map[string]interface{}{}
json.Unmarshal(contents, &result)
@ -146,6 +137,5 @@ func (widget *Widget) nbascore() {
}
allGame += fmt.Sprintf("%s%5s%v[white] %s %3s [white]vs %s%-3s %s\n", qColor, "Q", quarter, vTeam, vScore, hColor, hScore, hTeam) // Format the score and store in allgame
}
widget.View.SetText(allGame)
return allGame
}

View File

@ -11,7 +11,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
client *Client
settings *Settings
}
@ -20,7 +19,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -41,19 +39,16 @@ func (widget *Widget) Refresh() {
}
var content string
title := fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings.Title, appName)
wrap := false
if depErr != nil {
widget.View.SetWrap(true)
wrap = true
content = depErr.Error()
} else {
widget.View.SetWrap(false)
content = widget.contentFrom(deploys)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.CommonSettings.Title, appName)))
widget.View.Clear()
widget.View.SetText(content)
})
widget.Redraw(title, content, wrap)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -11,7 +11,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -19,7 +18,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -35,18 +33,15 @@ func (widget *Widget) Refresh() {
)
var content string
wrap := false
if err != nil {
widget.View.SetWrap(true)
wrap = true
content = err.Error()
} else {
widget.View.SetWrap(false)
content = widget.contentFrom(data)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.View.SetText(content)
})
widget.Redraw(widget.CommonSettings.Title, content, wrap)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -12,7 +12,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -20,7 +19,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -44,14 +42,10 @@ func (widget *Widget) Refresh() {
incidents, err2 = GetIncidents(widget.settings.apiKey)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.View.Clear()
})
var content string
wrap := false
if err1 != nil || err2 != nil {
widget.View.SetWrap(true)
wrap = true
if err1 != nil {
content = content + err1.Error()
}
@ -63,9 +57,7 @@ func (widget *Widget) Refresh() {
content = widget.contentFrom(onCalls, incidents)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(content)
})
widget.Redraw(widget.CommonSettings.Title, content, wrap)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -12,7 +12,6 @@ type Widget struct {
Battery *Battery
app *tview.Application
settings *Settings
}
@ -22,7 +21,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
Battery: NewBattery(),
app: app,
settings: settings,
}
@ -39,7 +37,5 @@ func (widget *Widget) Refresh() {
content = content + "\n"
content = content + widget.Battery.String()
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(content)
})
widget.Redraw(widget.CommonSettings.Title, content, true)
}

View File

@ -28,7 +28,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
items *Result
selected int
settings *Settings
@ -41,7 +40,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}
@ -69,19 +67,12 @@ func (widget *Widget) Refresh() {
)
if err != nil {
widget.View.SetWrap(true)
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(err.Error())
})
} else {
widget.items = &items.Results
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
return
}
widget.items = &items.Results
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -91,12 +82,14 @@ func (widget *Widget) display() {
return
}
widget.View.SetWrap(false)
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.settings.projectName)))
widget.View.SetText(widget.contentFrom(widget.items))
title := fmt.Sprintf("%s - %s", widget.CommonSettings.Title, widget.settings.projectName)
widget.Redraw(title, widget.contentFrom(widget.items), false)
}
func (widget *Widget) contentFrom(result *Result) string {
if result == nil {
return "No results"
}
var str string
if len(result.Items) > widget.settings.count {
result.Items = result.Items[:widget.settings.count]

View File

@ -11,7 +11,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -19,7 +18,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -37,9 +35,7 @@ func (widget *Widget) Refresh() {
data := NewSecurityData()
data.Fetch()
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(widget.contentFrom(data))
})
widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(data), false)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -21,7 +21,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
settings *Settings
spotigopher.Info
spotigopher.SpotifyClient
@ -38,7 +37,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
Info: spotigopher.Info{},
SpotifyClient: spotifyClient,
app: app,
settings: settings,
}
@ -63,19 +61,18 @@ func (w *Widget) refreshSpotifyInfos() error {
}
func (w *Widget) Refresh() {
w.app.QueueUpdateDraw(func() {
w.render()
})
w.render()
}
func (w *Widget) render() {
err := w.refreshSpotifyInfos()
w.View.Clear()
var content string
if err != nil {
w.TextWidget.View.SetText(err.Error())
content = err.Error()
} else {
w.TextWidget.View.SetText(w.createOutput())
content = w.createOutput()
}
w.Redraw(w.CommonSettings.Title, content, true)
}
func (w *Widget) createOutput() string {

View File

@ -48,7 +48,6 @@ type Widget struct {
Info
app *tview.Application
client *spotify.Client
clientChan chan *spotify.Client
playerState *spotify.PlayerState
@ -99,7 +98,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
Info: Info{},
app: app,
client: client,
clientChan: tempClientChan,
playerState: playerState,
@ -181,18 +179,11 @@ func (w *Widget) refreshSpotifyInfos() error {
// Refresh refreshes the current view of the widget
func (w *Widget) Refresh() {
w.app.QueueUpdateDraw(func() {
w.render()
})
}
func (w *Widget) render() {
err := w.refreshSpotifyInfos()
w.View.Clear()
if err != nil {
w.TextWidget.View.SetText(err.Error())
w.Redraw(w.CommonSettings.Title, err.Error(), true)
} else {
w.TextWidget.View.SetText(w.createOutput())
w.Redraw(w.CommonSettings.Title, w.createOutput(), false)
}
}

View File

@ -10,7 +10,6 @@ type Widget struct {
CurrentIcon int
app *tview.Application
settings *Settings
}
@ -20,7 +19,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
CurrentIcon: 0,
app: app,
settings: settings,
}
@ -30,9 +28,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(widget.animation())
})
widget.Redraw(widget.CommonSettings.Title, widget.animation(), false)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -14,7 +14,6 @@ type Widget struct {
Date string
Version string
app *tview.Application
settings *Settings
systemInfo *SystemInfo
}
@ -25,7 +24,6 @@ func NewWidget(app *tview.Application, date, version string, settings *Settings)
Date: date,
app: app,
settings: settings,
Version: version,
}
@ -36,21 +34,18 @@ func NewWidget(app *tview.Application, date, version string, settings *Settings)
}
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(
fmt.Sprintf(
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
"Built",
widget.prettyDate(),
"Vers",
widget.Version,
"OS",
widget.systemInfo.ProductVersion,
"Build",
widget.systemInfo.BuildVersion,
),
)
})
content := fmt.Sprintf(
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
"Built",
widget.prettyDate(),
"Vers",
widget.Version,
"OS",
widget.systemInfo.ProductVersion,
"Build",
widget.systemInfo.BuildVersion,
)
widget.Redraw(widget.CommonSettings.Title, content, false)
}
func (widget *Widget) prettyDate() string {

View File

@ -73,16 +73,13 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
// Refresh is only called once on start-up. Its job is to display the
// text files that first time. After that, the watcher takes over
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) display() {
title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource())
title = widget.ContextualTitle(title)
_, _, width, _ := widget.View.GetRect()
text := widget.settings.common.SigilStr(len(widget.Sources), widget.Idx, width) + "\n"
@ -93,8 +90,7 @@ func (widget *Widget) display() {
text = text + widget.plainText()
}
widget.View.SetTitle(title) // <- Writes to TextView's title
widget.View.SetText(text) // <- Writes to TextView's text
widget.Redraw(title, text, false)
}
func (widget *Widget) fileName() string {

View File

@ -2,7 +2,6 @@ package todo
import (
"fmt"
"strconv"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/checklist"
@ -34,9 +33,7 @@ func (widget *Widget) display() {
newList.SetSelectedByItem(widget.list.SelectedItem())
widget.SetList(newList)
widget.View.Clear()
widget.View.SetText(str)
widget.View.Highlight(strconv.Itoa(widget.list.Selected())).ScrollToHighlight()
widget.Redraw(widget.CommonSettings.Title, str, false)
}
func (widget *Widget) formattedItemLine(idx int, item *checklist.ChecklistItem, selectedItem *checklist.ChecklistItem, maxLen int) string {

View File

@ -79,13 +79,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
func (widget *Widget) Refresh() {
widget.load()
widget.app.QueueUpdateDraw(func() {
title := widget.ContextualTitle(widget.CommonSettings.Title)
widget.View.SetTitle(title)
widget.display()
})
widget.display()
}
func (widget *Widget) SetList(list checklist.Checklist) {
@ -198,10 +192,9 @@ func (widget *Widget) addSaveButton(form *tview.Form, fctn func()) {
}
func (widget *Widget) modalFocus(form *tview.Form) {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.QueueUpdateDraw(func() {
frame := widget.modalFrame(form)
widget.pages.AddPage("modal", frame, false, true)
widget.app.SetFocus(frame)
})
}

View File

@ -17,7 +17,6 @@ func (widget *Widget) display() {
}
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
widget.View.SetTitle(widget.ContextualTitle(title))
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.projects), widget.idx, width) + "\n"
@ -47,5 +46,5 @@ func (widget *Widget) display() {
str = str + row + wtf.PadRow((checkWidth+len(item.Content)), (checkWidth+maxLen+1)) + "\n"
}
widget.View.SetText(str)
widget.TextWidget.Redraw(title, str, false)
}

View File

@ -31,7 +31,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
idx int
projects []*Project
settings *Settings
@ -44,7 +43,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}
@ -96,9 +94,7 @@ func (w *Widget) Refresh() {
return
}
w.app.QueueUpdateDraw(func() {
w.display()
})
w.display()
}
/* -------------------- Keyboard Movement -------------------- */

View File

@ -27,7 +27,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
builds *Builds
selected int
settings *Settings
@ -39,7 +38,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}
@ -63,19 +61,11 @@ func (widget *Widget) Refresh() {
builds, err := BuildsFor(widget.settings.apiKey, widget.settings.pro)
if err != nil {
widget.View.SetWrap(true)
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(err.Error())
})
} else {
widget.builds = builds
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
return
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.display()
})
widget.builds = builds
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -85,10 +75,8 @@ func (widget *Widget) display() {
return
}
widget.View.SetWrap(false)
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - Builds", widget.CommonSettings.Title)))
widget.View.SetText(widget.contentFrom(widget.builds))
title := fmt.Sprintf("%s - Builds", widget.CommonSettings.Title)
widget.Redraw(title, widget.contentFrom(widget.builds), false)
}
func (widget *Widget) contentFrom(builds *Builds) string {

View File

@ -11,7 +11,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -19,7 +18,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -45,8 +43,9 @@ func (widget *Widget) Refresh() {
var title string
var content string
wrap := false
if err != nil {
widget.View.SetWrap(true)
wrap = true
title = widget.CommonSettings.Title
content = err.Error()
} else {
@ -59,10 +58,7 @@ func (widget *Widget) Refresh() {
content = widget.contentFrom(searchResult)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(title)
widget.View.SetText(content)
})
widget.Redraw(title, content, wrap)
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -28,7 +28,6 @@ type Widget struct {
wtf.MultiSourceWidget
wtf.TextWidget
app *tview.Application
client *Client
idx int
settings *Settings
@ -42,7 +41,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
idx: 0,
settings: settings,
}
@ -67,9 +65,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
// Refresh is called on the interval and refreshes the data
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
@ -78,7 +74,7 @@ func (widget *Widget) display() {
widget.client.screenName = widget.CurrentSource()
tweets := widget.client.Tweets()
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("Twitter - [green]@%s[white]", widget.CurrentSource())))
title := fmt.Sprintf("Twitter - [green]@%s[white]", widget.CurrentSource())
if len(tweets) == 0 {
str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[blue]No Tweets[white]", 50))
@ -92,7 +88,7 @@ func (widget *Widget) display() {
str = str + widget.format(tweet)
}
widget.View.SetText(str)
widget.Redraw(title, str, false)
}
// If the tweet's Username is the same as the account we're watching, no

View File

@ -10,7 +10,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
settings *Settings
}
@ -18,7 +17,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -28,10 +26,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.View.Clear()
content := fmt.Sprintf("Widget %s and/or type %s does not exist", widget.Name(), widget.CommonSettings.Module.Type)
widget.View.SetText(content)
})
content := fmt.Sprintf("Widget %s and/or type %s does not exist", widget.Name(), widget.CommonSettings.Module.Type)
widget.Redraw(widget.CommonSettings.Title, content, true)
}

View File

@ -20,7 +20,6 @@ const HelpText = `
type Widget struct {
wtf.TextWidget
app *tview.Application
teams []OnCallTeam
settings *Settings
}
@ -47,19 +46,11 @@ func (widget *Widget) Refresh() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
if err != nil {
widget.View.SetWrap(true)
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(err.Error())
})
widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
} else {
widget.teams = teams
widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(widget.teams), true)
}
widget.app.QueueUpdateDraw(func() {
widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
widget.display()
})
}
func (widget *Widget) display() {
@ -75,6 +66,10 @@ func (widget *Widget) display() {
func (widget *Widget) contentFrom(teams []OnCallTeam) string {
var str string
if teams == nil || len(teams) == 0 {
return "No teams specified"
}
for _, team := range teams {
if len(widget.settings.team) > 0 && widget.settings.team != team.Slug {
continue

View File

@ -12,7 +12,6 @@ import (
type Widget struct {
wtf.TextWidget
app *tview.Application
result string
settings *Settings
}
@ -21,7 +20,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false),
app: app,
settings: settings,
}
@ -31,9 +29,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
func (widget *Widget) Refresh() {
widget.prettyWeather()
widget.app.QueueUpdateDraw(func() {
widget.View.SetText(widget.result)
})
widget.Redraw(widget.CommonSettings.Title, widget.result, false)
}
//this method reads the config and calls wttr.in for pretty weather

View File

@ -9,31 +9,34 @@ import (
)
func (widget *Widget) display() {
err := ""
if widget.apiKeyValid() == false {
widget.View.SetText(" Environment variable WTF_OWM_API_KEY is not set")
return
err += " Environment variable WTF_OWM_API_KEY is not set\n"
}
cityData := widget.currentData()
if cityData == nil {
widget.View.SetText(" Weather data is unavailable: no city data")
return
err += " Weather data is unavailable: no city data\n"
}
if len(cityData.Weather) == 0 {
widget.View.SetText(" Weather data is unavailable: no weather data")
return
err += " Weather data is unavailable: no weather data"
}
widget.View.SetTitle(widget.title(cityData))
title := widget.CommonSettings.Title
var content string
if err != "" {
content = err
} else {
title = widget.title(cityData)
_, _, width, _ := widget.View.GetRect()
content = widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
content = content + widget.description(cityData) + "\n\n"
content = content + widget.temperatures(cityData) + "\n"
content = content + widget.sunInfo(cityData)
}
_, _, width, _ := widget.View.GetRect()
content := widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
content = content + widget.description(cityData) + "\n\n"
content = content + widget.temperatures(cityData) + "\n"
content = content + widget.sunInfo(cityData)
widget.View.SetText(content)
widget.Redraw(title, content, false)
}
func (widget *Widget) description(cityData *owm.CurrentWeatherData) string {

View File

@ -27,7 +27,6 @@ type Widget struct {
Data []*owm.CurrentWeatherData
Idx int
app *tview.Application
settings *Settings
}
@ -40,7 +39,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
Idx: 0,
app: app,
settings: settings,
}
@ -77,9 +75,7 @@ func (widget *Widget) Refresh() {
widget.Data = widget.Fetch(wtf.ToInts(widget.settings.cityIDs))
}
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
// Next displays data for the next city data in the list. If the current city is the last

View File

@ -13,7 +13,6 @@ type Widget struct {
wtf.KeyboardWidget
wtf.TextWidget
app *tview.Application
result *TicketArray
selected int
settings *Settings
@ -25,7 +24,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
KeyboardWidget: wtf.NewKeyboardWidget(),
TextWidget: wtf.NewTextWidget(app, settings.common, true),
app: app,
settings: settings,
}
@ -46,16 +44,14 @@ func (widget *Widget) Refresh() {
widget.result = ticketArray
}
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) display() {
widget.View.SetTitle(fmt.Sprintf("%s (%d)", widget.CommonSettings.Title, widget.result.Count))
widget.View.SetText(widget.textContent(widget.result.Tickets))
title := fmt.Sprintf("%s (%d)", widget.CommonSettings.Title, widget.result.Count)
widget.Redraw(title, widget.textContent(widget.result.Tickets), false)
}
func (widget *Widget) textContent(items []Ticket) string {

View File

@ -13,6 +13,7 @@ type TextWidget struct {
focusChar string
name string
refreshInterval int
app *tview.Application
View *tview.TextView
@ -24,6 +25,7 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable
widget := TextWidget{
CommonSettings: commonSettings,
app: app,
enabled: commonSettings.Enabled,
focusable: focusable,
focusChar: commonSettings.FocusChar(),
@ -107,6 +109,16 @@ func (widget *TextWidget) TextView() *tview.TextView {
return widget.View
}
func (widget *TextWidget) Redraw(title, text string, wrap bool) {
widget.app.QueueUpdateDraw(func() {
widget.View.Clear()
widget.View.SetWrap(wrap)
widget.View.SetTitle(widget.ContextualTitle(title))
widget.View.SetText(text)
})
}
/* -------------------- Unexported Functions -------------------- */
func (widget *TextWidget) addView() *tview.TextView {