mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
☢️ WTF-1031 Support multiple simultaneous configurations (#1032)
* WTF-1031 Rename WtfApp.app to WtfApp.tviewApp Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-1031 Add scaffolding for main to support multiple WtfApp instances Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-1031 WIP Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove common functionality from KeyboardWidget and into Base Signed-off-by: Chris Cummer <chriscummer@me.com> * Augment with some descriptive comments Signed-off-by: Chris Cummer <chriscummer@me.com> * Add full support for multiple app instances via the AppManager. Still to do: * Config support for multiple apps/multiple config files * The ability to switch between apps Signed-off-by: Chris Cummer <chriscummer@me.com> * Move SetTerminal out of main and into its own file Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
9ba22f656b
commit
fd794707cd
71
app/app_manager.go
Normal file
71
app/app_manager.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/olebedev/config"
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WtfAppManager handles the instances of WtfApp, ensuring that they're displayed as requested
|
||||||
|
type WtfAppManager struct {
|
||||||
|
WtfApps []*WtfApp
|
||||||
|
|
||||||
|
selected int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAppManager creates and returns an instance of AppManager
|
||||||
|
func NewAppManager() WtfAppManager {
|
||||||
|
appMan := WtfAppManager{
|
||||||
|
WtfApps: []*WtfApp{},
|
||||||
|
}
|
||||||
|
|
||||||
|
return appMan
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeNewWtfApp creates and starts a new instance of WtfApp from a set of configuration params
|
||||||
|
func (appMan *WtfAppManager) MakeNewWtfApp(config *config.Config, configFilePath string) {
|
||||||
|
wtfApp := NewWtfApp(tview.NewApplication(), config, configFilePath)
|
||||||
|
appMan.Add(wtfApp)
|
||||||
|
|
||||||
|
wtfApp.Start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add adds a WtfApp to the collection of apps that the AppManager manages.
|
||||||
|
// This app is then available for display onscreen.
|
||||||
|
func (appMan *WtfAppManager) Add(wtfApp *WtfApp) {
|
||||||
|
appMan.WtfApps = append(appMan.WtfApps, wtfApp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current returns the currently-displaying instance of WtfApp
|
||||||
|
func (appMan *WtfAppManager) Current() (*WtfApp, error) {
|
||||||
|
if appMan.selected < 0 || appMan.selected >= len(appMan.WtfApps) {
|
||||||
|
return nil, errors.New("invalid app index selected")
|
||||||
|
}
|
||||||
|
|
||||||
|
return appMan.WtfApps[appMan.selected], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next cycles the WtfApps forward by one, making the next one in the list
|
||||||
|
// the current one. If there are none after the current one, it wraps around.
|
||||||
|
func (appMan *WtfAppManager) Next() (*WtfApp, error) {
|
||||||
|
appMan.selected++
|
||||||
|
|
||||||
|
if appMan.selected >= len(appMan.WtfApps) {
|
||||||
|
appMan.selected = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return appMan.Current()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prev cycles the WtfApps backwards by one, making the previous one in the
|
||||||
|
// list the current one. If there are none before the current one, it wraps around.
|
||||||
|
func (appMan *WtfAppManager) Prev() (*WtfApp, error) {
|
||||||
|
appMan.selected--
|
||||||
|
|
||||||
|
if appMan.selected < 0 {
|
||||||
|
appMan.selected = len(appMan.WtfApps) - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return appMan.Current()
|
||||||
|
}
|
@ -84,14 +84,14 @@ func readGitHubAPIKey(cfg *config.Config) string {
|
|||||||
|
|
||||||
func (wtfApp *WtfApp) contributorThankYouMessage() string {
|
func (wtfApp *WtfApp) contributorThankYouMessage() string {
|
||||||
str := " On behalf of all the users of WTF, thank you for contributing to the source code."
|
str := " On behalf of all the users of WTF, thank you for contributing to the source code."
|
||||||
str += fmt.Sprintf(" %s", aurora.Green("You rock."))
|
str += fmt.Sprintf(" %s", aurora.Green("\n\n You rock."))
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wtfApp *WtfApp) sponsorThankYouMessage() string {
|
func (wtfApp *WtfApp) sponsorThankYouMessage() string {
|
||||||
str := " Your sponsorship of WTF makes a difference. Thank you for sponsoring and supporting WTF."
|
str := " Your sponsorship of WTF makes a difference. Thank you for sponsoring and supporting WTF."
|
||||||
str += fmt.Sprintf(" %s", aurora.Green("You're awesome."))
|
str += fmt.Sprintf(" %s", aurora.Green("\n\n You're awesome."))
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/wtfutil/wtf/wtf"
|
"github.com/wtfutil/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FocusState is a custom type that differentiates focusable scopes
|
||||||
type FocusState int
|
type FocusState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -20,17 +21,18 @@ const (
|
|||||||
// FocusTracker is used by the app to track which onscreen widget currently has focus,
|
// FocusTracker is used by the app to track which onscreen widget currently has focus,
|
||||||
// and to move focus between widgets.
|
// and to move focus between widgets.
|
||||||
type FocusTracker struct {
|
type FocusTracker struct {
|
||||||
App *tview.Application
|
|
||||||
Idx int
|
Idx int
|
||||||
IsFocused bool
|
IsFocused bool
|
||||||
Widgets []wtf.Wtfable
|
Widgets []wtf.Wtfable
|
||||||
|
|
||||||
config *config.Config
|
config *config.Config
|
||||||
|
tviewApp *tview.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFocusTracker(app *tview.Application, widgets []wtf.Wtfable, config *config.Config) FocusTracker {
|
// NewFocusTracker creates and returns an instance of FocusTracker
|
||||||
|
func NewFocusTracker(tviewApp *tview.Application, widgets []wtf.Wtfable, config *config.Config) FocusTracker {
|
||||||
focusTracker := FocusTracker{
|
focusTracker := FocusTracker{
|
||||||
App: app,
|
tviewApp: tviewApp,
|
||||||
Idx: -1,
|
Idx: -1,
|
||||||
IsFocused: false,
|
IsFocused: false,
|
||||||
Widgets: widgets,
|
Widgets: widgets,
|
||||||
@ -45,6 +47,7 @@ func NewFocusTracker(app *tview.Application, widgets []wtf.Wtfable, config *conf
|
|||||||
|
|
||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
|
// FocusOn puts the focus on the item that belongs to the focus character passed in
|
||||||
func (tracker *FocusTracker) FocusOn(char string) bool {
|
func (tracker *FocusTracker) FocusOn(char string) bool {
|
||||||
if !tracker.useNavShortcuts() {
|
if !tracker.useNavShortcuts() {
|
||||||
return false
|
return false
|
||||||
@ -108,6 +111,7 @@ func (tracker *FocusTracker) Prev() {
|
|||||||
tracker.IsFocused = true
|
tracker.IsFocused = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refocus forces the focus back to the currently-selected item
|
||||||
func (tracker *FocusTracker) Refocus() {
|
func (tracker *FocusTracker) Refocus() {
|
||||||
tracker.focus(tracker.Idx)
|
tracker.focus(tracker.Idx)
|
||||||
}
|
}
|
||||||
@ -196,7 +200,7 @@ func (tracker *FocusTracker) focus(idx int) {
|
|||||||
widget.CommonSettings().Colors.BorderTheme.Focused,
|
widget.CommonSettings().Colors.BorderTheme.Focused,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
tracker.App.SetFocus(view)
|
tracker.tviewApp.SetFocus(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tracker *FocusTracker) focusables() []wtf.Wtfable {
|
func (tracker *FocusTracker) focusables() []wtf.Wtfable {
|
||||||
@ -239,7 +243,7 @@ func (tracker *FocusTracker) focusState() FocusState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, widget := range tracker.Widgets {
|
for _, widget := range tracker.Widgets {
|
||||||
if widget.TextView() == tracker.App.GetFocus() {
|
if widget.TextView() == tracker.tviewApp.GetFocus() {
|
||||||
return widgetFocused
|
return widgetFocused
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/wtfutil/wtf/wtf"
|
"github.com/wtfutil/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ModuleValidator is responsible for validating the state of a module's configuration
|
||||||
type ModuleValidator struct{}
|
type ModuleValidator struct{}
|
||||||
|
|
||||||
type widgetError struct {
|
type widgetError struct {
|
||||||
@ -16,6 +17,7 @@ type widgetError struct {
|
|||||||
validationErrors []cfg.Validatable
|
validationErrors []cfg.Validatable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewModuleValidator creates and returns an instance of ModuleValidator
|
||||||
func NewModuleValidator() *ModuleValidator {
|
func NewModuleValidator() *ModuleValidator {
|
||||||
return &ModuleValidator{}
|
return &ModuleValidator{}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ import (
|
|||||||
|
|
||||||
// MakeWidget creates and returns instances of widgets
|
// MakeWidget creates and returns instances of widgets
|
||||||
func MakeWidget(
|
func MakeWidget(
|
||||||
app *tview.Application,
|
tviewApp *tview.Application,
|
||||||
pages *tview.Pages,
|
pages *tview.Pages,
|
||||||
moduleName string,
|
moduleName string,
|
||||||
config *config.Config,
|
config *config.Config,
|
||||||
@ -103,239 +103,239 @@ func MakeWidget(
|
|||||||
switch moduleConfig.UString("type", moduleName) {
|
switch moduleConfig.UString("type", moduleName) {
|
||||||
case "arpansagovau":
|
case "arpansagovau":
|
||||||
settings := arpansagovau.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := arpansagovau.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = arpansagovau.NewWidget(app, settings)
|
widget = arpansagovau.NewWidget(tviewApp, settings)
|
||||||
case "azuredevops":
|
case "azuredevops":
|
||||||
settings := azuredevops.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := azuredevops.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = azuredevops.NewWidget(app, pages, settings)
|
widget = azuredevops.NewWidget(tviewApp, pages, settings)
|
||||||
case "bamboohr":
|
case "bamboohr":
|
||||||
settings := bamboohr.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := bamboohr.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = bamboohr.NewWidget(app, settings)
|
widget = bamboohr.NewWidget(tviewApp, settings)
|
||||||
case "bargraph":
|
case "bargraph":
|
||||||
settings := bargraph.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := bargraph.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = bargraph.NewWidget(app, settings)
|
widget = bargraph.NewWidget(tviewApp, settings)
|
||||||
case "bittrex":
|
case "bittrex":
|
||||||
settings := bittrex.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := bittrex.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = bittrex.NewWidget(app, settings)
|
widget = bittrex.NewWidget(tviewApp, settings)
|
||||||
case "blockfolio":
|
case "blockfolio":
|
||||||
settings := blockfolio.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := blockfolio.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = blockfolio.NewWidget(app, settings)
|
widget = blockfolio.NewWidget(tviewApp, settings)
|
||||||
case "buildkite":
|
case "buildkite":
|
||||||
settings := buildkite.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := buildkite.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = buildkite.NewWidget(app, pages, settings)
|
widget = buildkite.NewWidget(tviewApp, pages, settings)
|
||||||
case "cdsFavorites":
|
case "cdsFavorites":
|
||||||
settings := cdsfavorites.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := cdsfavorites.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = cdsfavorites.NewWidget(app, pages, settings)
|
widget = cdsfavorites.NewWidget(tviewApp, pages, settings)
|
||||||
case "cdsQueue":
|
case "cdsQueue":
|
||||||
settings := cdsqueue.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := cdsqueue.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = cdsqueue.NewWidget(app, pages, settings)
|
widget = cdsqueue.NewWidget(tviewApp, pages, settings)
|
||||||
case "cdsStatus":
|
case "cdsStatus":
|
||||||
settings := cdsstatus.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := cdsstatus.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = cdsstatus.NewWidget(app, pages, settings)
|
widget = cdsstatus.NewWidget(tviewApp, pages, settings)
|
||||||
case "circleci":
|
case "circleci":
|
||||||
settings := circleci.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := circleci.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = circleci.NewWidget(app, settings)
|
widget = circleci.NewWidget(tviewApp, settings)
|
||||||
case "clocks":
|
case "clocks":
|
||||||
settings := clocks.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := clocks.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = clocks.NewWidget(app, settings)
|
widget = clocks.NewWidget(tviewApp, settings)
|
||||||
case "cmdrunner":
|
case "cmdrunner":
|
||||||
settings := cmdrunner.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := cmdrunner.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = cmdrunner.NewWidget(app, settings)
|
widget = cmdrunner.NewWidget(tviewApp, settings)
|
||||||
case "cryptolive":
|
case "cryptolive":
|
||||||
settings := cryptolive.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := cryptolive.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = cryptolive.NewWidget(app, settings)
|
widget = cryptolive.NewWidget(tviewApp, settings)
|
||||||
case "datadog":
|
case "datadog":
|
||||||
settings := datadog.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := datadog.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = datadog.NewWidget(app, pages, settings)
|
widget = datadog.NewWidget(tviewApp, pages, settings)
|
||||||
case "devto":
|
case "devto":
|
||||||
settings := devto.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := devto.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = devto.NewWidget(app, pages, settings)
|
widget = devto.NewWidget(tviewApp, pages, settings)
|
||||||
case "digitalclock":
|
case "digitalclock":
|
||||||
settings := digitalclock.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := digitalclock.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = digitalclock.NewWidget(app, settings)
|
widget = digitalclock.NewWidget(tviewApp, settings)
|
||||||
case "digitalocean":
|
case "digitalocean":
|
||||||
settings := digitalocean.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := digitalocean.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = digitalocean.NewWidget(app, pages, settings)
|
widget = digitalocean.NewWidget(tviewApp, pages, settings)
|
||||||
case "docker":
|
case "docker":
|
||||||
settings := docker.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := docker.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = docker.NewWidget(app, pages, settings)
|
widget = docker.NewWidget(tviewApp, pages, settings)
|
||||||
case "feedreader":
|
case "feedreader":
|
||||||
settings := feedreader.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := feedreader.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = feedreader.NewWidget(app, pages, settings)
|
widget = feedreader.NewWidget(tviewApp, pages, settings)
|
||||||
case "football":
|
case "football":
|
||||||
settings := football.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := football.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = football.NewWidget(app, pages, settings)
|
widget = football.NewWidget(tviewApp, pages, settings)
|
||||||
case "gcal":
|
case "gcal":
|
||||||
settings := gcal.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gcal.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gcal.NewWidget(app, settings)
|
widget = gcal.NewWidget(tviewApp, settings)
|
||||||
case "gerrit":
|
case "gerrit":
|
||||||
settings := gerrit.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gerrit.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gerrit.NewWidget(app, pages, settings)
|
widget = gerrit.NewWidget(tviewApp, pages, settings)
|
||||||
case "git":
|
case "git":
|
||||||
settings := git.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := git.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = git.NewWidget(app, pages, settings)
|
widget = git.NewWidget(tviewApp, pages, settings)
|
||||||
case "github":
|
case "github":
|
||||||
settings := github.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := github.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = github.NewWidget(app, pages, settings)
|
widget = github.NewWidget(tviewApp, pages, settings)
|
||||||
case "gitlab":
|
case "gitlab":
|
||||||
settings := gitlab.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gitlab.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gitlab.NewWidget(app, pages, settings)
|
widget = gitlab.NewWidget(tviewApp, pages, settings)
|
||||||
case "gitlabtodo":
|
case "gitlabtodo":
|
||||||
settings := gitlabtodo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gitlabtodo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gitlabtodo.NewWidget(app, pages, settings)
|
widget = gitlabtodo.NewWidget(tviewApp, pages, settings)
|
||||||
case "gitter":
|
case "gitter":
|
||||||
settings := gitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gitter.NewWidget(app, pages, settings)
|
widget = gitter.NewWidget(tviewApp, pages, settings)
|
||||||
case "googleanalytics":
|
case "googleanalytics":
|
||||||
settings := googleanalytics.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := googleanalytics.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = googleanalytics.NewWidget(app, settings)
|
widget = googleanalytics.NewWidget(tviewApp, settings)
|
||||||
case "gspreadsheets":
|
case "gspreadsheets":
|
||||||
settings := gspreadsheets.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := gspreadsheets.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = gspreadsheets.NewWidget(app, settings)
|
widget = gspreadsheets.NewWidget(tviewApp, settings)
|
||||||
case "grafana":
|
case "grafana":
|
||||||
settings := grafana.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := grafana.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = grafana.NewWidget(app, pages, settings)
|
widget = grafana.NewWidget(tviewApp, pages, settings)
|
||||||
case "hackernews":
|
case "hackernews":
|
||||||
settings := hackernews.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := hackernews.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = hackernews.NewWidget(app, pages, settings)
|
widget = hackernews.NewWidget(tviewApp, pages, settings)
|
||||||
case "hibp":
|
case "hibp":
|
||||||
settings := hibp.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := hibp.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = hibp.NewWidget(app, settings)
|
widget = hibp.NewWidget(tviewApp, settings)
|
||||||
case "ipapi":
|
case "ipapi":
|
||||||
settings := ipapi.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := ipapi.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = ipapi.NewWidget(app, settings)
|
widget = ipapi.NewWidget(tviewApp, settings)
|
||||||
case "ipinfo":
|
case "ipinfo":
|
||||||
settings := ipinfo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := ipinfo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = ipinfo.NewWidget(app, settings)
|
widget = ipinfo.NewWidget(tviewApp, settings)
|
||||||
case "jenkins":
|
case "jenkins":
|
||||||
settings := jenkins.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := jenkins.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = jenkins.NewWidget(app, pages, settings)
|
widget = jenkins.NewWidget(tviewApp, pages, settings)
|
||||||
case "jira":
|
case "jira":
|
||||||
settings := jira.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := jira.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = jira.NewWidget(app, pages, settings)
|
widget = jira.NewWidget(tviewApp, pages, settings)
|
||||||
case "kubernetes":
|
case "kubernetes":
|
||||||
settings := kubernetes.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := kubernetes.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = kubernetes.NewWidget(app, settings)
|
widget = kubernetes.NewWidget(tviewApp, settings)
|
||||||
case "krisinformation":
|
case "krisinformation":
|
||||||
settings := krisinformation.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := krisinformation.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = krisinformation.NewWidget(app, settings)
|
widget = krisinformation.NewWidget(tviewApp, settings)
|
||||||
case "logger":
|
case "logger":
|
||||||
settings := logger.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := logger.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = logger.NewWidget(app, settings)
|
widget = logger.NewWidget(tviewApp, settings)
|
||||||
case "mercurial":
|
case "mercurial":
|
||||||
settings := mercurial.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := mercurial.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = mercurial.NewWidget(app, pages, settings)
|
widget = mercurial.NewWidget(tviewApp, pages, settings)
|
||||||
case "nbascore":
|
case "nbascore":
|
||||||
settings := nbascore.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := nbascore.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = nbascore.NewWidget(app, pages, settings)
|
widget = nbascore.NewWidget(tviewApp, pages, settings)
|
||||||
case "newrelic":
|
case "newrelic":
|
||||||
settings := newrelic.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := newrelic.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = newrelic.NewWidget(app, pages, settings)
|
widget = newrelic.NewWidget(tviewApp, pages, settings)
|
||||||
case "opsgenie":
|
case "opsgenie":
|
||||||
settings := opsgenie.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := opsgenie.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = opsgenie.NewWidget(app, settings)
|
widget = opsgenie.NewWidget(tviewApp, settings)
|
||||||
case "pagerduty":
|
case "pagerduty":
|
||||||
settings := pagerduty.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := pagerduty.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = pagerduty.NewWidget(app, settings)
|
widget = pagerduty.NewWidget(tviewApp, settings)
|
||||||
case "pihole":
|
case "pihole":
|
||||||
settings := pihole.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := pihole.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = pihole.NewWidget(app, pages, settings)
|
widget = pihole.NewWidget(tviewApp, pages, settings)
|
||||||
case "power":
|
case "power":
|
||||||
settings := power.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := power.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = power.NewWidget(app, settings)
|
widget = power.NewWidget(tviewApp, settings)
|
||||||
case "prettyweather":
|
case "prettyweather":
|
||||||
settings := prettyweather.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := prettyweather.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = prettyweather.NewWidget(app, settings)
|
widget = prettyweather.NewWidget(tviewApp, settings)
|
||||||
case "pocket":
|
case "pocket":
|
||||||
settings := pocket.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := pocket.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = pocket.NewWidget(app, pages, settings)
|
widget = pocket.NewWidget(tviewApp, pages, settings)
|
||||||
case "resourceusage":
|
case "resourceusage":
|
||||||
settings := resourceusage.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := resourceusage.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = resourceusage.NewWidget(app, settings)
|
widget = resourceusage.NewWidget(tviewApp, settings)
|
||||||
case "rollbar":
|
case "rollbar":
|
||||||
settings := rollbar.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := rollbar.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = rollbar.NewWidget(app, pages, settings)
|
widget = rollbar.NewWidget(tviewApp, pages, settings)
|
||||||
case "security":
|
case "security":
|
||||||
settings := security.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := security.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = security.NewWidget(app, settings)
|
widget = security.NewWidget(tviewApp, settings)
|
||||||
case "spacex":
|
case "spacex":
|
||||||
settings := spacex.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := spacex.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = spacex.NewWidget(app, settings)
|
widget = spacex.NewWidget(tviewApp, settings)
|
||||||
case "spotify":
|
case "spotify":
|
||||||
settings := spotify.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := spotify.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = spotify.NewWidget(app, pages, settings)
|
widget = spotify.NewWidget(tviewApp, pages, settings)
|
||||||
case "spotifyweb":
|
case "spotifyweb":
|
||||||
settings := spotifyweb.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := spotifyweb.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = spotifyweb.NewWidget(app, pages, settings)
|
widget = spotifyweb.NewWidget(tviewApp, pages, settings)
|
||||||
case "status":
|
case "status":
|
||||||
settings := status.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := status.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = status.NewWidget(app, settings)
|
widget = status.NewWidget(tviewApp, settings)
|
||||||
case "subreddit":
|
case "subreddit":
|
||||||
settings := subreddit.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := subreddit.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = subreddit.NewWidget(app, pages, settings)
|
widget = subreddit.NewWidget(tviewApp, pages, settings)
|
||||||
case "textfile":
|
case "textfile":
|
||||||
settings := textfile.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := textfile.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = textfile.NewWidget(app, pages, settings)
|
widget = textfile.NewWidget(tviewApp, pages, settings)
|
||||||
case "todo":
|
case "todo":
|
||||||
settings := todo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := todo.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = todo.NewWidget(app, pages, settings)
|
widget = todo.NewWidget(tviewApp, pages, settings)
|
||||||
case "todo_plus":
|
case "todo_plus":
|
||||||
settings := todo_plus.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := todo_plus.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = todo_plus.NewWidget(app, pages, settings)
|
widget = todo_plus.NewWidget(tviewApp, pages, settings)
|
||||||
case "todoist":
|
case "todoist":
|
||||||
settings := todo_plus.FromTodoist(moduleName, moduleConfig, config)
|
settings := todo_plus.FromTodoist(moduleName, moduleConfig, config)
|
||||||
widget = todo_plus.NewWidget(app, pages, settings)
|
widget = todo_plus.NewWidget(tviewApp, pages, settings)
|
||||||
case "transmission":
|
case "transmission":
|
||||||
settings := transmission.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := transmission.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = transmission.NewWidget(app, pages, settings)
|
widget = transmission.NewWidget(tviewApp, pages, settings)
|
||||||
case "travisci":
|
case "travisci":
|
||||||
settings := travisci.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := travisci.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = travisci.NewWidget(app, pages, settings)
|
widget = travisci.NewWidget(tviewApp, pages, settings)
|
||||||
case "trello":
|
case "trello":
|
||||||
settings := todo_plus.FromTrello(moduleName, moduleConfig, config)
|
settings := todo_plus.FromTrello(moduleName, moduleConfig, config)
|
||||||
widget = todo_plus.NewWidget(app, pages, settings)
|
widget = todo_plus.NewWidget(tviewApp, pages, settings)
|
||||||
case "twitch":
|
case "twitch":
|
||||||
settings := twitch.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := twitch.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = twitch.NewWidget(app, pages, settings)
|
widget = twitch.NewWidget(tviewApp, pages, settings)
|
||||||
case "twitter":
|
case "twitter":
|
||||||
settings := twitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := twitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = twitter.NewWidget(app, pages, settings)
|
widget = twitter.NewWidget(tviewApp, pages, settings)
|
||||||
case "twitterstats":
|
case "twitterstats":
|
||||||
settings := twitterstats.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := twitterstats.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = twitterstats.NewWidget(app, pages, settings)
|
widget = twitterstats.NewWidget(tviewApp, pages, settings)
|
||||||
case "uptimerobot":
|
case "uptimerobot":
|
||||||
settings := uptimerobot.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := uptimerobot.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = uptimerobot.NewWidget(app, pages, settings)
|
widget = uptimerobot.NewWidget(tviewApp, pages, settings)
|
||||||
case "victorops":
|
case "victorops":
|
||||||
settings := victorops.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := victorops.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = victorops.NewWidget(app, settings)
|
widget = victorops.NewWidget(tviewApp, settings)
|
||||||
case "weather":
|
case "weather":
|
||||||
settings := weather.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := weather.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = weather.NewWidget(app, pages, settings)
|
widget = weather.NewWidget(tviewApp, pages, settings)
|
||||||
case "zendesk":
|
case "zendesk":
|
||||||
settings := zendesk.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := zendesk.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = zendesk.NewWidget(app, pages, settings)
|
widget = zendesk.NewWidget(tviewApp, pages, settings)
|
||||||
case "exchangerates":
|
case "exchangerates":
|
||||||
settings := exchangerates.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := exchangerates.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = exchangerates.NewWidget(app, pages, settings)
|
widget = exchangerates.NewWidget(tviewApp, pages, settings)
|
||||||
case "finnhub":
|
case "finnhub":
|
||||||
settings := finnhub.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := finnhub.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = finnhub.NewWidget(app, settings)
|
widget = finnhub.NewWidget(tviewApp, settings)
|
||||||
default:
|
default:
|
||||||
settings := unknown.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
settings := unknown.NewSettingsFromYAML(moduleName, moduleConfig, config)
|
||||||
widget = unknown.NewWidget(app, settings)
|
widget = unknown.NewWidget(tviewApp, settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeWidgets creates and returns a collection of enabled widgets
|
// MakeWidgets creates and returns a collection of enabled widgets
|
||||||
func MakeWidgets(app *tview.Application, pages *tview.Pages, config *config.Config) []wtf.Wtfable {
|
func MakeWidgets(tviewApp *tview.Application, pages *tview.Pages, config *config.Config) []wtf.Wtfable {
|
||||||
widgets := []wtf.Wtfable{}
|
widgets := []wtf.Wtfable{}
|
||||||
|
|
||||||
moduleNames, _ := config.Map("wtf.mods")
|
moduleNames, _ := config.Map("wtf.mods")
|
||||||
|
|
||||||
for moduleName := range moduleNames {
|
for moduleName := range moduleNames {
|
||||||
widget := MakeWidget(app, pages, moduleName, config)
|
widget := MakeWidget(tviewApp, pages, moduleName, config)
|
||||||
|
|
||||||
if widget != nil {
|
if widget != nil {
|
||||||
widgets = append(widgets, widget)
|
widgets = append(widgets, widget)
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
_ "github.com/gdamore/tcell/terminfo/extended"
|
_ "github.com/gdamore/tcell/terminfo/extended"
|
||||||
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/radovskyb/watcher"
|
"github.com/radovskyb/watcher"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
@ -18,7 +21,8 @@ import (
|
|||||||
// WtfApp is the container for a collection of widgets that are all constructed from a single
|
// WtfApp is the container for a collection of widgets that are all constructed from a single
|
||||||
// configuration file and displayed together
|
// configuration file and displayed together
|
||||||
type WtfApp struct {
|
type WtfApp struct {
|
||||||
app *tview.Application
|
TViewApp *tview.Application
|
||||||
|
|
||||||
config *config.Config
|
config *config.Config
|
||||||
configFilePath string
|
configFilePath string
|
||||||
display *Display
|
display *Display
|
||||||
@ -30,32 +34,29 @@ type WtfApp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWtfApp creates and returns an instance of WtfApp
|
// NewWtfApp creates and returns an instance of WtfApp
|
||||||
func NewWtfApp(app *tview.Application, config *config.Config, configFilePath string) *WtfApp {
|
func NewWtfApp(tviewApp *tview.Application, config *config.Config, configFilePath string) *WtfApp {
|
||||||
wtfApp := WtfApp{
|
wtfApp := &WtfApp{
|
||||||
app: app,
|
TViewApp: tviewApp,
|
||||||
|
|
||||||
config: config,
|
config: config,
|
||||||
configFilePath: configFilePath,
|
configFilePath: configFilePath,
|
||||||
pages: tview.NewPages(),
|
pages: tview.NewPages(),
|
||||||
}
|
}
|
||||||
|
|
||||||
wtfApp.app.SetBeforeDrawFunc(func(s tcell.Screen) bool {
|
wtfApp.TViewApp.SetBeforeDrawFunc(func(s tcell.Screen) bool {
|
||||||
s.Clear()
|
s.Clear()
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
wtfApp.app.SetInputCapture(wtfApp.keyboardIntercept)
|
wtfApp.widgets = MakeWidgets(wtfApp.TViewApp, wtfApp.pages, wtfApp.config)
|
||||||
|
|
||||||
wtfApp.widgets = MakeWidgets(wtfApp.app, wtfApp.pages, wtfApp.config)
|
|
||||||
wtfApp.display = NewDisplay(wtfApp.widgets, wtfApp.config)
|
wtfApp.display = NewDisplay(wtfApp.widgets, wtfApp.config)
|
||||||
wtfApp.focusTracker = NewFocusTracker(wtfApp.app, wtfApp.widgets, wtfApp.config)
|
wtfApp.focusTracker = NewFocusTracker(wtfApp.TViewApp, wtfApp.widgets, wtfApp.config)
|
||||||
|
wtfApp.validator = NewModuleValidator()
|
||||||
|
|
||||||
githubAPIKey := readGitHubAPIKey(wtfApp.config)
|
githubAPIKey := readGitHubAPIKey(wtfApp.config)
|
||||||
wtfApp.ghUser = support.NewGitHubUser(githubAPIKey)
|
wtfApp.ghUser = support.NewGitHubUser(githubAPIKey)
|
||||||
|
|
||||||
wtfApp.validator = NewModuleValidator()
|
|
||||||
|
|
||||||
wtfApp.pages.AddPage("grid", wtfApp.display.Grid, true, true)
|
wtfApp.pages.AddPage("grid", wtfApp.display.Grid, true, true)
|
||||||
wtfApp.app.SetRoot(wtfApp.pages, true)
|
|
||||||
|
|
||||||
wtfApp.validator.Validate(wtfApp.widgets)
|
wtfApp.validator.Validate(wtfApp.widgets)
|
||||||
|
|
||||||
@ -66,17 +67,28 @@ func NewWtfApp(app *tview.Application, config *config.Config, configFilePath str
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return &wtfApp
|
wtfApp.TViewApp.SetInputCapture(wtfApp.keyboardIntercept)
|
||||||
|
wtfApp.TViewApp.SetRoot(wtfApp.pages, true)
|
||||||
|
|
||||||
|
return wtfApp
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
|
// Run starts the underlying tview app
|
||||||
|
func (wtfApp *WtfApp) Run() {
|
||||||
|
if err := wtfApp.TViewApp.Run(); err != nil {
|
||||||
|
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Start initializes the app
|
// Start initializes the app
|
||||||
func (wtfApp *WtfApp) Start() {
|
func (wtfApp *WtfApp) Start() {
|
||||||
go wtfApp.scheduleWidgets()
|
go wtfApp.scheduleWidgets()
|
||||||
|
|
||||||
go wtfApp.watchForConfigChanges()
|
go wtfApp.watchForConfigChanges()
|
||||||
|
|
||||||
|
// FIXME: This should be moved to the AppManager
|
||||||
go func() { _ = wtfApp.ghUser.Load() }()
|
go func() { _ = wtfApp.ghUser.Load() }()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +110,16 @@ func (wtfApp *WtfApp) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
|||||||
switch event.Key() {
|
switch event.Key() {
|
||||||
case tcell.KeyCtrlC:
|
case tcell.KeyCtrlC:
|
||||||
wtfApp.Stop()
|
wtfApp.Stop()
|
||||||
wtfApp.app.Stop()
|
wtfApp.TViewApp.Stop()
|
||||||
wtfApp.DisplayExitMessage()
|
wtfApp.DisplayExitMessage()
|
||||||
case tcell.KeyCtrlR:
|
case tcell.KeyCtrlR:
|
||||||
wtfApp.refreshAllWidgets()
|
wtfApp.refreshAllWidgets()
|
||||||
return nil
|
return nil
|
||||||
|
case tcell.KeyCtrlSpace:
|
||||||
|
// FIXME: This can't reside in the app, the app doesn't know about
|
||||||
|
// the AppManager. The AppManager needs to catch this one
|
||||||
|
fmt.Println("Next app")
|
||||||
|
return nil
|
||||||
case tcell.KeyTab:
|
case tcell.KeyTab:
|
||||||
wtfApp.focusTracker.Next()
|
wtfApp.focusTracker.Next()
|
||||||
case tcell.KeyBacktab:
|
case tcell.KeyBacktab:
|
||||||
@ -154,7 +171,7 @@ func (wtfApp *WtfApp) watchForConfigChanges() {
|
|||||||
wtfApp.Stop()
|
wtfApp.Stop()
|
||||||
|
|
||||||
config := cfg.LoadWtfConfigFile(wtfApp.configFilePath)
|
config := cfg.LoadWtfConfigFile(wtfApp.configFilePath)
|
||||||
newApp := NewWtfApp(wtfApp.app, config, wtfApp.configFilePath)
|
newApp := NewWtfApp(wtfApp.TViewApp, config, wtfApp.configFilePath)
|
||||||
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
||||||
utils.Init(config.UString("wtf.openFileUtil", "open"), openURLUtil)
|
utils.Init(config.UString("wtf.openFileUtil", "open"), openURLUtil)
|
||||||
|
|
||||||
|
@ -9,16 +9,14 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates and returns an instance of Widget
|
// NewWidget creates and returns an instance of Widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, settings.common),
|
TextWidget: view.NewTextWidget(tviewApp, settings.common),
|
||||||
|
|
||||||
app: app,
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
main.go
42
main.go
@ -1,10 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// Generators
|
|
||||||
// To generate the skeleton for a new TextWidget use 'WTF_WIDGET_NAME=MySuperAwesomeWidget go generate -run=text
|
|
||||||
//go:generate -command text go run generator/textwidget.go
|
|
||||||
//go:generate text
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@ -17,34 +12,20 @@ import (
|
|||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olebedev/config"
|
|
||||||
"github.com/pkg/profile"
|
"github.com/pkg/profile"
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/wtfutil/wtf/app"
|
"github.com/wtfutil/wtf/app"
|
||||||
"github.com/wtfutil/wtf/cfg"
|
"github.com/wtfutil/wtf/cfg"
|
||||||
"github.com/wtfutil/wtf/flags"
|
"github.com/wtfutil/wtf/flags"
|
||||||
"github.com/wtfutil/wtf/utils"
|
"github.com/wtfutil/wtf/utils"
|
||||||
|
"github.com/wtfutil/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tviewApp *tview.Application
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
date = "dev"
|
date = "dev"
|
||||||
version = "dev"
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* -------------------- Functions -------------------- */
|
|
||||||
|
|
||||||
func setTerm(config *config.Config) {
|
|
||||||
term := config.UString("wtf.term", os.Getenv("TERM"))
|
|
||||||
err := os.Setenv("TERM", term)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("\n%s Failed to set $TERM to %s.\n", aurora.Red("ERROR"), aurora.Yellow(term))
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------- Main -------------------- */
|
/* -------------------- Main -------------------- */
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -54,11 +35,12 @@ func main() {
|
|||||||
flags := flags.NewFlags()
|
flags := flags.NewFlags()
|
||||||
flags.Parse()
|
flags.Parse()
|
||||||
|
|
||||||
hasCustom := flags.HasCustomConfig()
|
|
||||||
cfg.Initialize(hasCustom)
|
|
||||||
|
|
||||||
// Load the configuration file
|
// Load the configuration file
|
||||||
|
cfg.Initialize(flags.HasCustomConfig())
|
||||||
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
|
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
|
||||||
|
|
||||||
|
wtf.SetTerminal(config)
|
||||||
|
|
||||||
flags.RenderIf(version, date, config)
|
flags.RenderIf(version, date, config)
|
||||||
|
|
||||||
if flags.Profile {
|
if flags.Profile {
|
||||||
@ -69,15 +51,15 @@ func main() {
|
|||||||
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
||||||
utils.Init(openFileUtil, openURLUtil)
|
utils.Init(openFileUtil, openURLUtil)
|
||||||
|
|
||||||
setTerm(config)
|
/* Initialize the App Manager */
|
||||||
|
appMan := app.NewAppManager()
|
||||||
|
appMan.MakeNewWtfApp(config, flags.Config)
|
||||||
|
|
||||||
// Build the application
|
currentApp, err := appMan.Current()
|
||||||
tviewApp = tview.NewApplication()
|
if err != nil {
|
||||||
wtfApp := app.NewWtfApp(tviewApp, config, flags.Config)
|
|
||||||
wtfApp.Start()
|
|
||||||
|
|
||||||
if err := tviewApp.Run(); err != nil {
|
|
||||||
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
|
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentApp.Run()
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ type Widget struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ type Widget struct {
|
|||||||
items []Item
|
items []Item
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,15 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.BarGraph
|
view.BarGraph
|
||||||
|
|
||||||
app *tview.Application
|
tviewApp *tview.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
BarGraph: view.NewBarGraph(app, "Sample Bar Graph", settings.Common),
|
BarGraph: view.NewBarGraph(tviewApp, "Sample Bar Graph", settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.SetWrap(true)
|
widget.View.SetWrap(true)
|
||||||
@ -69,7 +69,7 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
widget.View.Clear()
|
widget.View.Clear()
|
||||||
|
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.tviewApp.QueueUpdateDraw(func() {
|
||||||
display(widget)
|
display(widget)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package buildkite
|
package buildkite
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
|
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
|
||||||
|
@ -27,10 +27,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
|
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
|
||||||
|
@ -27,10 +27,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next line")
|
widget.SetKeyboardChar("j", widget.Next, "Select next line")
|
||||||
|
@ -27,10 +27,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
Client: NewClient(settings.apiKey),
|
Client: NewClient(settings.apiKey),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
@ -8,18 +8,16 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
clockColl ClockCollection
|
clockColl ClockCollection
|
||||||
dateFormat string
|
dateFormat string
|
||||||
timeFormat string
|
timeFormat string
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
app: app,
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
dateFormat: settings.dateFormat,
|
dateFormat: settings.dateFormat,
|
||||||
timeFormat: settings.timeFormat,
|
timeFormat: settings.timeFormat,
|
||||||
@ -34,10 +32,8 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
|
|
||||||
// Refresh updates the onscreen contents of the widget
|
// Refresh updates the onscreen contents of the widget
|
||||||
func (widget *Widget) Refresh() {
|
func (widget *Widget) Refresh() {
|
||||||
widget.app.QueueUpdateDraw(func() {
|
sortedClocks := widget.clockColl.Sorted(widget.settings.sort)
|
||||||
sortedClocks := widget.clockColl.Sorted(widget.settings.sort)
|
widget.display(sortedClocks, widget.dateFormat, widget.timeFormat)
|
||||||
widget.display(sortedClocks, widget.dateFormat, widget.timeFormat)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -27,9 +27,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
buffer: &bytes.Buffer{},
|
buffer: &bytes.Buffer{},
|
||||||
|
@ -29,9 +29,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
summaryList: summaryList{},
|
summaryList: summaryList{},
|
||||||
|
@ -18,9 +18,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
device_token: settings.deviceToken,
|
device_token: settings.deviceToken,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
@ -20,9 +20,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
priceWidget: price.NewWidget(settings.priceSettings),
|
priceWidget: price.NewWidget(settings.priceSettings),
|
||||||
toplistWidget: toplist.NewWidget(settings.toplistSettings),
|
toplistWidget: toplist.NewWidget(settings.toplistSettings),
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package devto
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("d", widget.Next, "Select next item")
|
widget.SetKeyboardChar("d", widget.Next, "Select next item")
|
||||||
|
@ -19,9 +19,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,14 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new widget using settings
|
// NewWidget creates a new widget using settings
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
app: app,
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package digitalocean
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("?", widget.showInfo, "Show info about the selected droplet")
|
widget.SetKeyboardChar("?", widget.showInfo, "Show info about the selected droplet")
|
||||||
|
@ -42,11 +42,11 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
app: app,
|
app: tviewApp,
|
||||||
pages: pages,
|
pages: pages,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ type Widget struct {
|
|||||||
displayBuffer string
|
displayBuffer string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package feedreader
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -63,9 +63,9 @@ func getShowText(feedItem *FeedItem, showType ShowType) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
parser: gofeed.NewParser(),
|
parser: gofeed.NewParser(),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
@ -17,10 +17,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget ..
|
// NewWidget ..
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
Client: NewClient(settings.symbols, settings.apiKey),
|
Client: NewClient(settings.symbols, settings.apiKey),
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
var widget Widget
|
var widget Widget
|
||||||
|
|
||||||
leagueId, err := getLeague(settings.league)
|
leagueId, err := getLeague(settings.league)
|
||||||
@ -51,7 +51,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget = Widget{
|
widget = Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
Client: NewClient(settings.apiKey),
|
Client: NewClient(settings.apiKey),
|
||||||
League: leagueId,
|
League: leagueId,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
@ -8,17 +8,17 @@ import (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
calEvents []*CalEvent
|
calEvents []*CalEvent
|
||||||
settings *Settings
|
|
||||||
err error
|
err error
|
||||||
|
settings *Settings
|
||||||
|
tviewApp *tview.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.app.Suspend(widget.authenticate)
|
widget.tviewApp.Suspend(widget.authenticate)
|
||||||
widget.Refresh()
|
widget.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("h", widget.prevProject, "Select previous project")
|
widget.SetKeyboardChar("h", widget.prevProject, "Select previous project")
|
||||||
|
@ -29,9 +29,9 @@ var (
|
|||||||
GerritURLPattern = regexp.MustCompile(`^(http|https)://(.*)$`)
|
GerritURLPattern = regexp.MustCompile(`^(http|https)://(.*)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
Idx: 0,
|
Idx: 0,
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package git
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
|
widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
|
||||||
|
@ -23,17 +23,17 @@ type Widget struct {
|
|||||||
|
|
||||||
GitRepos []*GitRepo
|
GitRepos []*GitRepo
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
pages *tview.Pages
|
pages *tview.Pages
|
||||||
settings *Settings
|
settings *Settings
|
||||||
|
tviewApp *tview.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
pages: pages,
|
pages: pages,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ func (widget *Widget) Checkout() {
|
|||||||
repoToCheckout := widget.GitRepos[widget.Idx]
|
repoToCheckout := widget.GitRepos[widget.Idx]
|
||||||
repoToCheckout.checkout(text)
|
repoToCheckout.checkout(text)
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
widget.Refresh()
|
widget.Refresh()
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ func (widget *Widget) addButtons(form *tview.Form, checkoutFctn func()) {
|
|||||||
func (widget *Widget) addCancelButton(form *tview.Form) {
|
func (widget *Widget) addCancelButton(form *tview.Form) {
|
||||||
cancelFn := func() {
|
cancelFn := func() {
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +102,10 @@ func (widget *Widget) addCancelButton(form *tview.Form) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) modalFocus(form *tview.Form) {
|
func (widget *Widget) modalFocus(form *tview.Form) {
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.tviewApp.QueueUpdateDraw(func() {
|
||||||
frame := widget.modalFrame(form)
|
frame := widget.modalFrame(form)
|
||||||
widget.pages.AddPage("modal", frame, false, true)
|
widget.pages.AddPage("modal", frame, false, true)
|
||||||
widget.app.SetFocus(frame)
|
widget.tviewApp.SetFocus(frame)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -23,10 +23,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -29,12 +29,12 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
context, err := newContext(settings)
|
context, err := newContext(settings)
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
context: context,
|
context: context,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
@ -3,8 +3,9 @@ package gitlabtodo
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
widget.SetKeyboardChar("/", widget.ShowHelp, "Show/hide this help widget")
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.SetKeyboardChar("r", widget.Refresh, "Refresh widget")
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
|
||||||
widget.SetKeyboardChar("o", widget.openTodo, "Open todo in browser")
|
widget.SetKeyboardChar("o", widget.openTodo, "Open todo in browser")
|
||||||
|
@ -18,9 +18,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package gitter
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
Client: NewClient(settings),
|
Client: NewClient(settings),
|
||||||
Selected: -1,
|
Selected: -1,
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package hackernews
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -18,9 +18,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ type ipinfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget constructor
|
// NewWidget constructor
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ type ipinfo struct {
|
|||||||
Organization string `json:"org"`
|
Organization string `json:"org"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package jenkins
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -16,9 +16,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of the widget
|
// NewWidget creates a new instance of the widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
objects: settings.objects,
|
objects: settings.objects,
|
||||||
title: settings.title,
|
title: settings.title,
|
||||||
|
@ -17,16 +17,14 @@ const (
|
|||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
filePath string
|
filePath string
|
||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
app: app,
|
|
||||||
filePath: log.LogFilePath(),
|
filePath: log.LogFilePath(),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package mercurial
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
|
widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
|
||||||
|
@ -18,19 +18,19 @@ type Widget struct {
|
|||||||
view.MultiSourceWidget
|
view.MultiSourceWidget
|
||||||
view.TextWidget
|
view.TextWidget
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
Data []*MercurialRepo
|
Data []*MercurialRepo
|
||||||
pages *tview.Pages
|
pages *tview.Pages
|
||||||
settings *Settings
|
settings *Settings
|
||||||
|
tviewApp *tview.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "repository", "repositories"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
pages: pages,
|
pages: pages,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ func (widget *Widget) Checkout() {
|
|||||||
repoToCheckout := widget.Data[widget.Idx]
|
repoToCheckout := widget.Data[widget.Idx]
|
||||||
repoToCheckout.checkout(text)
|
repoToCheckout.checkout(text)
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
|
|
||||||
widget.display()
|
widget.display()
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ func (widget *Widget) addButtons(form *tview.Form, checkoutFctn func()) {
|
|||||||
func (widget *Widget) addCancelButton(form *tview.Form) {
|
func (widget *Widget) addCancelButton(form *tview.Form) {
|
||||||
cancelFn := func() {
|
cancelFn := func() {
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,10 +100,10 @@ func (widget *Widget) addCancelButton(form *tview.Form) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) modalFocus(form *tview.Form) {
|
func (widget *Widget) modalFocus(form *tview.Form) {
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.tviewApp.QueueUpdateDraw(func() {
|
||||||
frame := widget.modalFrame(form)
|
frame := widget.modalFrame(form)
|
||||||
widget.pages.AddPage("modal", frame, false, true)
|
widget.pages.AddPage("modal", frame, false, true)
|
||||||
widget.app.SetFocus(frame)
|
widget.tviewApp.SetFocus(frame)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package nbascore
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
||||||
|
@ -24,9 +24,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "applicationID", "applicationIDs"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "applicationID", "applicationIDs"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates and returns an instance of PagerDuty widget
|
// NewWidget creates and returns an instance of PagerDuty widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package pihole
|
package pihole
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("d", widget.disable, "disable Pi-hole")
|
widget.SetKeyboardChar("d", widget.disable, "disable Pi-hole")
|
||||||
|
@ -15,10 +15,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
//func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package pocket
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("a", widget.toggleLink, "Toggle Link")
|
widget.SetKeyboardChar("a", widget.toggleLink, "Toggle Link")
|
||||||
|
@ -21,9 +21,9 @@ type Widget struct {
|
|||||||
archivedView bool
|
archivedView bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, nil, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, nil, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
client: NewClient(settings.consumerKey, "http://localhost"),
|
client: NewClient(settings.consumerKey, "http://localhost"),
|
||||||
archivedView: false,
|
archivedView: false,
|
||||||
|
@ -15,9 +15,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
Battery: NewBattery(),
|
Battery: NewBattery(),
|
||||||
|
|
||||||
|
@ -14,18 +14,17 @@ import (
|
|||||||
|
|
||||||
// Widget define wtf widget to register widget later
|
// Widget define wtf widget to register widget later
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.BarGraph
|
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
settings *Settings
|
settings *Settings
|
||||||
|
tviewApp *tview.Application
|
||||||
|
view.BarGraph
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
BarGraph: view.NewBarGraph(app, settings.Name, settings.Common),
|
BarGraph: view.NewBarGraph(tviewApp, settings.Name, settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.tviewApp.QueueUpdateDraw(func() {
|
||||||
widget.View.Clear()
|
widget.View.Clear()
|
||||||
display(widget)
|
display(widget)
|
||||||
})
|
})
|
||||||
|
@ -3,6 +3,7 @@ package rollbar
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -18,9 +18,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
return widget
|
return widget
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
widget.SetKeyboardChar("l", widget.next, "Select next item")
|
||||||
|
@ -19,9 +19,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
Info: spotigopher.Info{},
|
Info: spotigopher.Info{},
|
||||||
client: spotigopher.NewClient(),
|
client: spotigopher.NewClient(),
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
|
widget.SetKeyboardChar("h", widget.selectPrevious, "Select previous item")
|
||||||
|
@ -60,7 +60,7 @@ func authHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new widget for WTF
|
// NewWidget creates a new widget for WTF
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
redirectURI = "http://localhost:" + settings.callbackPort + "/callback"
|
redirectURI = "http://localhost:" + settings.callbackPort + "/callback"
|
||||||
|
|
||||||
auth = spotify.NewAuthenticator(redirectURI, spotify.ScopeUserReadCurrentlyPlaying, spotify.ScopeUserReadPlaybackState, spotify.ScopeUserModifyPlaybackState)
|
auth = spotify.NewAuthenticator(redirectURI, spotify.ScopeUserReadCurrentlyPlaying, spotify.ScopeUserReadPlaybackState, spotify.ScopeUserModifyPlaybackState)
|
||||||
@ -71,7 +71,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
|||||||
var playerState *spotify.PlayerState
|
var playerState *spotify.PlayerState
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
Info: Info{},
|
Info: Info{},
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ type Widget struct {
|
|||||||
settings *Settings
|
settings *Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
CurrentIcon: 0,
|
CurrentIcon: 0,
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package subreddit
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -16,9 +16,9 @@ type Widget struct {
|
|||||||
links []Link
|
links []Link
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := &Widget{
|
widget := &Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ type Widget struct {
|
|||||||
systemInfo *SystemInfo
|
systemInfo *SystemInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, date, version string, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, date, version string, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
|
||||||
|
|
||||||
Date: date,
|
Date: date,
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(nil)
|
widget.InitializeRefreshKeyboardControl(nil)
|
||||||
|
|
||||||
widget.SetKeyboardChar("l", widget.NextSource, "Select next file")
|
widget.SetKeyboardChar("l", widget.NextSource, "Select next file")
|
||||||
|
@ -29,10 +29,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "filePath", "filePaths"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "filePath", "filePaths"),
|
||||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -22,21 +22,20 @@ const (
|
|||||||
|
|
||||||
// A Widget represents a Todo widget
|
// A Widget represents a Todo widget
|
||||||
type Widget struct {
|
type Widget struct {
|
||||||
view.ScrollableWidget
|
|
||||||
|
|
||||||
app *tview.Application
|
|
||||||
filePath string
|
filePath string
|
||||||
list checklist.Checklist
|
list checklist.Checklist
|
||||||
pages *tview.Pages
|
pages *tview.Pages
|
||||||
settings *Settings
|
settings *Settings
|
||||||
|
tviewApp *tview.Application
|
||||||
|
view.ScrollableWidget
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
app: app,
|
tviewApp: tviewApp,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
filePath: settings.filePath,
|
filePath: settings.filePath,
|
||||||
list: checklist.NewChecklist(settings.Sigils.Checkbox.Checked, settings.Sigils.Checkbox.Unchecked),
|
list: checklist.NewChecklist(settings.Sigils.Checkbox.Checked, settings.Sigils.Checkbox.Unchecked),
|
||||||
@ -117,15 +116,15 @@ func (widget *Widget) newItem() {
|
|||||||
widget.SetItemCount(len(widget.list.Items))
|
widget.SetItemCount(len(widget.list.Items))
|
||||||
widget.persist()
|
widget.persist()
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addButtons(form, saveFctn)
|
widget.addButtons(form, saveFctn)
|
||||||
widget.modalFocus(form)
|
widget.modalFocus(form)
|
||||||
|
|
||||||
widget.app.QueueUpdate(func() {
|
widget.tviewApp.QueueUpdate(func() {
|
||||||
widget.app.Draw()
|
widget.tviewApp.Draw()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,15 +165,15 @@ func (widget *Widget) updateSelected() {
|
|||||||
widget.updateSelectedItem(text)
|
widget.updateSelectedItem(text)
|
||||||
widget.persist()
|
widget.persist()
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addButtons(form, saveFctn)
|
widget.addButtons(form, saveFctn)
|
||||||
widget.modalFocus(form)
|
widget.modalFocus(form)
|
||||||
|
|
||||||
widget.app.QueueUpdate(func() {
|
widget.tviewApp.QueueUpdate(func() {
|
||||||
widget.app.Draw()
|
widget.tviewApp.Draw()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +197,7 @@ func (widget *Widget) addButtons(form *tview.Form, saveFctn func()) {
|
|||||||
func (widget *Widget) addCancelButton(form *tview.Form) {
|
func (widget *Widget) addCancelButton(form *tview.Form) {
|
||||||
cancelFn := func() {
|
cancelFn := func() {
|
||||||
widget.pages.RemovePage("modal")
|
widget.pages.RemovePage("modal")
|
||||||
widget.app.SetFocus(widget.View)
|
widget.tviewApp.SetFocus(widget.View)
|
||||||
widget.display()
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,10 +210,10 @@ func (widget *Widget) addSaveButton(form *tview.Form, fctn func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) modalFocus(form *tview.Form) {
|
func (widget *Widget) modalFocus(form *tview.Form) {
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.tviewApp.QueueUpdateDraw(func() {
|
||||||
frame := widget.modalFrame(form)
|
frame := widget.modalFrame(form)
|
||||||
widget.pages.AddPage("modal", frame, false, true)
|
widget.pages.AddPage("modal", frame, false, true)
|
||||||
widget.app.SetFocus(frame)
|
widget.tviewApp.SetFocus(frame)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package todo_plus
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("d", widget.Delete, "Delete item")
|
widget.SetKeyboardChar("d", widget.Delete, "Delete item")
|
||||||
|
@ -19,10 +19,10 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "project", "projects"),
|
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "project", "projects"),
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package transmission
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(nil)
|
widget.InitializeRefreshKeyboardControl(nil)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Prev, "Select previous item")
|
widget.SetKeyboardChar("j", widget.Prev, "Select previous item")
|
||||||
|
@ -21,9 +21,9 @@ type Widget struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget creates a new instance of a widget
|
// NewWidget creates a new instance of a widget
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package travisci
|
|||||||
import "github.com/gdamore/tcell"
|
import "github.com/gdamore/tcell"
|
||||||
|
|
||||||
func (widget *Widget) initializeKeyboardControls() {
|
func (widget *Widget) initializeKeyboardControls() {
|
||||||
|
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
|
||||||
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
widget.InitializeRefreshKeyboardControl(widget.Refresh)
|
||||||
|
|
||||||
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
widget.SetKeyboardChar("j", widget.Next, "Select next item")
|
||||||
|
@ -17,9 +17,9 @@ type Widget struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
ScrollableWidget: view.NewScrollableWidget(app, pages, settings.Common),
|
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user