From dbc047516d79399f0575e23d4bb0d09d66a3410e Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sun, 4 Aug 2019 21:42:40 -0700 Subject: [PATCH] Move all components responsible for module composition into /view --- modules/bamboohr/widget.go | 5 +++-- modules/circleci/widget.go | 6 +++--- modules/clocks/widget.go | 6 +++--- modules/cmdrunner/widget.go | 5 +++-- modules/cryptoexchanges/bittrex/widget.go | 6 +++--- modules/cryptoexchanges/blockfolio/widget.go | 6 +++--- modules/cryptoexchanges/cryptolive/widget.go | 6 +++--- modules/datadog/widget.go | 9 +++++---- modules/feedreader/widget.go | 9 +++++---- modules/gcal/widget.go | 6 +++--- modules/gerrit/widget.go | 9 +++++---- modules/git/widget.go | 13 +++++++------ modules/github/widget.go | 14 +++++++------- modules/gitlab/widget.go | 14 +++++++------- modules/gitter/widget.go | 9 +++++---- modules/googleanalytics/widget.go | 6 +++--- modules/gspreadsheets/widget.go | 5 +++-- modules/hackernews/widget.go | 9 +++++---- modules/hibp/widget.go | 6 +++--- modules/ipaddresses/ipapi/widget.go | 6 +++--- modules/ipaddresses/ipinfo/widget.go | 6 +++--- modules/jenkins/widget.go | 9 +++++---- modules/jira/widget.go | 9 +++++---- modules/logger/widget.go | 6 +++--- modules/mercurial/widget.go | 13 +++++++------ modules/nbascore/widget.go | 9 +++++---- modules/newrelic/widget.go | 5 +++-- modules/opsgenie/widget.go | 5 +++-- modules/pagerduty/widget.go | 5 +++-- modules/power/widget.go | 6 +++--- modules/rollbar/widget.go | 9 +++++---- modules/security/widget.go | 6 +++--- modules/spotify/widget.go | 9 +++++---- modules/spotifyweb/widget.go | 9 +++++---- modules/status/widget.go | 6 +++--- modules/system/widget.go | 5 +++-- modules/textfile/widget.go | 14 +++++++------- modules/todo/widget.go | 17 ++++++++++------- modules/todoist/widget.go | 14 +++++++------- modules/transmission/widget.go | 10 +++++----- modules/travisci/widget.go | 9 +++++---- modules/trello/widget.go | 6 +++--- modules/twitter/widget.go | 13 +++++++------ modules/unknown/widget.go | 6 +++--- modules/victorops/widget.go | 6 +++--- modules/weatherservices/prettyweather/widget.go | 5 +++-- modules/weatherservices/weather/widget.go | 13 +++++++------ modules/zendesk/widget.go | 9 +++++---- {wtf => view}/keyboard_widget.go | 5 +++-- {wtf => view}/keyboard_widget_test.go | 2 +- {wtf => view}/multisource_widget.go | 5 +++-- {wtf => view}/scrollable.go | 3 +-- {wtf => view}/text_widget.go | 11 ++++++----- {wtf => view}/text_widget_test.go | 2 +- 54 files changed, 226 insertions(+), 196 deletions(-) rename {wtf => view}/keyboard_widget.go (96%) rename {wtf => view}/keyboard_widget_test.go (99%) rename {wtf => view}/multisource_widget.go (97%) rename {wtf => view}/scrollable.go (99%) rename {wtf => view}/text_widget.go (91%) rename {wtf => view}/text_widget_test.go (99%) diff --git a/modules/bamboohr/widget.go b/modules/bamboohr/widget.go index 5e3d5a2c..8dd16ee9 100644 --- a/modules/bamboohr/widget.go +++ b/modules/bamboohr/widget.go @@ -5,20 +5,21 @@ import ( "time" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) const APIURI = "https://api.bamboohr.com/api/gateway.php" type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/circleci/widget.go b/modules/circleci/widget.go index 920b2845..e10a216f 100644 --- a/modules/circleci/widget.go +++ b/modules/circleci/widget.go @@ -4,11 +4,11 @@ import ( "fmt" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget *Client settings *Settings @@ -16,7 +16,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), Client: NewClient(settings.apiKey), settings: settings, diff --git a/modules/clocks/widget.go b/modules/clocks/widget.go index bcabe565..b22f9d7e 100644 --- a/modules/clocks/widget.go +++ b/modules/clocks/widget.go @@ -5,11 +5,11 @@ import ( "time" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget app *tview.Application clockColl ClockCollection @@ -20,7 +20,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), app: app, settings: settings, diff --git a/modules/cmdrunner/widget.go b/modules/cmdrunner/widget.go index 523815b5..4f2aca20 100644 --- a/modules/cmdrunner/widget.go +++ b/modules/cmdrunner/widget.go @@ -6,11 +6,12 @@ import ( "strings" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.TextWidget + view.TextWidget args []string cmd string @@ -20,7 +21,7 @@ type Widget struct { // NewWidget creates a new instance of the widget func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), args: settings.args, cmd: settings.cmd, diff --git a/modules/cryptoexchanges/bittrex/widget.go b/modules/cryptoexchanges/bittrex/widget.go index a0e0345a..8850241e 100644 --- a/modules/cryptoexchanges/bittrex/widget.go +++ b/modules/cryptoexchanges/bittrex/widget.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) var ok = true @@ -18,7 +18,7 @@ const baseURL = "https://bittrex.com/api/v1.1/public/getmarketsummary" // Widget define wtf widget to register widget later type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings summaryList @@ -27,7 +27,7 @@ type Widget struct { // NewWidget Make new instance of widget func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, summaryList: summaryList{}, diff --git a/modules/cryptoexchanges/blockfolio/widget.go b/modules/cryptoexchanges/blockfolio/widget.go index 1d7db72d..a4079607 100644 --- a/modules/cryptoexchanges/blockfolio/widget.go +++ b/modules/cryptoexchanges/blockfolio/widget.go @@ -8,11 +8,11 @@ import ( "net/http" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget device_token string settings *Settings @@ -20,7 +20,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), device_token: settings.deviceToken, settings: settings, diff --git a/modules/cryptoexchanges/cryptolive/widget.go b/modules/cryptoexchanges/cryptolive/widget.go index f6c67d96..5cc01e6a 100644 --- a/modules/cryptoexchanges/cryptolive/widget.go +++ b/modules/cryptoexchanges/cryptolive/widget.go @@ -7,12 +7,12 @@ import ( "github.com/rivo/tview" "github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/price" "github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/toplist" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // Widget define wtf widget to register widget later type Widget struct { - wtf.TextWidget + view.TextWidget priceWidget *price.Widget toplistWidget *toplist.Widget @@ -22,7 +22,7 @@ type Widget struct { // NewWidget Make new instance of widget func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), priceWidget: price.NewWidget(settings.priceSettings), toplistWidget: toplist.NewWidget(settings.toplistSettings), diff --git a/modules/datadog/widget.go b/modules/datadog/widget.go index e163585f..d14ae877 100644 --- a/modules/datadog/widget.go +++ b/modules/datadog/widget.go @@ -4,13 +4,14 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" datadog "github.com/zorkian/go-datadog-api" ) type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget monitors []datadog.Monitor settings *Settings @@ -18,8 +19,8 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/feedreader/widget.go b/modules/feedreader/widget.go index 678c8566..f3b20ba9 100644 --- a/modules/feedreader/widget.go +++ b/modules/feedreader/widget.go @@ -7,6 +7,7 @@ import ( "github.com/mmcdole/gofeed" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) @@ -22,8 +23,8 @@ type FeedItem struct { // Widget is the container for RSS and Atom data type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget stories []*FeedItem parser *gofeed.Parser @@ -33,8 +34,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := &Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), parser: gofeed.NewParser(), settings: settings, diff --git a/modules/gcal/widget.go b/modules/gcal/widget.go index 964fc4e3..9efaaa84 100644 --- a/modules/gcal/widget.go +++ b/modules/gcal/widget.go @@ -2,11 +2,11 @@ package gcal import ( "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget app *tview.Application calEvents []*CalEvent @@ -15,7 +15,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, true), + TextWidget: view.NewTextWidget(app, settings.common, true), app: app, settings: settings, diff --git a/modules/gerrit/widget.go b/modules/gerrit/widget.go index b310a2b5..bb9c0f36 100644 --- a/modules/gerrit/widget.go +++ b/modules/gerrit/widget.go @@ -8,12 +8,13 @@ import ( glb "github.com/andygrunwald/go-gerrit" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.TextWidget + view.KeyboardWidget + view.TextWidget gerrit *glb.Client @@ -30,8 +31,8 @@ var ( func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + TextWidget: view.NewTextWidget(app, settings.common, true), Idx: 0, diff --git a/modules/git/widget.go b/modules/git/widget.go index 31163c8f..de80781f 100644 --- a/modules/git/widget.go +++ b/modules/git/widget.go @@ -8,6 +8,7 @@ import ( "github.com/gdamore/tcell" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) @@ -16,9 +17,9 @@ const modalWidth = 80 const modalHeight = 7 type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget GitRepos []*GitRepo @@ -29,9 +30,9 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"), + TextWidget: view.NewTextWidget(app, settings.common, true), app: app, pages: pages, diff --git a/modules/github/widget.go b/modules/github/widget.go index ad4d3ed3..8e3003fb 100644 --- a/modules/github/widget.go +++ b/modules/github/widget.go @@ -4,13 +4,13 @@ import ( "strings" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.MultiSourceWidget - wtf.KeyboardWidget - wtf.TextWidget + view.MultiSourceWidget + view.KeyboardWidget + view.TextWidget GithubRepos []*GithubRepo @@ -19,9 +19,9 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"), + TextWidget: view.NewTextWidget(app, settings.common, true), settings: settings, } diff --git a/modules/gitlab/widget.go b/modules/gitlab/widget.go index bad0b118..e735ff33 100644 --- a/modules/gitlab/widget.go +++ b/modules/gitlab/widget.go @@ -2,14 +2,14 @@ package gitlab import ( "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" glb "github.com/xanzy/go-gitlab" ) type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget GitlabProjects []*GitlabProject @@ -26,9 +26,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * } widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"), + TextWidget: view.NewTextWidget(app, settings.common, true), gitlab: gitlab, settings: settings, diff --git a/modules/gitter/widget.go b/modules/gitter/widget.go index 79c55682..12c0fb26 100644 --- a/modules/gitter/widget.go +++ b/modules/gitter/widget.go @@ -4,13 +4,14 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // A Widget represents a Gitter widget type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget messages []Message settings *Settings @@ -19,8 +20,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/googleanalytics/widget.go b/modules/googleanalytics/widget.go index af808d47..d74dbc0c 100644 --- a/modules/googleanalytics/widget.go +++ b/modules/googleanalytics/widget.go @@ -2,18 +2,18 @@ package googleanalytics import ( "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/gspreadsheets/widget.go b/modules/gspreadsheets/widget.go index 2224cc51..0cbb34d4 100644 --- a/modules/gspreadsheets/widget.go +++ b/modules/gspreadsheets/widget.go @@ -4,19 +4,20 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" sheets "google.golang.org/api/sheets/v4" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/hackernews/widget.go b/modules/hackernews/widget.go index 2a31e8ce..6274e339 100644 --- a/modules/hackernews/widget.go +++ b/modules/hackernews/widget.go @@ -6,12 +6,13 @@ import ( "strings" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget stories []Story settings *Settings @@ -19,8 +20,8 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := &Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/hibp/widget.go b/modules/hibp/widget.go index f6ff7488..8a7ee1f9 100644 --- a/modules/hibp/widget.go +++ b/modules/hibp/widget.go @@ -4,12 +4,12 @@ import ( "fmt" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // Widget is the container for hibp data type Widget struct { - wtf.TextWidget + view.TextWidget accounts []string settings *Settings @@ -18,7 +18,7 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := &Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/ipaddresses/ipapi/widget.go b/modules/ipaddresses/ipapi/widget.go index eb530e37..158adc1f 100644 --- a/modules/ipaddresses/ipapi/widget.go +++ b/modules/ipaddresses/ipapi/widget.go @@ -9,12 +9,12 @@ import ( "text/template" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // Widget widget struct type Widget struct { - wtf.TextWidget + view.TextWidget result string settings *Settings @@ -38,7 +38,7 @@ type ipinfo struct { // NewWidget constructor func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/ipaddresses/ipinfo/widget.go b/modules/ipaddresses/ipinfo/widget.go index 0cc2a494..8f09f919 100644 --- a/modules/ipaddresses/ipinfo/widget.go +++ b/modules/ipaddresses/ipinfo/widget.go @@ -8,11 +8,11 @@ import ( "text/template" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget result string settings *Settings @@ -31,7 +31,7 @@ type ipinfo struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/jenkins/widget.go b/modules/jenkins/widget.go index f6ca5298..a4579e5b 100644 --- a/modules/jenkins/widget.go +++ b/modules/jenkins/widget.go @@ -5,12 +5,13 @@ import ( "regexp" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget settings *Settings view *View @@ -18,8 +19,8 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/jira/widget.go b/modules/jira/widget.go index 77054475..7ffbb52d 100644 --- a/modules/jira/widget.go +++ b/modules/jira/widget.go @@ -4,12 +4,13 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget result *SearchResult settings *Settings @@ -17,8 +18,8 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/logger/widget.go b/modules/logger/widget.go index b67b2e16..049bd31e 100644 --- a/modules/logger/widget.go +++ b/modules/logger/widget.go @@ -7,13 +7,13 @@ import ( "github.com/rivo/tview" log "github.com/wtfutil/wtf/logger" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) const maxBufferSize int64 = 1024 type Widget struct { - wtf.TextWidget + view.TextWidget app *tview.Application filePath string @@ -22,7 +22,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, true), + TextWidget: view.NewTextWidget(app, settings.common, true), app: app, filePath: log.LogFilePath(), diff --git a/modules/mercurial/widget.go b/modules/mercurial/widget.go index aeae8feb..42b993ba 100644 --- a/modules/mercurial/widget.go +++ b/modules/mercurial/widget.go @@ -3,6 +3,7 @@ package mercurial import ( "github.com/gdamore/tcell" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) @@ -12,9 +13,9 @@ const modalHeight = 7 // A Widget represents a Mercurial widget type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget app *tview.Application Data []*MercurialRepo @@ -25,9 +26,9 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"), + TextWidget: view.NewTextWidget(app, settings.common, true), app: app, pages: pages, diff --git a/modules/nbascore/widget.go b/modules/nbascore/widget.go index c13ddb8e..ff764806 100644 --- a/modules/nbascore/widget.go +++ b/modules/nbascore/widget.go @@ -9,13 +9,14 @@ import ( "time" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // A Widget represents an NBA Score widget type Widget struct { - wtf.KeyboardWidget - wtf.TextWidget + view.KeyboardWidget + view.TextWidget language string result string @@ -27,8 +28,8 @@ var offset = 0 // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + TextWidget: view.NewTextWidget(app, settings.common, true), settings: settings, } diff --git a/modules/newrelic/widget.go b/modules/newrelic/widget.go index 90de8b5a..6d0e974e 100644 --- a/modules/newrelic/widget.go +++ b/modules/newrelic/widget.go @@ -4,12 +4,13 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" nr "github.com/yfronto/newrelic" ) type Widget struct { - wtf.TextWidget + view.TextWidget client *Client settings *Settings @@ -17,7 +18,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/opsgenie/widget.go b/modules/opsgenie/widget.go index 69f1c23b..70075673 100644 --- a/modules/opsgenie/widget.go +++ b/modules/opsgenie/widget.go @@ -5,18 +5,19 @@ import ( "strings" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/pagerduty/widget.go b/modules/pagerduty/widget.go index 47d0ebec..fbf0b314 100644 --- a/modules/pagerduty/widget.go +++ b/modules/pagerduty/widget.go @@ -6,18 +6,19 @@ import ( "github.com/PagerDuty/go-pagerduty" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/power/widget.go b/modules/power/widget.go index 394c0d48..3254ab65 100644 --- a/modules/power/widget.go +++ b/modules/power/widget.go @@ -4,11 +4,11 @@ import ( "fmt" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget Battery *Battery @@ -17,7 +17,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), Battery: NewBattery(), diff --git a/modules/rollbar/widget.go b/modules/rollbar/widget.go index 727f1c47..1d58f940 100644 --- a/modules/rollbar/widget.go +++ b/modules/rollbar/widget.go @@ -4,13 +4,14 @@ import ( "fmt" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // A Widget represents a Rollbar widget type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget items *Result settings *Settings @@ -19,8 +20,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/security/widget.go b/modules/security/widget.go index 8dbaa873..0ae6ac9c 100644 --- a/modules/security/widget.go +++ b/modules/security/widget.go @@ -5,18 +5,18 @@ import ( "strings" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/spotify/widget.go b/modules/spotify/widget.go index 10caeccd..a81fc3d4 100644 --- a/modules/spotify/widget.go +++ b/modules/spotify/widget.go @@ -5,13 +5,14 @@ import ( "github.com/rivo/tview" "github.com/sticreations/spotigopher/spotigopher" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // A Widget represents a Spotify widget type Widget struct { - wtf.KeyboardWidget - wtf.TextWidget + view.KeyboardWidget + view.TextWidget client spotigopher.SpotifyClient settings *Settings @@ -21,8 +22,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + TextWidget: view.NewTextWidget(app, settings.common, true), Info: spotigopher.Info{}, client: spotigopher.NewClient(), diff --git a/modules/spotifyweb/widget.go b/modules/spotifyweb/widget.go index 5b1027ce..cbbf416c 100644 --- a/modules/spotifyweb/widget.go +++ b/modules/spotifyweb/widget.go @@ -7,6 +7,7 @@ import ( "os" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" "github.com/zmb3/spotify" ) @@ -22,8 +23,8 @@ type Info struct { // Widget is the struct used by all WTF widgets to transfer to the main widget controller type Widget struct { - wtf.KeyboardWidget - wtf.TextWidget + view.KeyboardWidget + view.TextWidget Info @@ -68,8 +69,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * var playerState *spotify.PlayerState widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + TextWidget: view.NewTextWidget(app, settings.common, true), Info: Info{}, diff --git a/modules/status/widget.go b/modules/status/widget.go index 24614897..69981beb 100644 --- a/modules/status/widget.go +++ b/modules/status/widget.go @@ -2,11 +2,11 @@ package status import ( "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget CurrentIcon int @@ -15,7 +15,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), CurrentIcon: 0, diff --git a/modules/system/widget.go b/modules/system/widget.go index ac9b2263..b12ce398 100644 --- a/modules/system/widget.go +++ b/modules/system/widget.go @@ -5,11 +5,12 @@ import ( "time" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.TextWidget + view.TextWidget Date string Version string @@ -20,7 +21,7 @@ type Widget struct { func NewWidget(app *tview.Application, date, version string, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), Date: date, diff --git a/modules/textfile/widget.go b/modules/textfile/widget.go index 39e33c0d..9e68d96b 100644 --- a/modules/textfile/widget.go +++ b/modules/textfile/widget.go @@ -14,7 +14,7 @@ import ( "github.com/radovskyb/watcher" "github.com/rivo/tview" "github.com/wtfutil/wtf/utils" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) const ( @@ -22,9 +22,9 @@ const ( ) type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget settings *Settings } @@ -32,9 +32,9 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "filePath", "filePaths"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "filePath", "filePaths"), + TextWidget: view.NewTextWidget(app, settings.common, true), settings: settings, } diff --git a/modules/todo/widget.go b/modules/todo/widget.go index 638b2001..70b73a91 100644 --- a/modules/todo/widget.go +++ b/modules/todo/widget.go @@ -8,18 +8,21 @@ import ( "github.com/rivo/tview" "github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/checklist" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" "gopkg.in/yaml.v2" ) -const offscreen = -1000 -const modalWidth = 80 -const modalHeight = 7 +const ( + offscreen = -1000 + modalWidth = 80 + modalHeight = 7 +) // A Widget represents a Todo widget type Widget struct { - wtf.KeyboardWidget - wtf.TextWidget + view.KeyboardWidget + view.TextWidget app *tview.Application settings *Settings @@ -31,8 +34,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + TextWidget: view.NewTextWidget(app, settings.common, true), app: app, settings: settings, diff --git a/modules/todoist/widget.go b/modules/todoist/widget.go index 9778eac7..8a93369f 100644 --- a/modules/todoist/widget.go +++ b/modules/todoist/widget.go @@ -3,14 +3,14 @@ package todoist import ( "github.com/darkSasori/todoist" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // A Widget represents a Todoist widget type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.MultiSourceWidget + view.ScrollableWidget projects []*Project settings *Settings @@ -19,9 +19,9 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "project", "projects"), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "project", "projects"), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/transmission/widget.go b/modules/transmission/widget.go index b8d76df2..e6c457cd 100644 --- a/modules/transmission/widget.go +++ b/modules/transmission/widget.go @@ -5,13 +5,13 @@ import ( "github.com/hekmon/transmissionrpc" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // Widget is the container for transmission data type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget client *transmissionrpc.Client settings *Settings @@ -21,8 +21,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/travisci/widget.go b/modules/travisci/widget.go index f145b48b..a5e5d582 100644 --- a/modules/travisci/widget.go +++ b/modules/travisci/widget.go @@ -5,12 +5,13 @@ import ( "strings" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget builds *Builds settings *Settings @@ -18,8 +19,8 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/modules/trello/widget.go b/modules/trello/widget.go index 5e29b33f..5dcb217c 100644 --- a/modules/trello/widget.go +++ b/modules/trello/widget.go @@ -5,18 +5,18 @@ import ( "github.com/adlio/trello" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/twitter/widget.go b/modules/twitter/widget.go index b26ae210..f023a6a8 100644 --- a/modules/twitter/widget.go +++ b/modules/twitter/widget.go @@ -7,13 +7,14 @@ import ( "github.com/dustin/go-humanize" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget client *Client idx int @@ -23,9 +24,9 @@ type Widget struct { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "screenName", "screenNames"), + TextWidget: view.NewTextWidget(app, settings.common, true), idx: 0, settings: settings, diff --git a/modules/unknown/widget.go b/modules/unknown/widget.go index 77090b3a..2e53475f 100644 --- a/modules/unknown/widget.go +++ b/modules/unknown/widget.go @@ -4,18 +4,18 @@ import ( "fmt" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) type Widget struct { - wtf.TextWidget + view.TextWidget settings *Settings } func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/victorops/widget.go b/modules/victorops/widget.go index 924102fa..a1ad09a5 100644 --- a/modules/victorops/widget.go +++ b/modules/victorops/widget.go @@ -4,12 +4,12 @@ import ( "fmt" "github.com/rivo/tview" - "github.com/wtfutil/wtf/wtf" + "github.com/wtfutil/wtf/view" ) // Widget contains text info type Widget struct { - wtf.TextWidget + view.TextWidget teams []OnCallTeam settings *Settings @@ -18,7 +18,7 @@ type Widget struct { // NewWidget creates a new widget func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, true), + TextWidget: view.NewTextWidget(app, settings.common, true), } widget.View.SetScrollable(true) diff --git a/modules/weatherservices/prettyweather/widget.go b/modules/weatherservices/prettyweather/widget.go index 8645ba60..f98a7791 100644 --- a/modules/weatherservices/prettyweather/widget.go +++ b/modules/weatherservices/prettyweather/widget.go @@ -6,11 +6,12 @@ import ( "strings" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) type Widget struct { - wtf.TextWidget + view.TextWidget result string settings *Settings @@ -18,7 +19,7 @@ type Widget struct { func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(app, settings.common, false), + TextWidget: view.NewTextWidget(app, settings.common, false), settings: settings, } diff --git a/modules/weatherservices/weather/widget.go b/modules/weatherservices/weather/widget.go index 4f4ba669..5fa52ff6 100644 --- a/modules/weatherservices/weather/widget.go +++ b/modules/weatherservices/weather/widget.go @@ -3,14 +3,15 @@ package weather import ( owm "github.com/briandowns/openweathermap" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // Widget is the container for weather data. type Widget struct { - wtf.KeyboardWidget - wtf.MultiSourceWidget - wtf.TextWidget + view.KeyboardWidget + view.MultiSourceWidget + view.TextWidget // APIKey string Data []*owm.CurrentWeatherData @@ -22,9 +23,9 @@ type Widget struct { // NewWidget creates and returns a new instance of the weather Widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "cityid", "cityids"), - TextWidget: wtf.NewTextWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "cityid", "cityids"), + TextWidget: view.NewTextWidget(app, settings.common, true), pages: pages, settings: settings, diff --git a/modules/zendesk/widget.go b/modules/zendesk/widget.go index f8702539..3b1f4cdc 100644 --- a/modules/zendesk/widget.go +++ b/modules/zendesk/widget.go @@ -5,13 +5,14 @@ import ( "log" "github.com/rivo/tview" + "github.com/wtfutil/wtf/view" "github.com/wtfutil/wtf/wtf" ) // A Widget represents a Zendesk widget type Widget struct { - wtf.KeyboardWidget - wtf.ScrollableWidget + view.KeyboardWidget + view.ScrollableWidget result *TicketArray settings *Settings @@ -20,8 +21,8 @@ type Widget struct { // NewWidget creates a new instance of a widget func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { widget := Widget{ - KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), - ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), + KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common), + ScrollableWidget: view.NewScrollableWidget(app, settings.common, true), settings: settings, } diff --git a/wtf/keyboard_widget.go b/view/keyboard_widget.go similarity index 96% rename from wtf/keyboard_widget.go rename to view/keyboard_widget.go index 4e09e0ab..d48c69fd 100644 --- a/wtf/keyboard_widget.go +++ b/view/keyboard_widget.go @@ -1,4 +1,4 @@ -package wtf +package view import ( "fmt" @@ -7,6 +7,7 @@ import ( "github.com/gdamore/tcell" "github.com/rivo/tview" "github.com/wtfutil/wtf/cfg" + "github.com/wtfutil/wtf/wtf" ) type helpItem struct { @@ -120,7 +121,7 @@ func (widget *KeyboardWidget) ShowHelp() { widget.app.SetFocus(widget.view) } - modal := NewBillboardModal(widget.HelpText(), closeFunc) + modal := wtf.NewBillboardModal(widget.HelpText(), closeFunc) widget.pages.AddPage("help", modal, false, true) widget.app.SetFocus(modal) diff --git a/wtf/keyboard_widget_test.go b/view/keyboard_widget_test.go similarity index 99% rename from wtf/keyboard_widget_test.go rename to view/keyboard_widget_test.go index 1eade042..c1540850 100644 --- a/wtf/keyboard_widget_test.go +++ b/view/keyboard_widget_test.go @@ -1,4 +1,4 @@ -package wtf +package view import ( "testing" diff --git a/wtf/multisource_widget.go b/view/multisource_widget.go similarity index 97% rename from wtf/multisource_widget.go rename to view/multisource_widget.go index 8bfa8cbd..f3f818e7 100644 --- a/wtf/multisource_widget.go +++ b/view/multisource_widget.go @@ -1,7 +1,8 @@ -package wtf +package view import ( "github.com/wtfutil/wtf/cfg" + "github.com/wtfutil/wtf/wtf" ) // MultiSourceWidget is a widget that supports displaying data from multiple sources @@ -89,7 +90,7 @@ func (widget *MultiSourceWidget) loadSources() { single := widget.moduleConfig.Config.UString(widget.singular, "") multiple := widget.moduleConfig.Config.UList(widget.plural, empty) - asStrs := ToStrs(multiple) + asStrs := wtf.ToStrs(multiple) if single != "" { asStrs = append(asStrs, single) diff --git a/wtf/scrollable.go b/view/scrollable.go similarity index 99% rename from wtf/scrollable.go rename to view/scrollable.go index 22d84fd6..38744344 100644 --- a/wtf/scrollable.go +++ b/view/scrollable.go @@ -1,4 +1,4 @@ -package wtf +package view import ( "strconv" @@ -16,7 +16,6 @@ type ScrollableWidget struct { } func NewScrollableWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) ScrollableWidget { - widget := ScrollableWidget{ TextWidget: NewTextWidget(app, commonSettings, focusable), } diff --git a/wtf/text_widget.go b/view/text_widget.go similarity index 91% rename from wtf/text_widget.go rename to view/text_widget.go index eb851918..f71a8a4d 100644 --- a/wtf/text_widget.go +++ b/view/text_widget.go @@ -1,4 +1,4 @@ -package wtf +package view import ( "fmt" @@ -6,6 +6,7 @@ import ( "github.com/rivo/tview" "github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/utils" + "github.com/wtfutil/wtf/wtf" ) type TextWidget struct { @@ -148,10 +149,10 @@ func (widget *TextWidget) Redraw(title, text string, wrap bool) { func (widget *TextWidget) addView() *tview.TextView { view := tview.NewTextView() - view.SetBackgroundColor(ColorFor(widget.commonSettings.Colors.Background)) - view.SetBorderColor(ColorFor(widget.BorderColor())) - view.SetTextColor(ColorFor(widget.commonSettings.Colors.Text)) - view.SetTitleColor(ColorFor(widget.commonSettings.Colors.Title)) + view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background)) + view.SetBorderColor(wtf.ColorFor(widget.BorderColor())) + view.SetTextColor(wtf.ColorFor(widget.commonSettings.Colors.Text)) + view.SetTitleColor(wtf.ColorFor(widget.commonSettings.Colors.Title)) view.SetBorder(true) view.SetDynamicColors(true) diff --git a/wtf/text_widget_test.go b/view/text_widget_test.go similarity index 99% rename from wtf/text_widget_test.go rename to view/text_widget_test.go index 4e2baa64..18a6b909 100644 --- a/wtf/text_widget_test.go +++ b/view/text_widget_test.go @@ -1,4 +1,4 @@ -package wtf +package view import ( "testing"