mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-315 Fix race conditions caused by writing to view
This commit is contained in:
parent
a1aae6206f
commit
5445309aa0
@ -18,12 +18,16 @@ var ok = true
|
||||
// Widget define wtf widget to register widget later
|
||||
type Widget struct {
|
||||
wtf.BarGraph
|
||||
|
||||
app *tview.Application
|
||||
}
|
||||
|
||||
// NewWidget Make new instance of widget
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
BarGraph: wtf.NewBarGraph(app, "Sample Bar Graph", "bargraph", false),
|
||||
|
||||
app: app,
|
||||
}
|
||||
|
||||
widget.View.SetWrap(true)
|
||||
@ -66,7 +70,9 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
widget.View.Clear()
|
||||
|
||||
display(widget)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
display(widget)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -25,6 +26,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -43,7 +45,9 @@ 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.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -12,6 +12,7 @@ const APIURI = "https://api.bamboohr.com/api/gateway.php"
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -19,6 +20,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -40,9 +42,10 @@ func (widget *Widget) Refresh() {
|
||||
wtf.Now().Format(wtf.DateFormat),
|
||||
)
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
|
||||
widget.View.SetText(widget.contentFrom(todayItems))
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(widget.contentFrom(todayItems))
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -11,6 +11,7 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
*Client
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -19,6 +20,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
Client: NewClient(settings.apiKey),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -34,8 +36,6 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
builds, err := widget.Client.BuildsFor()
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.Name()))
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
@ -45,7 +45,10 @@ func (widget *Widget) Refresh() {
|
||||
content = widget.contentFrom(builds)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.Name()))
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -15,10 +15,10 @@ type Widget struct {
|
||||
app *tview.Application
|
||||
args []string
|
||||
cmd string
|
||||
result string
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
// NewWidget creates a new instance of the widget
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
@ -34,17 +34,20 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
return &widget
|
||||
}
|
||||
|
||||
// Refresh executes the command and updates the view with the results
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.execute()
|
||||
result := widget.execute()
|
||||
|
||||
widget.CommonSettings.Title = widget.String()
|
||||
ansiTitle := tview.TranslateANSI(widget.String())
|
||||
ansiResult := tview.TranslateANSI(result)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(tview.TranslateANSI(widget.CommonSettings.Title))
|
||||
widget.View.SetText(widget.result)
|
||||
widget.View.SetTitle(ansiTitle)
|
||||
widget.View.SetText(ansiResult)
|
||||
})
|
||||
}
|
||||
|
||||
// String returns the string representation of the widget
|
||||
func (widget *Widget) String() string {
|
||||
args := strings.Join(widget.args, " ")
|
||||
|
||||
@ -55,7 +58,9 @@ func (widget *Widget) String() string {
|
||||
return fmt.Sprintf(" %s ", widget.cmd)
|
||||
}
|
||||
|
||||
func (widget *Widget) execute() {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) execute() string {
|
||||
cmd := exec.Command(widget.cmd, widget.args...)
|
||||
widget.result = tview.TranslateANSI(wtf.ExecuteCommand(cmd))
|
||||
return wtf.ExecuteCommand(cmd)
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ const baseURL = "https://bittrex.com/api/v1.1/public/getmarketsummary"
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
summaryList
|
||||
}
|
||||
@ -29,6 +30,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
summaryList: summaryList{},
|
||||
}
|
||||
@ -77,7 +79,10 @@ func makeMarketCurrency(name string) *mCurrency {
|
||||
// Refresh & update after interval time
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.updateSummary()
|
||||
widget.display()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
@ -137,7 +142,9 @@ func (widget *Widget) updateSummary() {
|
||||
}
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
func makeRequest(baseName, marketName string) *http.Request {
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
device_token string
|
||||
settings *Settings
|
||||
}
|
||||
@ -22,6 +23,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
device_token: settings.deviceToken,
|
||||
settings: settings,
|
||||
}
|
||||
@ -32,15 +34,17 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.View.SetTitle(" Blockfolio ")
|
||||
|
||||
positions, err := Fetch(widget.device_token)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
content := widget.contentFrom(positions)
|
||||
widget.View.SetText(content)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(" Blockfolio ")
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
priceWidget *price.Widget
|
||||
toplistWidget *toplist.Widget
|
||||
settings *Settings
|
||||
@ -24,6 +25,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
priceWidget: price.NewWidget(settings.priceSettings),
|
||||
toplistWidget: toplist.NewWidget(settings.toplistSettings),
|
||||
settings: settings,
|
||||
@ -46,14 +48,17 @@ func (widget *Widget) Refresh() {
|
||||
widget.toplistWidget.Refresh(&wg)
|
||||
wg.Wait()
|
||||
|
||||
display(widget)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func display(widget *Widget) {
|
||||
func (widget *Widget) display() {
|
||||
str := ""
|
||||
str += widget.priceWidget.Result
|
||||
str += widget.toplistWidget.Result
|
||||
|
||||
widget.View.SetText(fmt.Sprintf("\n%s", str))
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -29,9 +31,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
func (widget *Widget) Refresh() {
|
||||
monitors, monitorErr := widget.Monitors()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
|
||||
var content string
|
||||
if monitorErr != nil {
|
||||
widget.View.SetWrap(true)
|
||||
@ -40,8 +39,11 @@ func (widget *Widget) Refresh() {
|
||||
widget.View.SetWrap(false)
|
||||
content = widget.contentFrom(monitors)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -41,7 +41,9 @@ func (widget *Widget) Disable() {
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if isAuthenticated() {
|
||||
widget.fetchAndDisplayEvents()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.fetchAndDisplayEvents()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -75,7 +77,9 @@ outer:
|
||||
for {
|
||||
select {
|
||||
case <-tick.C:
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
case <-widget.ch:
|
||||
break outer
|
||||
}
|
||||
|
@ -38,8 +38,10 @@ type Widget struct {
|
||||
|
||||
GerritProjects []*GerritProject
|
||||
Idx int
|
||||
selected int
|
||||
settings *Settings
|
||||
|
||||
app *tview.Application
|
||||
selected int
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
var (
|
||||
@ -51,7 +53,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
Idx: 0,
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -91,8 +95,11 @@ func (widget *Widget) Refresh() {
|
||||
gerrit, err := glb.NewClient(gerritUrl, httpClient)
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
return
|
||||
}
|
||||
widget.gerrit = gerrit
|
||||
@ -102,7 +109,10 @@ func (widget *Widget) Refresh() {
|
||||
project.Refresh(widget.settings.username)
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -25,8 +25,10 @@ type Widget struct {
|
||||
|
||||
GitlabProjects []*GitlabProject
|
||||
Idx int
|
||||
gitlab *glb.Client
|
||||
settings *Settings
|
||||
|
||||
app *tview.Application
|
||||
gitlab *glb.Client
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
@ -41,7 +43,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Idx: 0,
|
||||
Idx: 0,
|
||||
|
||||
app: app,
|
||||
gitlab: gitlab,
|
||||
settings: settings,
|
||||
}
|
||||
@ -61,7 +65,9 @@ func (widget *Widget) Refresh() {
|
||||
project.Refresh()
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
func (widget *Widget) Next() {
|
||||
|
@ -24,6 +24,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
messages []Message
|
||||
selected int
|
||||
settings *Settings
|
||||
@ -34,6 +35,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -70,14 +72,19 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
} else {
|
||||
widget.messages = messages
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.View.ScrollToEnd()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
widget.View.ScrollToEnd()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -29,7 +31,9 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
func (widget *Widget) Refresh() {
|
||||
cells, _ := widget.Fetch()
|
||||
|
||||
widget.View.SetText(widget.contentFrom(cells))
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetText(widget.contentFrom(cells))
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
result string
|
||||
settings *Settings
|
||||
}
|
||||
@ -40,6 +41,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -51,7 +53,10 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
// Refresh refresh the module
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.ipinfo()
|
||||
widget.View.SetText(widget.result)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetText(widget.result)
|
||||
})
|
||||
}
|
||||
|
||||
//this method reads the config and calls ipinfo for ip information
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
result string
|
||||
settings *Settings
|
||||
}
|
||||
@ -33,6 +34,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -43,9 +45,11 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.ipinfo()
|
||||
widget.View.Clear()
|
||||
|
||||
widget.View.SetText(widget.result)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.Clear()
|
||||
widget.View.SetText(widget.result)
|
||||
})
|
||||
}
|
||||
|
||||
//this method reads the config and calls ipinfo for ip information
|
||||
|
@ -28,6 +28,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
selected int
|
||||
settings *Settings
|
||||
view *View
|
||||
@ -38,6 +39,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -67,11 +69,16 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -26,6 +26,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
result *SearchResult
|
||||
selected int
|
||||
settings *Settings
|
||||
@ -36,6 +37,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -60,13 +62,18 @@ func (widget *Widget) Refresh() {
|
||||
if err != nil {
|
||||
widget.result = nil
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
} else {
|
||||
widget.result = searchResult
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -65,7 +65,11 @@ func (widget *Widget) Checkout() {
|
||||
repoToCheckout.checkout(text)
|
||||
widget.pages.RemovePage("modal")
|
||||
widget.app.SetFocus(widget.View)
|
||||
widget.display()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
|
||||
widget.Refresh()
|
||||
}
|
||||
|
||||
@ -84,7 +88,10 @@ func (widget *Widget) Refresh() {
|
||||
repoPaths := wtf.ToStrs(widget.settings.repositories)
|
||||
|
||||
widget.Data = widget.mercurialRepos(repoPaths)
|
||||
widget.display()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
client *Client
|
||||
settings *Settings
|
||||
}
|
||||
@ -19,6 +20,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -38,9 +40,6 @@ func (widget *Widget) Refresh() {
|
||||
appName = app.Name
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.Name(), appName)))
|
||||
widget.View.Clear()
|
||||
|
||||
var content string
|
||||
if depErr != nil {
|
||||
widget.View.SetWrap(true)
|
||||
@ -50,7 +49,11 @@ func (widget *Widget) Refresh() {
|
||||
content = widget.contentFrom(deploys)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.Name(), appName)))
|
||||
widget.View.Clear()
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -32,8 +34,6 @@ func (widget *Widget) Refresh() {
|
||||
widget.settings.schedule,
|
||||
)
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
@ -43,7 +43,10 @@ func (widget *Widget) Refresh() {
|
||||
content = widget.contentFrom(data)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -19,6 +20,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -42,8 +44,10 @@ func (widget *Widget) Refresh() {
|
||||
incidents, err2 = GetIncidents(widget.settings.apiKey)
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
})
|
||||
|
||||
var content string
|
||||
if err1 != nil || err2 != nil {
|
||||
@ -59,7 +63,9 @@ func (widget *Widget) Refresh() {
|
||||
content = widget.contentFrom(onCalls, incidents)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -18,6 +18,7 @@ var ok = true
|
||||
type Widget struct {
|
||||
wtf.BarGraph
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -26,6 +27,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
BarGraph: wtf.NewBarGraph(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -39,7 +41,6 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
|
||||
// MakeGraph - Load the dead drop stats
|
||||
func MakeGraph(widget *Widget) {
|
||||
|
||||
cpuStats, err := cpu.Percent(time.Duration(0), true)
|
||||
if err != nil {
|
||||
return
|
||||
@ -114,8 +115,9 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
widget.View.Clear()
|
||||
|
||||
display(widget)
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
display(widget)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -27,6 +27,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
items *Result
|
||||
selected int
|
||||
settings *Settings
|
||||
@ -37,6 +38,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -63,13 +65,18 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
} else {
|
||||
widget.items = &items.Results
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -21,6 +21,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
spotigopher.Info
|
||||
spotigopher.SpotifyClient
|
||||
@ -34,7 +35,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
Info: spotigopher.Info{},
|
||||
SpotifyClient: spotifyClient,
|
||||
settings: settings,
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
widget.settings.common.RefreshInterval = 5
|
||||
@ -54,7 +57,9 @@ func (w *Widget) refreshSpotifyInfos() error {
|
||||
}
|
||||
|
||||
func (w *Widget) Refresh() {
|
||||
w.render()
|
||||
w.app.QueueUpdateDraw(func() {
|
||||
w.render()
|
||||
})
|
||||
}
|
||||
|
||||
func (w *Widget) render() {
|
||||
|
@ -48,6 +48,8 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
Info
|
||||
|
||||
app *tview.Application
|
||||
client *spotify.Client
|
||||
clientChan chan *spotify.Client
|
||||
playerState *spotify.PlayerState
|
||||
@ -95,7 +97,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
Info: Info{},
|
||||
Info: Info{},
|
||||
|
||||
app: app,
|
||||
client: client,
|
||||
clientChan: tempClientChan,
|
||||
playerState: playerState,
|
||||
@ -173,7 +177,9 @@ func (w *Widget) refreshSpotifyInfos() error {
|
||||
|
||||
// Refresh refreshes the current view of the widget
|
||||
func (w *Widget) Refresh() {
|
||||
w.render()
|
||||
w.app.QueueUpdateDraw(func() {
|
||||
w.render()
|
||||
})
|
||||
}
|
||||
|
||||
func (w *Widget) render() {
|
||||
|
@ -14,7 +14,7 @@ type Widget struct {
|
||||
Date string
|
||||
Version string
|
||||
|
||||
app *tview.App
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
systemInfo *SystemInfo
|
||||
}
|
||||
|
@ -267,8 +267,10 @@ 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.SetFocus(frame)
|
||||
widget.app.Draw()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.app.SetFocus(frame)
|
||||
})
|
||||
}
|
||||
|
||||
func (widget *Widget) modalForm(lbl, text string) *tview.Form {
|
||||
|
@ -26,6 +26,7 @@ type Widget struct {
|
||||
wtf.HelpfulWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
builds *Builds
|
||||
selected int
|
||||
settings *Settings
|
||||
@ -36,6 +37,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -58,13 +60,18 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
} else {
|
||||
widget.builds = builds
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -40,24 +42,27 @@ func (widget *Widget) Refresh() {
|
||||
widget.settings.list,
|
||||
)
|
||||
|
||||
var title string
|
||||
var content string
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
title = widget.Name()
|
||||
content = err.Error()
|
||||
} else {
|
||||
widget.View.SetWrap(false)
|
||||
widget.View.SetTitle(
|
||||
fmt.Sprintf(
|
||||
"[white]%s: [green]%s ",
|
||||
widget.Name(),
|
||||
widget.settings.board,
|
||||
),
|
||||
title = fmt.Sprintf(
|
||||
"[white]%s: [green]%s ",
|
||||
widget.Name(),
|
||||
widget.settings.board,
|
||||
)
|
||||
content = widget.contentFrom(searchResult)
|
||||
}
|
||||
|
||||
widget.View.SetText(content)
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(title)
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
}
|
||||
|
||||
@ -17,6 +18,7 @@ func NewWidget(app *tview.Application, name string, settings *Settings) *Widget
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, false),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -26,9 +28,11 @@ func NewWidget(app *tview.Application, name string, settings *Settings) *Widget
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
|
||||
content := fmt.Sprintf("Widget %s does not exist", widget.Name())
|
||||
widget.View.SetText(content)
|
||||
content := fmt.Sprintf("Widget %s does not exist", widget.Name())
|
||||
widget.View.SetText(content)
|
||||
})
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ const HelpText = `
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
teams []OnCallTeam
|
||||
settings *Settings
|
||||
}
|
||||
@ -47,12 +48,17 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetText(err.Error())
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.SetText(err.Error())
|
||||
})
|
||||
} else {
|
||||
widget.teams = teams
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
func (widget *Widget) display() {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
result *TicketArray
|
||||
selected int
|
||||
settings *Settings
|
||||
@ -21,6 +22,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@ -39,7 +41,9 @@ func (widget *Widget) Refresh() {
|
||||
widget.result = ticketArray
|
||||
}
|
||||
|
||||
widget.display()
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user