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