mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Remove the app.Draw() gorountine
Prefer to have widgets force a draw when their data changes. This should reduce draws (unless the user has a module installed that updates >= 1/sec, the old draw default). This should also remove a source of some of the race conditions that users were experiencing (though not all, there are still many).
This commit is contained in:
parent
9bd2430063
commit
f650bb1698
@ -1,9 +1,22 @@
|
||||
wtf:
|
||||
grid:
|
||||
columns: [40]
|
||||
columns: [40, 40]
|
||||
rows: [16]
|
||||
refreshInterval: 1
|
||||
mods:
|
||||
clocks:
|
||||
enabled: true
|
||||
locations:
|
||||
Toronto: "America/Toronto"
|
||||
UTC: "Etc/UTC"
|
||||
Vancouver: "America/Vancouver"
|
||||
position:
|
||||
top: 0
|
||||
left: 0
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 15
|
||||
sort: "chronological"
|
||||
textfile:
|
||||
enabled: true
|
||||
filePaths:
|
||||
@ -12,8 +25,8 @@ wtf:
|
||||
format: true
|
||||
formatStyle: "vim"
|
||||
position:
|
||||
top: 1
|
||||
top: 0
|
||||
left: 1
|
||||
height: 2
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 15
|
||||
|
@ -3,6 +3,7 @@ package bamboohr
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -10,9 +11,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("BambooHR", "bamboohr", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "BambooHR", "bamboohr", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -2,6 +2,8 @@ package circleci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -9,9 +11,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("CircleCI", "circleci", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "CircleCI", "circleci", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -13,9 +14,9 @@ type Widget struct {
|
||||
clockColl ClockCollection
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("World Clocks", "clocks", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "World Clocks", "clocks", false),
|
||||
}
|
||||
|
||||
widget.clockColl = widget.buildClockCollection(wtf.Config.UMap("wtf.mods.clocks.locations"))
|
||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
||||
result string
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" CmdRunner ", "cmdrunner", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "CmdRunner", "cmdrunner", false),
|
||||
|
||||
args: wtf.ToStrs(wtf.Config.UList("wtf.mods.cmdrunner.args")),
|
||||
cmd: wtf.Config.UString("wtf.mods.cmdrunner.cmd"),
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"net/http"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -35,9 +36,9 @@ type Widget struct {
|
||||
}
|
||||
|
||||
// NewWidget Make new instance of widget
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Bittrex ", "bittrex", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Bittrex", "bittrex", false),
|
||||
summaryList: summaryList{},
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -16,9 +17,9 @@ type Widget struct {
|
||||
device_token string
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Blockfolio ", "blockfolio", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Blockfolio", "blockfolio", false),
|
||||
device_token: wtf.Config.UString("wtf.mods.blockfolio.device_token"),
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/price"
|
||||
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/toplist"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
@ -17,9 +18,9 @@ type Widget struct {
|
||||
}
|
||||
|
||||
// NewWidget Make new instance of widget
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "CryptoLive", "cryptolive", false),
|
||||
priceWidget: price.NewWidget(),
|
||||
toplistWidget: toplist.NewWidget(),
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package datadog
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
datadog "github.com/zorkian/go-datadog-api"
|
||||
)
|
||||
@ -11,9 +12,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Datadog", "datadog", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Datadog", "datadog", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -15,9 +16,9 @@ type Widget struct {
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Calendar", "gcal", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Calendar", "gcal", true),
|
||||
ch: make(chan struct{}),
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ var (
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Gerrit", "gerrit", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Gerrit", "gerrit", true),
|
||||
|
||||
Idx: 0,
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget("git", "repository", "repositories"),
|
||||
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Git", "git", true),
|
||||
|
||||
app: app,
|
||||
pages: pages,
|
||||
|
@ -29,7 +29,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("GitHub", "github", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "GitHub", "github", true),
|
||||
|
||||
Idx: 0,
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Gitlab", "gitlab", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Gitlab", "gitlab", true),
|
||||
|
||||
gitlab: gitlab,
|
||||
|
||||
|
@ -31,7 +31,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Gitter", "gitter", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Gitter", "gitter", true),
|
||||
}
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
|
@ -3,6 +3,7 @@ package gspreadsheets
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
sheets "google.golang.org/api/sheets/v4"
|
||||
)
|
||||
@ -11,9 +12,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Google Spreadsheets", "gspreadsheets", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Google Spreadsheets", "gspreadsheets", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -35,7 +35,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Hacker News", "hackernews", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Hacker News", "hackernews", true),
|
||||
}
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
|
@ -1,14 +1,14 @@
|
||||
package ipapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"bytes"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -37,9 +37,9 @@ type ipinfo struct {
|
||||
}
|
||||
|
||||
// NewWidget constructor
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("IPInfo", "ipapi", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "IPInfo", "ipapi", false),
|
||||
}
|
||||
|
||||
widget.View.SetWrap(false)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package ipinfo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"text/template"
|
||||
|
||||
"bytes"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -30,9 +30,9 @@ type ipinfo struct {
|
||||
Organization string `json:"org"`
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("IPInfo", "ipinfo", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "IPInfo", "ipinfo", false),
|
||||
}
|
||||
|
||||
widget.View.SetWrap(false)
|
||||
|
@ -34,7 +34,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Jenkins", "jenkins", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Jenkins", "jenkins", true),
|
||||
}
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
|
@ -33,7 +33,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Jira", "jira", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Jira", "jira", true),
|
||||
}
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -19,9 +20,9 @@ type Widget struct {
|
||||
filePath string
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Logs ", "logger", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Logs", "logger", true),
|
||||
|
||||
filePath: logFilePath(),
|
||||
}
|
||||
|
65
main.go
65
main.go
@ -107,25 +107,6 @@ func loadConfigFile(filePath string) {
|
||||
wtf.Config = Config
|
||||
}
|
||||
|
||||
// redrawApp redraws the rendered views to screen on a defined interval (set in config.yml)
|
||||
// Use this because each textView widget can have it's own update interval, and I don't want to
|
||||
// manage drawing co-ordination amongst them all. If you need to have a
|
||||
// widget redraw on it's own schedule, use the view's SetChangedFunc() and pass it `app`.
|
||||
func redrawApp(app *tview.Application) {
|
||||
tick := time.NewTicker(time.Duration(Config.UInt("wtf.refreshInterval", 2)) * time.Second)
|
||||
quit := make(chan struct{})
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-tick.C:
|
||||
app.Draw()
|
||||
case <-quit:
|
||||
tick.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refreshAllWidgets() {
|
||||
for _, widget := range widgets {
|
||||
go widget.Refresh()
|
||||
@ -181,25 +162,25 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
||||
// Always in alphabetical order
|
||||
switch widgetName {
|
||||
case "bamboohr":
|
||||
widgets = append(widgets, bamboohr.NewWidget())
|
||||
widgets = append(widgets, bamboohr.NewWidget(app))
|
||||
case "bargraph":
|
||||
widgets = append(widgets, bargraph.NewWidget())
|
||||
case "bittrex":
|
||||
widgets = append(widgets, bittrex.NewWidget())
|
||||
widgets = append(widgets, bittrex.NewWidget(app))
|
||||
case "blockfolio":
|
||||
widgets = append(widgets, blockfolio.NewWidget())
|
||||
widgets = append(widgets, blockfolio.NewWidget(app))
|
||||
case "circleci":
|
||||
widgets = append(widgets, circleci.NewWidget())
|
||||
widgets = append(widgets, circleci.NewWidget(app))
|
||||
case "clocks":
|
||||
widgets = append(widgets, clocks.NewWidget())
|
||||
widgets = append(widgets, clocks.NewWidget(app))
|
||||
case "cmdrunner":
|
||||
widgets = append(widgets, cmdrunner.NewWidget())
|
||||
widgets = append(widgets, cmdrunner.NewWidget(app))
|
||||
case "cryptolive":
|
||||
widgets = append(widgets, cryptolive.NewWidget())
|
||||
widgets = append(widgets, cryptolive.NewWidget(app))
|
||||
case "datadog":
|
||||
widgets = append(widgets, datadog.NewWidget())
|
||||
widgets = append(widgets, datadog.NewWidget(app))
|
||||
case "gcal":
|
||||
widgets = append(widgets, gcal.NewWidget())
|
||||
widgets = append(widgets, gcal.NewWidget(app))
|
||||
case "gerrit":
|
||||
widgets = append(widgets, gerrit.NewWidget(app, pages))
|
||||
case "git":
|
||||
@ -211,33 +192,33 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
||||
case "gitter":
|
||||
widgets = append(widgets, gitter.NewWidget(app, pages))
|
||||
case "gspreadsheets":
|
||||
widgets = append(widgets, gspreadsheets.NewWidget())
|
||||
widgets = append(widgets, gspreadsheets.NewWidget(app))
|
||||
case "hackernews":
|
||||
widgets = append(widgets, hackernews.NewWidget(app, pages))
|
||||
case "ipapi":
|
||||
widgets = append(widgets, ipapi.NewWidget())
|
||||
widgets = append(widgets, ipapi.NewWidget(app))
|
||||
case "ipinfo":
|
||||
widgets = append(widgets, ipinfo.NewWidget())
|
||||
widgets = append(widgets, ipinfo.NewWidget(app))
|
||||
case "jenkins":
|
||||
widgets = append(widgets, jenkins.NewWidget(app, pages))
|
||||
case "jira":
|
||||
widgets = append(widgets, jira.NewWidget(app, pages))
|
||||
case "logger":
|
||||
widgets = append(widgets, logger.NewWidget())
|
||||
widgets = append(widgets, logger.NewWidget(app))
|
||||
case "newrelic":
|
||||
widgets = append(widgets, newrelic.NewWidget())
|
||||
widgets = append(widgets, newrelic.NewWidget(app))
|
||||
case "opsgenie":
|
||||
widgets = append(widgets, opsgenie.NewWidget())
|
||||
widgets = append(widgets, opsgenie.NewWidget(app))
|
||||
case "power":
|
||||
widgets = append(widgets, power.NewWidget())
|
||||
widgets = append(widgets, power.NewWidget(app))
|
||||
case "prettyweather":
|
||||
widgets = append(widgets, prettyweather.NewWidget())
|
||||
widgets = append(widgets, prettyweather.NewWidget(app))
|
||||
case "security":
|
||||
widgets = append(widgets, security.NewWidget())
|
||||
widgets = append(widgets, security.NewWidget(app))
|
||||
case "status":
|
||||
widgets = append(widgets, status.NewWidget())
|
||||
widgets = append(widgets, status.NewWidget(app))
|
||||
case "system":
|
||||
widgets = append(widgets, system.NewWidget(date, version))
|
||||
widgets = append(widgets, system.NewWidget(app, date, version))
|
||||
case "textfile":
|
||||
widgets = append(widgets, textfile.NewWidget(app, pages))
|
||||
case "todo":
|
||||
@ -247,13 +228,13 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
||||
case "travisci":
|
||||
widgets = append(widgets, travisci.NewWidget(app, pages))
|
||||
case "trello":
|
||||
widgets = append(widgets, trello.NewWidget())
|
||||
widgets = append(widgets, trello.NewWidget(app))
|
||||
case "twitter":
|
||||
widgets = append(widgets, twitter.NewWidget(app, pages))
|
||||
case "weather":
|
||||
widgets = append(widgets, weather.NewWidget(app, pages))
|
||||
case "zendesk":
|
||||
widgets = append(widgets, zendesk.NewWidget())
|
||||
widgets = append(widgets, zendesk.NewWidget(app))
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -298,8 +279,6 @@ func main() {
|
||||
pages.AddPage("grid", display.Grid, true, true)
|
||||
app.SetInputCapture(keyboardIntercept)
|
||||
|
||||
// Loop in a routine to redraw the screen
|
||||
//go redrawApp(app)
|
||||
go watchForConfigChanges(app, flags.Config, display.Grid, pages)
|
||||
|
||||
if err := app.SetRoot(pages, true).Run(); err != nil {
|
||||
|
@ -3,6 +3,7 @@ package newrelic
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
nr "github.com/yfronto/newrelic"
|
||||
)
|
||||
@ -11,9 +12,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("New Relic", "newrelic", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "New Relic", "newrelic", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -11,9 +12,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("OpsGenie", "opsgenie", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "OpsGenie", "opsgenie", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -3,6 +3,7 @@ package power
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -12,9 +13,9 @@ type Widget struct {
|
||||
Battery *Battery
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Power", "power", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Power", "power", false),
|
||||
Battery: NewBattery(),
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -13,9 +14,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Security", "security", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Security", "security", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -13,9 +14,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Security", "security", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Security", "security", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -1,6 +1,7 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -10,9 +11,9 @@ type Widget struct {
|
||||
CurrentIcon int
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Status", "status", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Status", "status", false),
|
||||
CurrentIcon: 0,
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -15,9 +16,9 @@ type Widget struct {
|
||||
Version string
|
||||
}
|
||||
|
||||
func NewWidget(date, version string) *Widget {
|
||||
func NewWidget(app *tview.Application, date, version string) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("System", "system", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "System", "system", false),
|
||||
|
||||
Date: date,
|
||||
Version: version,
|
||||
|
@ -40,7 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget("textfile", "filePath", "filePaths"),
|
||||
TextWidget: wtf.NewTextWidget("TextFile", "textfile", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "TextFile", "textfile", true),
|
||||
}
|
||||
|
||||
// Don't use a timer for this widget, watch for filesystem changes instead
|
||||
@ -54,9 +54,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetWordWrap(true)
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
widget.View.SetChangedFunc(func() {
|
||||
app.Draw()
|
||||
})
|
||||
|
||||
go widget.watchForFileChanges()
|
||||
|
||||
@ -85,8 +82,10 @@ func (widget *Widget) display() {
|
||||
text = text + widget.plainText()
|
||||
}
|
||||
|
||||
widget.View.SetTitle(title)
|
||||
widget.View.SetText(text)
|
||||
//widget.View.Lock()
|
||||
widget.View.SetTitle(title) // <- Writes to TextView's title
|
||||
widget.View.SetText(text) // <- Writes to TextView's text
|
||||
//widget.View.Unlock()
|
||||
}
|
||||
|
||||
func (widget *Widget) fileName() string {
|
||||
|
@ -48,7 +48,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Todo", "todo", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Todo", "todo", true),
|
||||
|
||||
app: app,
|
||||
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
|
||||
|
@ -38,7 +38,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Todoist", "todoist", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Todoist", "todoist", true),
|
||||
}
|
||||
|
||||
widget.loadAPICredentials()
|
||||
|
@ -33,7 +33,7 @@ type Widget struct {
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("TravisCI", "travisci", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "TravisCI", "travisci", true),
|
||||
}
|
||||
|
||||
widget.HelpfulWidget.SetView(widget.View)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/adlio/trello"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -12,9 +13,9 @@ type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Trello", "trello", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Trello", "trello", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -36,7 +36,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget("twitter", "screenName", "screenNames"),
|
||||
TextWidget: wtf.NewTextWidget("Twitter", "twitter", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Twitter", "twitter", true),
|
||||
|
||||
idx: 0,
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -17,9 +18,9 @@ type Widget struct {
|
||||
language string
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Pretty Weather", "prettyweather", false),
|
||||
TextWidget: wtf.NewTextWidget(app, "Pretty Weather", "prettyweather", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -35,7 +35,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
configKey := "weather"
|
||||
widget := Widget{
|
||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||
TextWidget: wtf.NewTextWidget("Weather", configKey, true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Weather", configKey, true),
|
||||
|
||||
Idx: 0,
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type TextWidget struct {
|
||||
Position
|
||||
}
|
||||
|
||||
func NewTextWidget(name string, configKey string, focusable bool) TextWidget {
|
||||
func NewTextWidget(app *tview.Application, name string, configKey string, focusable bool) TextWidget {
|
||||
widget := TextWidget{
|
||||
enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false),
|
||||
focusable: focusable,
|
||||
@ -39,7 +39,7 @@ func NewTextWidget(name string, configKey string, focusable bool) TextWidget {
|
||||
Config.UInt(fmt.Sprintf("wtf.mods.%s.position.height", configKey)),
|
||||
)
|
||||
|
||||
widget.addView()
|
||||
widget.addView(app)
|
||||
|
||||
return widget
|
||||
}
|
||||
@ -96,12 +96,15 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *TextWidget) addView() {
|
||||
func (widget *TextWidget) addView(app *tview.Application) {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||
view.SetBorder(true)
|
||||
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||
view.SetChangedFunc(func() {
|
||||
app.Draw()
|
||||
})
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
view.SetWrap(false)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -16,9 +16,9 @@ type Widget struct {
|
||||
selected int
|
||||
}
|
||||
|
||||
func NewWidget() *Widget {
|
||||
func NewWidget(app *tview.Application) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("Zendesk", "zendesk", true),
|
||||
TextWidget: wtf.NewTextWidget(app, "Zendesk", "zendesk", true),
|
||||
}
|
||||
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
|
Loading…
x
Reference in New Issue
Block a user