mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Fix race conditions caused by writing to view
This commit is contained in:
parent
b7be868798
commit
a1aae6206f
@ -12,6 +12,7 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
args []string
|
args []string
|
||||||
cmd string
|
cmd string
|
||||||
result string
|
result string
|
||||||
@ -22,6 +23,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||||
|
|
||||||
|
app: app,
|
||||||
args: settings.args,
|
args: settings.args,
|
||||||
cmd: settings.cmd,
|
cmd: settings.cmd,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@ -36,9 +38,11 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.execute()
|
widget.execute()
|
||||||
|
|
||||||
widget.CommonSettings.Title = widget.String()
|
widget.CommonSettings.Title = widget.String()
|
||||||
widget.View.SetTitle(tview.TranslateANSI(widget.CommonSettings.Title))
|
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
|
widget.View.SetTitle(tview.TranslateANSI(widget.CommonSettings.Title))
|
||||||
widget.View.SetText(widget.result)
|
widget.View.SetText(widget.result)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) String() string {
|
func (widget *Widget) String() string {
|
||||||
|
@ -44,6 +44,7 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.fetchAndDisplayEvents()
|
widget.fetchAndDisplayEvents()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.app.Suspend(widget.authenticate)
|
widget.app.Suspend(widget.authenticate)
|
||||||
widget.Refresh()
|
widget.Refresh()
|
||||||
}
|
}
|
||||||
@ -57,7 +58,10 @@ func (widget *Widget) fetchAndDisplayEvents() {
|
|||||||
} else {
|
} else {
|
||||||
widget.calEvents = calEvents
|
widget.calEvents = calEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLoop(widget *Widget) {
|
func updateLoop(widget *Widget) {
|
||||||
|
@ -92,7 +92,10 @@ func (widget *Widget) Refresh() {
|
|||||||
sort.Slice(widget.GitRepos, func(i, j int) bool {
|
sort.Slice(widget.GitRepos, func(i, j int) bool {
|
||||||
return widget.GitRepos[i].Path < widget.GitRepos[j].Path
|
return widget.GitRepos[i].Path < widget.GitRepos[j].Path
|
||||||
})
|
})
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -26,6 +26,8 @@ type Widget struct {
|
|||||||
|
|
||||||
GithubRepos []*GithubRepo
|
GithubRepos []*GithubRepo
|
||||||
Idx int
|
Idx int
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +37,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +57,9 @@ func (widget *Widget) Refresh() {
|
|||||||
repo.Refresh()
|
repo.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) Next() {
|
func (widget *Widget) Next() {
|
||||||
|
@ -30,6 +30,7 @@ type Widget struct {
|
|||||||
wtf.HelpfulWidget
|
wtf.HelpfulWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
stories []Story
|
stories []Story
|
||||||
selected int
|
selected int
|
||||||
settings *Settings
|
settings *Settings
|
||||||
@ -40,6 +41,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +85,9 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.stories = stories
|
widget.stories = stories
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -23,6 +23,7 @@ type Widget struct {
|
|||||||
wtf.HelpfulWidget
|
wtf.HelpfulWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
language string
|
language string
|
||||||
result string
|
result string
|
||||||
settings *Settings
|
settings *Settings
|
||||||
@ -35,6 +36,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,9 +48,10 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.nbascore()
|
widget.nbascore()
|
||||||
|
|
||||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) nbascore() {
|
func (widget *Widget) nbascore() {
|
||||||
|
@ -11,6 +11,8 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
Battery *Battery
|
Battery *Battery
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +21,8 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||||
|
|
||||||
Battery: NewBattery(),
|
Battery: NewBattery(),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,5 +39,7 @@ func (widget *Widget) Refresh() {
|
|||||||
content = content + "\n"
|
content = content + "\n"
|
||||||
content = content + widget.Battery.String()
|
content = content + widget.Battery.String()
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.View.SetText(content)
|
widget.View.SetText(content)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ type Widget struct {
|
|||||||
|
|
||||||
Date string
|
Date string
|
||||||
Version string
|
Version string
|
||||||
|
|
||||||
|
app *tview.App
|
||||||
settings *Settings
|
settings *Settings
|
||||||
systemInfo *SystemInfo
|
systemInfo *SystemInfo
|
||||||
}
|
}
|
||||||
@ -22,6 +24,8 @@ func NewWidget(app *tview.Application, date, version string, settings *Settings)
|
|||||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||||
|
|
||||||
Date: date,
|
Date: date,
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
Version: version,
|
Version: version,
|
||||||
}
|
}
|
||||||
@ -32,6 +36,7 @@ func NewWidget(app *tview.Application, date, version string, settings *Settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.View.SetText(
|
widget.View.SetText(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
|
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
|
||||||
@ -45,6 +50,7 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.systemInfo.BuildVersion,
|
widget.systemInfo.BuildVersion,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) prettyDate() string {
|
func (widget *Widget) prettyDate() string {
|
||||||
|
@ -35,6 +35,7 @@ type Widget struct {
|
|||||||
wtf.MultiSourceWidget
|
wtf.MultiSourceWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common.ConfigKey, "filePath", "filePaths"),
|
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common.ConfigKey, "filePath", "filePaths"),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +69,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
// Refresh is only called once on start-up. Its job is to display the
|
// 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
|
// text files that first time. After that, the watcher takes over
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -29,6 +29,7 @@ type Widget struct {
|
|||||||
wtf.HelpfulWidget
|
wtf.HelpfulWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
idx int
|
idx int
|
||||||
projects []*Project
|
projects []*Project
|
||||||
settings *Settings
|
settings *Settings
|
||||||
@ -39,6 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +90,9 @@ func (w *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.app.QueueUpdateDraw(func() {
|
||||||
w.display()
|
w.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Keyboard Movement -------------------- */
|
/* -------------------- Keyboard Movement -------------------- */
|
||||||
|
@ -27,6 +27,7 @@ type Widget struct {
|
|||||||
wtf.MultiSourceWidget
|
wtf.MultiSourceWidget
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
client *Client
|
client *Client
|
||||||
idx int
|
idx int
|
||||||
settings *Settings
|
settings *Settings
|
||||||
@ -39,6 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common.ConfigKey, "screenName", "screenNames"),
|
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common.ConfigKey, "screenName", "screenNames"),
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
|
app: app,
|
||||||
idx: 0,
|
idx: 0,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
@ -62,7 +64,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
|
|
||||||
// Refresh is called on the interval and refreshes the data
|
// Refresh is called on the interval and refreshes the data
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.display()
|
widget.display()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
result string
|
result string
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
@ -20,6 +21,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +31,9 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
widget.prettyWeather()
|
widget.prettyWeather()
|
||||||
|
|
||||||
|
widget.app.QueueUpdateDraw(func() {
|
||||||
widget.View.SetText(widget.result)
|
widget.View.SetText(widget.result)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//this method reads the config and calls wttr.in for pretty weather
|
//this method reads the config and calls wttr.in for pretty weather
|
||||||
|
@ -26,6 +26,8 @@ type Widget struct {
|
|||||||
// APIKey string
|
// APIKey string
|
||||||
Data []*owm.CurrentWeatherData
|
Data []*owm.CurrentWeatherData
|
||||||
Idx int
|
Idx int
|
||||||
|
|
||||||
|
app *tview.Application
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,12 +38,11 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
|
|
||||||
|
app: app,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
// widget.loadAPICredentials()
|
|
||||||
// widget.APIKey
|
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||||
|
|
||||||
@ -73,7 +74,9 @@ func (widget *Widget) Refresh() {
|
|||||||
widget.Data = widget.Fetch(wtf.ToInts(widget.settings.cityIDs))
|
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
|
// Next displays data for the next city data in the list. If the current city is the last
|
||||||
|
Loading…
x
Reference in New Issue
Block a user