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:
|
wtf:
|
||||||
grid:
|
grid:
|
||||||
columns: [40]
|
columns: [40, 40]
|
||||||
rows: [16]
|
rows: [16]
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
mods:
|
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:
|
textfile:
|
||||||
enabled: true
|
enabled: true
|
||||||
filePaths:
|
filePaths:
|
||||||
@ -12,8 +25,8 @@ wtf:
|
|||||||
format: true
|
format: true
|
||||||
formatStyle: "vim"
|
formatStyle: "vim"
|
||||||
position:
|
position:
|
||||||
top: 1
|
top: 0
|
||||||
left: 1
|
left: 1
|
||||||
height: 2
|
height: 1
|
||||||
width: 1
|
width: 1
|
||||||
refreshInterval: 15
|
refreshInterval: 15
|
||||||
|
@ -3,6 +3,7 @@ package bamboohr
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -10,9 +11,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("BambooHR", "bamboohr", false),
|
TextWidget: wtf.NewTextWidget(app, "BambooHR", "bamboohr", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -22,7 +22,7 @@ type Widget struct {
|
|||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget() *Widget {
|
func NewWidget() *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
BarGraph: wtf.NewBarGraph(" Sample Bar Graph", "bargraph", false),
|
BarGraph: wtf.NewBarGraph("Sample Bar Graph", "bargraph", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
|
@ -2,6 +2,8 @@ package circleci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -9,9 +11,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("CircleCI", "circleci", false),
|
TextWidget: wtf.NewTextWidget(app, "CircleCI", "circleci", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,9 +14,9 @@ type Widget struct {
|
|||||||
clockColl ClockCollection
|
clockColl ClockCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := 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"))
|
widget.clockColl = widget.buildClockCollection(wtf.Config.UMap("wtf.mods.clocks.locations"))
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
result string
|
result string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := 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")),
|
args: wtf.ToStrs(wtf.Config.UList("wtf.mods.cmdrunner.args")),
|
||||||
cmd: wtf.Config.UString("wtf.mods.cmdrunner.cmd"),
|
cmd: wtf.Config.UString("wtf.mods.cmdrunner.cmd"),
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,9 +36,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" Bittrex ", "bittrex", false),
|
TextWidget: wtf.NewTextWidget(app, "Bittrex", "bittrex", false),
|
||||||
summaryList: summaryList{},
|
summaryList: summaryList{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,9 +17,9 @@ type Widget struct {
|
|||||||
device_token string
|
device_token string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := 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"),
|
device_token: wtf.Config.UString("wtf.mods.blockfolio.device_token"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/price"
|
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/price"
|
||||||
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/toplist"
|
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/toplist"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
@ -17,9 +18,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
|
TextWidget: wtf.NewTextWidget(app, "CryptoLive", "cryptolive", false),
|
||||||
priceWidget: price.NewWidget(),
|
priceWidget: price.NewWidget(),
|
||||||
toplistWidget: toplist.NewWidget(),
|
toplistWidget: toplist.NewWidget(),
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package datadog
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
datadog "github.com/zorkian/go-datadog-api"
|
datadog "github.com/zorkian/go-datadog-api"
|
||||||
)
|
)
|
||||||
@ -11,9 +12,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Datadog", "datadog", false),
|
TextWidget: wtf.NewTextWidget(app, "Datadog", "datadog", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,9 +16,9 @@ type Widget struct {
|
|||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Calendar", "gcal", true),
|
TextWidget: wtf.NewTextWidget(app, "Calendar", "gcal", true),
|
||||||
ch: make(chan struct{}),
|
ch: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ const HelpText = `
|
|||||||
arrow right: Show the next project
|
arrow right: Show the next project
|
||||||
arrow down: Select the next review in the list
|
arrow down: Select the next review in the list
|
||||||
arrow up: Select the previous review in the list
|
arrow up: Select the previous review in the list
|
||||||
|
|
||||||
return: Open the selected review in a browser
|
return: Open the selected review in a browser
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ var (
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Gerrit", "gerrit", true),
|
TextWidget: wtf.NewTextWidget(app, "Gerrit", "gerrit", true),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
MultiSourceWidget: wtf.NewMultiSourceWidget("git", "repository", "repositories"),
|
MultiSourceWidget: wtf.NewMultiSourceWidget("git", "repository", "repositories"),
|
||||||
TextWidget: wtf.NewTextWidget("Git", "git", true),
|
TextWidget: wtf.NewTextWidget(app, "Git", "git", true),
|
||||||
|
|
||||||
app: app,
|
app: app,
|
||||||
pages: pages,
|
pages: pages,
|
||||||
|
@ -29,7 +29,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("GitHub", "github", true),
|
TextWidget: wtf.NewTextWidget(app, "GitHub", "github", true),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
|||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Gitlab", "gitlab", true),
|
TextWidget: wtf.NewTextWidget(app, "Gitlab", "gitlab", true),
|
||||||
|
|
||||||
gitlab: gitlab,
|
gitlab: gitlab,
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Gitter", "gitter", true),
|
TextWidget: wtf.NewTextWidget(app, "Gitter", "gitter", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
|
@ -3,6 +3,7 @@ package gspreadsheets
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
sheets "google.golang.org/api/sheets/v4"
|
sheets "google.golang.org/api/sheets/v4"
|
||||||
)
|
)
|
||||||
@ -11,9 +12,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Google Spreadsheets", "gspreadsheets", false),
|
TextWidget: wtf.NewTextWidget(app, "Google Spreadsheets", "gspreadsheets", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -35,7 +35,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
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)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package ipapi
|
package ipapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"bytes"
|
"github.com/rivo/tview"
|
||||||
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ type ipinfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget constructor
|
// NewWidget constructor
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("IPInfo", "ipapi", false),
|
TextWidget: wtf.NewTextWidget(app, "IPInfo", "ipapi", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetWrap(false)
|
widget.View.SetWrap(false)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package ipinfo
|
package ipinfo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"bytes"
|
"github.com/rivo/tview"
|
||||||
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ type ipinfo struct {
|
|||||||
Organization string `json:"org"`
|
Organization string `json:"org"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("IPInfo", "ipinfo", false),
|
TextWidget: wtf.NewTextWidget(app, "IPInfo", "ipinfo", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetWrap(false)
|
widget.View.SetWrap(false)
|
||||||
|
@ -34,7 +34,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Jenkins", "jenkins", true),
|
TextWidget: wtf.NewTextWidget(app, "Jenkins", "jenkins", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
|
@ -33,7 +33,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Jira", "jira", true),
|
TextWidget: wtf.NewTextWidget(app, "Jira", "jira", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,9 +20,9 @@ type Widget struct {
|
|||||||
filePath string
|
filePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" Logs ", "logger", true),
|
TextWidget: wtf.NewTextWidget(app, "Logs", "logger", true),
|
||||||
|
|
||||||
filePath: logFilePath(),
|
filePath: logFilePath(),
|
||||||
}
|
}
|
||||||
|
65
main.go
65
main.go
@ -107,25 +107,6 @@ func loadConfigFile(filePath string) {
|
|||||||
wtf.Config = Config
|
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() {
|
func refreshAllWidgets() {
|
||||||
for _, widget := range widgets {
|
for _, widget := range widgets {
|
||||||
go widget.Refresh()
|
go widget.Refresh()
|
||||||
@ -181,25 +162,25 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
|||||||
// Always in alphabetical order
|
// Always in alphabetical order
|
||||||
switch widgetName {
|
switch widgetName {
|
||||||
case "bamboohr":
|
case "bamboohr":
|
||||||
widgets = append(widgets, bamboohr.NewWidget())
|
widgets = append(widgets, bamboohr.NewWidget(app))
|
||||||
case "bargraph":
|
case "bargraph":
|
||||||
widgets = append(widgets, bargraph.NewWidget())
|
widgets = append(widgets, bargraph.NewWidget())
|
||||||
case "bittrex":
|
case "bittrex":
|
||||||
widgets = append(widgets, bittrex.NewWidget())
|
widgets = append(widgets, bittrex.NewWidget(app))
|
||||||
case "blockfolio":
|
case "blockfolio":
|
||||||
widgets = append(widgets, blockfolio.NewWidget())
|
widgets = append(widgets, blockfolio.NewWidget(app))
|
||||||
case "circleci":
|
case "circleci":
|
||||||
widgets = append(widgets, circleci.NewWidget())
|
widgets = append(widgets, circleci.NewWidget(app))
|
||||||
case "clocks":
|
case "clocks":
|
||||||
widgets = append(widgets, clocks.NewWidget())
|
widgets = append(widgets, clocks.NewWidget(app))
|
||||||
case "cmdrunner":
|
case "cmdrunner":
|
||||||
widgets = append(widgets, cmdrunner.NewWidget())
|
widgets = append(widgets, cmdrunner.NewWidget(app))
|
||||||
case "cryptolive":
|
case "cryptolive":
|
||||||
widgets = append(widgets, cryptolive.NewWidget())
|
widgets = append(widgets, cryptolive.NewWidget(app))
|
||||||
case "datadog":
|
case "datadog":
|
||||||
widgets = append(widgets, datadog.NewWidget())
|
widgets = append(widgets, datadog.NewWidget(app))
|
||||||
case "gcal":
|
case "gcal":
|
||||||
widgets = append(widgets, gcal.NewWidget())
|
widgets = append(widgets, gcal.NewWidget(app))
|
||||||
case "gerrit":
|
case "gerrit":
|
||||||
widgets = append(widgets, gerrit.NewWidget(app, pages))
|
widgets = append(widgets, gerrit.NewWidget(app, pages))
|
||||||
case "git":
|
case "git":
|
||||||
@ -211,33 +192,33 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
|||||||
case "gitter":
|
case "gitter":
|
||||||
widgets = append(widgets, gitter.NewWidget(app, pages))
|
widgets = append(widgets, gitter.NewWidget(app, pages))
|
||||||
case "gspreadsheets":
|
case "gspreadsheets":
|
||||||
widgets = append(widgets, gspreadsheets.NewWidget())
|
widgets = append(widgets, gspreadsheets.NewWidget(app))
|
||||||
case "hackernews":
|
case "hackernews":
|
||||||
widgets = append(widgets, hackernews.NewWidget(app, pages))
|
widgets = append(widgets, hackernews.NewWidget(app, pages))
|
||||||
case "ipapi":
|
case "ipapi":
|
||||||
widgets = append(widgets, ipapi.NewWidget())
|
widgets = append(widgets, ipapi.NewWidget(app))
|
||||||
case "ipinfo":
|
case "ipinfo":
|
||||||
widgets = append(widgets, ipinfo.NewWidget())
|
widgets = append(widgets, ipinfo.NewWidget(app))
|
||||||
case "jenkins":
|
case "jenkins":
|
||||||
widgets = append(widgets, jenkins.NewWidget(app, pages))
|
widgets = append(widgets, jenkins.NewWidget(app, pages))
|
||||||
case "jira":
|
case "jira":
|
||||||
widgets = append(widgets, jira.NewWidget(app, pages))
|
widgets = append(widgets, jira.NewWidget(app, pages))
|
||||||
case "logger":
|
case "logger":
|
||||||
widgets = append(widgets, logger.NewWidget())
|
widgets = append(widgets, logger.NewWidget(app))
|
||||||
case "newrelic":
|
case "newrelic":
|
||||||
widgets = append(widgets, newrelic.NewWidget())
|
widgets = append(widgets, newrelic.NewWidget(app))
|
||||||
case "opsgenie":
|
case "opsgenie":
|
||||||
widgets = append(widgets, opsgenie.NewWidget())
|
widgets = append(widgets, opsgenie.NewWidget(app))
|
||||||
case "power":
|
case "power":
|
||||||
widgets = append(widgets, power.NewWidget())
|
widgets = append(widgets, power.NewWidget(app))
|
||||||
case "prettyweather":
|
case "prettyweather":
|
||||||
widgets = append(widgets, prettyweather.NewWidget())
|
widgets = append(widgets, prettyweather.NewWidget(app))
|
||||||
case "security":
|
case "security":
|
||||||
widgets = append(widgets, security.NewWidget())
|
widgets = append(widgets, security.NewWidget(app))
|
||||||
case "status":
|
case "status":
|
||||||
widgets = append(widgets, status.NewWidget())
|
widgets = append(widgets, status.NewWidget(app))
|
||||||
case "system":
|
case "system":
|
||||||
widgets = append(widgets, system.NewWidget(date, version))
|
widgets = append(widgets, system.NewWidget(app, date, version))
|
||||||
case "textfile":
|
case "textfile":
|
||||||
widgets = append(widgets, textfile.NewWidget(app, pages))
|
widgets = append(widgets, textfile.NewWidget(app, pages))
|
||||||
case "todo":
|
case "todo":
|
||||||
@ -247,13 +228,13 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
|||||||
case "travisci":
|
case "travisci":
|
||||||
widgets = append(widgets, travisci.NewWidget(app, pages))
|
widgets = append(widgets, travisci.NewWidget(app, pages))
|
||||||
case "trello":
|
case "trello":
|
||||||
widgets = append(widgets, trello.NewWidget())
|
widgets = append(widgets, trello.NewWidget(app))
|
||||||
case "twitter":
|
case "twitter":
|
||||||
widgets = append(widgets, twitter.NewWidget(app, pages))
|
widgets = append(widgets, twitter.NewWidget(app, pages))
|
||||||
case "weather":
|
case "weather":
|
||||||
widgets = append(widgets, weather.NewWidget(app, pages))
|
widgets = append(widgets, weather.NewWidget(app, pages))
|
||||||
case "zendesk":
|
case "zendesk":
|
||||||
widgets = append(widgets, zendesk.NewWidget())
|
widgets = append(widgets, zendesk.NewWidget(app))
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,8 +279,6 @@ func main() {
|
|||||||
pages.AddPage("grid", display.Grid, true, true)
|
pages.AddPage("grid", display.Grid, true, true)
|
||||||
app.SetInputCapture(keyboardIntercept)
|
app.SetInputCapture(keyboardIntercept)
|
||||||
|
|
||||||
// Loop in a routine to redraw the screen
|
|
||||||
//go redrawApp(app)
|
|
||||||
go watchForConfigChanges(app, flags.Config, display.Grid, pages)
|
go watchForConfigChanges(app, flags.Config, display.Grid, pages)
|
||||||
|
|
||||||
if err := app.SetRoot(pages, true).Run(); err != nil {
|
if err := app.SetRoot(pages, true).Run(); err != nil {
|
||||||
|
@ -3,6 +3,7 @@ package newrelic
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
nr "github.com/yfronto/newrelic"
|
nr "github.com/yfronto/newrelic"
|
||||||
)
|
)
|
||||||
@ -11,9 +12,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("New Relic", "newrelic", false),
|
TextWidget: wtf.NewTextWidget(app, "New Relic", "newrelic", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,9 +12,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("OpsGenie", "opsgenie", false),
|
TextWidget: wtf.NewTextWidget(app, "OpsGenie", "opsgenie", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -3,6 +3,7 @@ package power
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,9 +13,9 @@ type Widget struct {
|
|||||||
Battery *Battery
|
Battery *Battery
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Power", "power", false),
|
TextWidget: wtf.NewTextWidget(app, "Power", "power", false),
|
||||||
Battery: NewBattery(),
|
Battery: NewBattery(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,9 +14,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Security", "security", false),
|
TextWidget: wtf.NewTextWidget(app, "Security", "security", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,9 +14,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Security", "security", false),
|
TextWidget: wtf.NewTextWidget(app, "Security", "security", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -10,9 +11,9 @@ type Widget struct {
|
|||||||
CurrentIcon int
|
CurrentIcon int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Status", "status", false),
|
TextWidget: wtf.NewTextWidget(app, "Status", "status", false),
|
||||||
CurrentIcon: 0,
|
CurrentIcon: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,9 +16,9 @@ type Widget struct {
|
|||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(date, version string) *Widget {
|
func NewWidget(app *tview.Application, date, version string) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("System", "system", false),
|
TextWidget: wtf.NewTextWidget(app, "System", "system", false),
|
||||||
|
|
||||||
Date: date,
|
Date: date,
|
||||||
Version: version,
|
Version: version,
|
||||||
|
@ -40,7 +40,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
MultiSourceWidget: wtf.NewMultiSourceWidget("textfile", "filePath", "filePaths"),
|
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
|
// 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.SetWrap(true)
|
||||||
widget.View.SetWordWrap(true)
|
widget.View.SetWordWrap(true)
|
||||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||||
widget.View.SetChangedFunc(func() {
|
|
||||||
app.Draw()
|
|
||||||
})
|
|
||||||
|
|
||||||
go widget.watchForFileChanges()
|
go widget.watchForFileChanges()
|
||||||
|
|
||||||
@ -85,8 +82,10 @@ func (widget *Widget) display() {
|
|||||||
text = text + widget.plainText()
|
text = text + widget.plainText()
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetTitle(title)
|
//widget.View.Lock()
|
||||||
widget.View.SetText(text)
|
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 {
|
func (widget *Widget) fileName() string {
|
||||||
|
@ -48,7 +48,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Todo", "todo", true),
|
TextWidget: wtf.NewTextWidget(app, "Todo", "todo", true),
|
||||||
|
|
||||||
app: app,
|
app: app,
|
||||||
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
|
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
|
||||||
|
@ -38,7 +38,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Todoist", "todoist", true),
|
TextWidget: wtf.NewTextWidget(app, "Todoist", "todoist", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.loadAPICredentials()
|
widget.loadAPICredentials()
|
||||||
|
@ -33,7 +33,7 @@ type Widget struct {
|
|||||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("TravisCI", "travisci", true),
|
TextWidget: wtf.NewTextWidget(app, "TravisCI", "travisci", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.HelpfulWidget.SetView(widget.View)
|
widget.HelpfulWidget.SetView(widget.View)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/adlio/trello"
|
"github.com/adlio/trello"
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,9 +13,9 @@ type Widget struct {
|
|||||||
wtf.TextWidget
|
wtf.TextWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Trello", "trello", false),
|
TextWidget: wtf.NewTextWidget(app, "Trello", "trello", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -36,7 +36,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
|||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
MultiSourceWidget: wtf.NewMultiSourceWidget("twitter", "screenName", "screenNames"),
|
MultiSourceWidget: wtf.NewMultiSourceWidget("twitter", "screenName", "screenNames"),
|
||||||
TextWidget: wtf.NewTextWidget("Twitter", "twitter", true),
|
TextWidget: wtf.NewTextWidget(app, "Twitter", "twitter", true),
|
||||||
|
|
||||||
idx: 0,
|
idx: 0,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,9 +18,9 @@ type Widget struct {
|
|||||||
language string
|
language string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Pretty Weather", "prettyweather", false),
|
TextWidget: wtf.NewTextWidget(app, "Pretty Weather", "prettyweather", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
|
@ -35,7 +35,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
|||||||
configKey := "weather"
|
configKey := "weather"
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
|
||||||
TextWidget: wtf.NewTextWidget("Weather", configKey, true),
|
TextWidget: wtf.NewTextWidget(app, "Weather", configKey, true),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ type TextWidget struct {
|
|||||||
Position
|
Position
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTextWidget(name string, configKey string, focusable bool) TextWidget {
|
func NewTextWidget(app *tview.Application, name string, configKey string, focusable bool) TextWidget {
|
||||||
widget := TextWidget{
|
widget := TextWidget{
|
||||||
enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false),
|
enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false),
|
||||||
focusable: focusable,
|
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)),
|
Config.UInt(fmt.Sprintf("wtf.mods.%s.position.height", configKey)),
|
||||||
)
|
)
|
||||||
|
|
||||||
widget.addView()
|
widget.addView(app)
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
@ -96,12 +96,15 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *TextWidget) addView() {
|
func (widget *TextWidget) addView(app *tview.Application) {
|
||||||
view := tview.NewTextView()
|
view := tview.NewTextView()
|
||||||
|
|
||||||
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||||
view.SetBorder(true)
|
view.SetBorder(true)
|
||||||
view.SetBorderColor(colorFor(widget.BorderColor()))
|
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||||
|
view.SetChangedFunc(func() {
|
||||||
|
app.Draw()
|
||||||
|
})
|
||||||
view.SetDynamicColors(true)
|
view.SetDynamicColors(true)
|
||||||
view.SetTitle(widget.ContextualTitle(widget.Name))
|
view.SetTitle(widget.ContextualTitle(widget.Name))
|
||||||
view.SetWrap(false)
|
view.SetWrap(false)
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
"github.com/rivo/tview"
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,9 +16,9 @@ type Widget struct {
|
|||||||
selected int
|
selected int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget() *Widget {
|
func NewWidget(app *tview.Application) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget("Zendesk", "zendesk", true),
|
TextWidget: wtf.NewTextWidget(app, "Zendesk", "zendesk", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user