1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Move all components responsible for module composition into /view

This commit is contained in:
Chris Cummer 2019-08-04 21:42:40 -07:00
parent 94d63306d4
commit dbc047516d
54 changed files with 226 additions and 196 deletions

View File

@ -5,20 +5,21 @@ import (
"time" "time"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
const APIURI = "https://api.bamboohr.com/api/gateway.php" const APIURI = "https://api.bamboohr.com/api/gateway.php"
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -4,11 +4,11 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
*Client *Client
settings *Settings settings *Settings
@ -16,7 +16,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
Client: NewClient(settings.apiKey), Client: NewClient(settings.apiKey),
settings: settings, settings: settings,

View File

@ -5,11 +5,11 @@ import (
"time" "time"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
app *tview.Application app *tview.Application
clockColl ClockCollection clockColl ClockCollection
@ -20,7 +20,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
app: app, app: app,
settings: settings, settings: settings,

View File

@ -6,11 +6,12 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
args []string args []string
cmd string cmd string
@ -20,7 +21,7 @@ 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(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
args: settings.args, args: settings.args,
cmd: settings.cmd, cmd: settings.cmd,

View File

@ -8,7 +8,7 @@ import (
"net/http" "net/http"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
var ok = true 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 // Widget define wtf widget to register widget later
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
summaryList summaryList
@ -27,7 +27,7 @@ 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(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
summaryList: summaryList{}, summaryList: summaryList{},

View File

@ -8,11 +8,11 @@ import (
"net/http" "net/http"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
device_token string device_token string
settings *Settings settings *Settings
@ -20,7 +20,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
device_token: settings.deviceToken, device_token: settings.deviceToken,
settings: settings, settings: settings,

View File

@ -7,12 +7,12 @@ import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/price" "github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/price"
"github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/toplist" "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 // Widget define wtf widget to register widget later
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
priceWidget *price.Widget priceWidget *price.Widget
toplistWidget *toplist.Widget toplistWidget *toplist.Widget
@ -22,7 +22,7 @@ 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(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
priceWidget: price.NewWidget(settings.priceSettings), priceWidget: price.NewWidget(settings.priceSettings),
toplistWidget: toplist.NewWidget(settings.toplistSettings), toplistWidget: toplist.NewWidget(settings.toplistSettings),

View File

@ -4,13 +4,14 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
datadog "github.com/zorkian/go-datadog-api" datadog "github.com/zorkian/go-datadog-api"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
monitors []datadog.Monitor monitors []datadog.Monitor
settings *Settings settings *Settings
@ -18,8 +19,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/mmcdole/gofeed" "github.com/mmcdole/gofeed"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
@ -22,8 +23,8 @@ type FeedItem struct {
// Widget is the container for RSS and Atom data // Widget is the container for RSS and Atom data
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
stories []*FeedItem stories []*FeedItem
parser *gofeed.Parser parser *gofeed.Parser
@ -33,8 +34,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := &Widget{ widget := &Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
parser: gofeed.NewParser(), parser: gofeed.NewParser(),
settings: settings, settings: settings,

View File

@ -2,11 +2,11 @@ package gcal
import ( import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
app *tview.Application app *tview.Application
calEvents []*CalEvent calEvents []*CalEvent
@ -15,7 +15,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
app: app, app: app,
settings: settings, settings: settings,

View File

@ -8,12 +8,13 @@ import (
glb "github.com/andygrunwald/go-gerrit" glb "github.com/andygrunwald/go-gerrit"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
gerrit *glb.Client gerrit *glb.Client
@ -30,8 +31,8 @@ var (
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
Idx: 0, Idx: 0,

View File

@ -8,6 +8,7 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
@ -16,9 +17,9 @@ const modalWidth = 80
const modalHeight = 7 const modalHeight = 7
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
GitRepos []*GitRepo GitRepos []*GitRepo
@ -29,9 +30,9 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
app: app, app: app,
pages: pages, pages: pages,

View File

@ -4,13 +4,13 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
GithubRepos []*GithubRepo GithubRepos []*GithubRepo
@ -19,9 +19,9 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -2,14 +2,14 @@ package gitlab
import ( import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
glb "github.com/xanzy/go-gitlab" glb "github.com/xanzy/go-gitlab"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
GitlabProjects []*GitlabProject GitlabProjects []*GitlabProject
@ -26,9 +26,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
} }
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
gitlab: gitlab, gitlab: gitlab,
settings: settings, settings: settings,

View File

@ -4,13 +4,14 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// A Widget represents a Gitter widget // A Widget represents a Gitter widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
messages []Message messages []Message
settings *Settings settings *Settings
@ -19,8 +20,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -2,18 +2,18 @@ package googleanalytics
import ( import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -4,19 +4,20 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
sheets "google.golang.org/api/sheets/v4" sheets "google.golang.org/api/sheets/v4"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -6,12 +6,13 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
stories []Story stories []Story
settings *Settings settings *Settings
@ -19,8 +20,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := &Widget{ widget := &Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
// Widget is the container for hibp data // Widget is the container for hibp data
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
accounts []string accounts []string
settings *Settings settings *Settings
@ -18,7 +18,7 @@ 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(app *tview.Application, settings *Settings) *Widget {
widget := &Widget{ widget := &Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -9,12 +9,12 @@ import (
"text/template" "text/template"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
// Widget widget struct // Widget widget struct
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
result string result string
settings *Settings settings *Settings
@ -38,7 +38,7 @@ type ipinfo struct {
// NewWidget constructor // NewWidget constructor
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -8,11 +8,11 @@ import (
"text/template" "text/template"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
result string result string
settings *Settings settings *Settings
@ -31,7 +31,7 @@ type ipinfo struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -5,12 +5,13 @@ import (
"regexp" "regexp"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
settings *Settings settings *Settings
view *View view *View
@ -18,8 +19,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
result *SearchResult result *SearchResult
settings *Settings settings *Settings
@ -17,8 +18,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -7,13 +7,13 @@ import (
"github.com/rivo/tview" "github.com/rivo/tview"
log "github.com/wtfutil/wtf/logger" log "github.com/wtfutil/wtf/logger"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
const maxBufferSize int64 = 1024 const maxBufferSize int64 = 1024
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
app *tview.Application app *tview.Application
filePath string filePath string
@ -22,7 +22,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
app: app, app: app,
filePath: log.LogFilePath(), filePath: log.LogFilePath(),

View File

@ -3,6 +3,7 @@ package mercurial
import ( import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
@ -12,9 +13,9 @@ const modalHeight = 7
// A Widget represents a Mercurial widget // A Widget represents a Mercurial widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
app *tview.Application app *tview.Application
Data []*MercurialRepo Data []*MercurialRepo
@ -25,9 +26,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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "repository", "repositories"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "repository", "repositories"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
app: app, app: app,
pages: pages, pages: pages,

View File

@ -9,13 +9,14 @@ import (
"time" "time"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// A Widget represents an NBA Score widget // A Widget represents an NBA Score widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
language string language string
result string result string
@ -27,8 +28,8 @@ var offset = 0
// 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
nr "github.com/yfronto/newrelic" nr "github.com/yfronto/newrelic"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
client *Client client *Client
settings *Settings settings *Settings
@ -17,7 +18,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -5,18 +5,19 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -6,18 +6,19 @@ import (
"github.com/PagerDuty/go-pagerduty" "github.com/PagerDuty/go-pagerduty"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -4,11 +4,11 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
Battery *Battery Battery *Battery
@ -17,7 +17,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
Battery: NewBattery(), Battery: NewBattery(),

View File

@ -4,13 +4,14 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// A Widget represents a Rollbar widget // A Widget represents a Rollbar widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
items *Result items *Result
settings *Settings settings *Settings
@ -19,8 +20,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -5,18 +5,18 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -5,13 +5,14 @@ import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/sticreations/spotigopher/spotigopher" "github.com/sticreations/spotigopher/spotigopher"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// A Widget represents a Spotify widget // A Widget represents a Spotify widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
client spotigopher.SpotifyClient client spotigopher.SpotifyClient
settings *Settings settings *Settings
@ -21,8 +22,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
Info: spotigopher.Info{}, Info: spotigopher.Info{},
client: spotigopher.NewClient(), client: spotigopher.NewClient(),

View File

@ -7,6 +7,7 @@ import (
"os" "os"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
"github.com/zmb3/spotify" "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 // Widget is the struct used by all WTF widgets to transfer to the main widget controller
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
Info Info
@ -68,8 +69,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
var playerState *spotify.PlayerState var playerState *spotify.PlayerState
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
Info: Info{}, Info: Info{},

View File

@ -2,11 +2,11 @@ package status
import ( import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
CurrentIcon int CurrentIcon int
@ -15,7 +15,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
CurrentIcon: 0, CurrentIcon: 0,

View File

@ -5,11 +5,12 @@ import (
"time" "time"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
Date string Date string
Version string Version string
@ -20,7 +21,7 @@ type Widget struct {
func NewWidget(app *tview.Application, date, version string, settings *Settings) *Widget { func NewWidget(app *tview.Application, date, version string, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
Date: date, Date: date,

View File

@ -14,7 +14,7 @@ import (
"github.com/radovskyb/watcher" "github.com/radovskyb/watcher"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/utils" "github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
const ( const (
@ -22,9 +22,9 @@ const (
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
@ -32,9 +32,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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "filePath", "filePaths"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "filePath", "filePaths"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -8,18 +8,21 @@ import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/checklist" "github.com/wtfutil/wtf/checklist"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
const offscreen = -1000 const (
const modalWidth = 80 offscreen = -1000
const modalHeight = 7 modalWidth = 80
modalHeight = 7
)
// A Widget represents a Todo widget // A Widget represents a Todo widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.TextWidget view.TextWidget
app *tview.Application app *tview.Application
settings *Settings settings *Settings
@ -31,8 +34,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
app: app, app: app,
settings: settings, settings: settings,

View File

@ -3,14 +3,14 @@ package todoist
import ( import (
"github.com/darkSasori/todoist" "github.com/darkSasori/todoist"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
// A Widget represents a Todoist widget // A Widget represents a Todoist widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.ScrollableWidget view.ScrollableWidget
projects []*Project projects []*Project
settings *Settings settings *Settings
@ -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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "project", "projects"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "project", "projects"),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -5,13 +5,13 @@ import (
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
// Widget is the container for transmission data // Widget is the container for transmission data
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
client *transmissionrpc.Client client *transmissionrpc.Client
settings *Settings settings *Settings
@ -21,8 +21,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -5,12 +5,13 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
builds *Builds builds *Builds
settings *Settings settings *Settings
@ -18,8 +19,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -5,18 +5,18 @@ import (
"github.com/adlio/trello" "github.com/adlio/trello"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -7,13 +7,14 @@ import (
"github.com/dustin/go-humanize" "github.com/dustin/go-humanize"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
client *Client client *Client
idx int idx int
@ -23,9 +24,9 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "screenName", "screenNames"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
idx: 0, idx: 0,
settings: settings, settings: settings,

View File

@ -4,18 +4,18 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
settings *Settings settings *Settings
} }
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/view"
) )
// Widget contains text info // Widget contains text info
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
teams []OnCallTeam teams []OnCallTeam
settings *Settings settings *Settings
@ -18,7 +18,7 @@ type Widget struct {
// NewWidget creates a new widget // NewWidget creates a new widget
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
} }
widget.View.SetScrollable(true) widget.View.SetScrollable(true)

View File

@ -6,11 +6,12 @@ import (
"strings" "strings"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
type Widget struct { type Widget struct {
wtf.TextWidget view.TextWidget
result string result string
settings *Settings settings *Settings
@ -18,7 +19,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, settings.common, false), TextWidget: view.NewTextWidget(app, settings.common, false),
settings: settings, settings: settings,
} }

View File

@ -3,14 +3,15 @@ package weather
import ( import (
owm "github.com/briandowns/openweathermap" owm "github.com/briandowns/openweathermap"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// Widget is the container for weather data. // Widget is the container for weather data.
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.MultiSourceWidget view.MultiSourceWidget
wtf.TextWidget view.TextWidget
// APIKey string // APIKey string
Data []*owm.CurrentWeatherData Data []*owm.CurrentWeatherData
@ -22,9 +23,9 @@ type Widget struct {
// NewWidget creates and returns a new instance of the weather Widget // NewWidget creates and returns a new instance of the weather Widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "cityid", "cityids"), MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "cityid", "cityids"),
TextWidget: wtf.NewTextWidget(app, settings.common, true), TextWidget: view.NewTextWidget(app, settings.common, true),
pages: pages, pages: pages,
settings: settings, settings: settings,

View File

@ -5,13 +5,14 @@ import (
"log" "log"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
// A Widget represents a Zendesk widget // A Widget represents a Zendesk widget
type Widget struct { type Widget struct {
wtf.KeyboardWidget view.KeyboardWidget
wtf.ScrollableWidget view.ScrollableWidget
result *TicketArray result *TicketArray
settings *Settings settings *Settings
@ -20,8 +21,8 @@ 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(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
KeyboardWidget: wtf.NewKeyboardWidget(app, pages, settings.common), KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: wtf.NewScrollableWidget(app, settings.common, true), ScrollableWidget: view.NewScrollableWidget(app, settings.common, true),
settings: settings, settings: settings,
} }

View File

@ -1,4 +1,4 @@
package wtf package view
import ( import (
"fmt" "fmt"
@ -7,6 +7,7 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/wtf"
) )
type helpItem struct { type helpItem struct {
@ -120,7 +121,7 @@ func (widget *KeyboardWidget) ShowHelp() {
widget.app.SetFocus(widget.view) widget.app.SetFocus(widget.view)
} }
modal := NewBillboardModal(widget.HelpText(), closeFunc) modal := wtf.NewBillboardModal(widget.HelpText(), closeFunc)
widget.pages.AddPage("help", modal, false, true) widget.pages.AddPage("help", modal, false, true)
widget.app.SetFocus(modal) widget.app.SetFocus(modal)

View File

@ -1,4 +1,4 @@
package wtf package view
import ( import (
"testing" "testing"

View File

@ -1,7 +1,8 @@
package wtf package view
import ( import (
"github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/wtf"
) )
// MultiSourceWidget is a widget that supports displaying data from multiple sources // 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, "") single := widget.moduleConfig.Config.UString(widget.singular, "")
multiple := widget.moduleConfig.Config.UList(widget.plural, empty) multiple := widget.moduleConfig.Config.UList(widget.plural, empty)
asStrs := ToStrs(multiple) asStrs := wtf.ToStrs(multiple)
if single != "" { if single != "" {
asStrs = append(asStrs, single) asStrs = append(asStrs, single)

View File

@ -1,4 +1,4 @@
package wtf package view
import ( import (
"strconv" "strconv"
@ -16,7 +16,6 @@ type ScrollableWidget struct {
} }
func NewScrollableWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) ScrollableWidget { func NewScrollableWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) ScrollableWidget {
widget := ScrollableWidget{ widget := ScrollableWidget{
TextWidget: NewTextWidget(app, commonSettings, focusable), TextWidget: NewTextWidget(app, commonSettings, focusable),
} }

View File

@ -1,4 +1,4 @@
package wtf package view
import ( import (
"fmt" "fmt"
@ -6,6 +6,7 @@ import (
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/cfg" "github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils" "github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf"
) )
type TextWidget struct { type TextWidget struct {
@ -148,10 +149,10 @@ func (widget *TextWidget) Redraw(title, text string, wrap bool) {
func (widget *TextWidget) addView() *tview.TextView { func (widget *TextWidget) addView() *tview.TextView {
view := tview.NewTextView() view := tview.NewTextView()
view.SetBackgroundColor(ColorFor(widget.commonSettings.Colors.Background)) view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background))
view.SetBorderColor(ColorFor(widget.BorderColor())) view.SetBorderColor(wtf.ColorFor(widget.BorderColor()))
view.SetTextColor(ColorFor(widget.commonSettings.Colors.Text)) view.SetTextColor(wtf.ColorFor(widget.commonSettings.Colors.Text))
view.SetTitleColor(ColorFor(widget.commonSettings.Colors.Title)) view.SetTitleColor(wtf.ColorFor(widget.commonSettings.Colors.Title))
view.SetBorder(true) view.SetBorder(true)
view.SetDynamicColors(true) view.SetDynamicColors(true)

View File

@ -1,4 +1,4 @@
package wtf package view
import ( import (
"testing" "testing"