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

Fix merge conflict in todo/widget.go

This commit is contained in:
Chris Cummer 2018-04-29 07:55:00 -07:00
commit da75e116c1
17 changed files with 40 additions and 20 deletions

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr"), TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr", false),
} }
return &widget return &widget

View File

@ -16,7 +16,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🕗 World Clocks ", "clocks"), TextWidget: wtf.NewTextWidget(" 🕗 World Clocks ", "clocks", false),
} }
return &widget return &widget

View File

@ -19,7 +19,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal"), TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal", false),
} }
return &widget return &widget

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" Git ", "git"), TextWidget: wtf.NewTextWidget(" Git ", "git", true),
Idx: 0, Idx: 0,
} }

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" Github ", "github"), TextWidget: wtf.NewTextWidget(" Github ", "github", true),
Idx: 0, Idx: 0,
} }

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget("JIRA", "jira"), TextWidget: wtf.NewTextWidget("JIRA", "jira", false),
} }
return &widget return &widget

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic"), TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic", false),
} }
return &widget return &widget

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie"), TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie", false),
} }
return &widget return &widget

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security"), TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security", false),
} }
return &widget return &widget

View File

@ -19,7 +19,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status"), TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status", false),
Current: 0, Current: 0,
} }

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget(builtAt, version string) *Widget { func NewWidget(builtAt, version string) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" System ", "system"), TextWidget: wtf.NewTextWidget(" System ", "system", false),
BuiltAt: builtAt, BuiltAt: builtAt,
Version: version, Version: version,
} }

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile"), TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile", true),
FilePath: Config.UString("wtf.mods.textfile.filename"), FilePath: Config.UString("wtf.mods.textfile.filename"),
} }

View File

@ -26,7 +26,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 📝 Todo ", "todo"), TextWidget: wtf.NewTextWidget(" 📝 Todo ", "todo", true),
app: app, app: app,
pages: pages, pages: pages,

View File

@ -25,7 +25,7 @@ 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() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" Weather ", "weather"), TextWidget: wtf.NewTextWidget(" Weather ", "weather", true),
APIKey: os.Getenv("WTF_OWM_API_KEY"), APIKey: os.Getenv("WTF_OWM_API_KEY"),
Idx: 0, Idx: 0,
} }
@ -186,6 +186,8 @@ func (widget *Widget) icon(data *owm.CurrentWeatherData) string {
icon = "❄️" icon = "❄️"
case "sunny": case "sunny":
icon = "☀️" icon = "☀️"
case "thunderstorm":
icon = "⛈"
default: default:
icon = "💥" icon = "💥"
} }

View File

@ -46,7 +46,7 @@ func (tracker *FocusTracker) Prev() {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func (tracker *FocusTracker) blur(idx int) { func (tracker *FocusTracker) blur(idx int) {
view := tracker.Widgets[idx].TextView() view := tracker.focusable()[idx].TextView()
view.Blur() view.Blur()
view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.normal", "gray"))) view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.normal", "gray")))
} }
@ -55,20 +55,32 @@ func (tracker *FocusTracker) decrement() {
tracker.Idx = tracker.Idx - 1 tracker.Idx = tracker.Idx - 1
if tracker.Idx < 0 { if tracker.Idx < 0 {
tracker.Idx = len(tracker.Widgets) - 1 tracker.Idx = len(tracker.focusable()) - 1
} }
} }
func (tracker *FocusTracker) focus(idx int) { func (tracker *FocusTracker) focus(idx int) {
view := tracker.Widgets[idx].TextView() view := tracker.focusable()[idx].TextView()
tracker.App.SetFocus(view) tracker.App.SetFocus(view)
view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.focus", "gray"))) view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.focus", "gray")))
} }
func (tracker *FocusTracker) focusable() []TextViewer {
focusable := []TextViewer{}
for _, widget := range tracker.Widgets {
if widget.Focusable() {
focusable = append(focusable, widget)
}
}
return focusable
}
func (tracker *FocusTracker) increment() { func (tracker *FocusTracker) increment() {
tracker.Idx = tracker.Idx + 1 tracker.Idx = tracker.Idx + 1
if tracker.Idx == len(tracker.Widgets) { if tracker.Idx == len(tracker.focusable()) {
tracker.Idx = 0 tracker.Idx = 0
} }
} }

View File

@ -9,7 +9,7 @@ type TextViewer interface {
Enabler Enabler
Scheduler Scheduler
//Refresh() Focusable() bool
TextView() *tview.TextView TextView() *tview.TextView
Top() int Top() int

View File

@ -13,6 +13,7 @@ var Config *config.Config
type TextWidget struct { type TextWidget struct {
enabled bool enabled bool
focusable bool
Name string Name string
RefreshedAt time.Time RefreshedAt time.Time
RefreshInt int RefreshInt int
@ -21,9 +22,10 @@ type TextWidget struct {
Position Position
} }
func NewTextWidget(name string, configKey string) TextWidget { func NewTextWidget(name string, configKey string, focusable bool) TextWidget {
widget := TextWidget{ widget := TextWidget{
enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false), enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false),
focusable: focusable,
Name: name, Name: name,
RefreshInt: Config.UInt(fmt.Sprintf("wtf.mods.%s.refreshInterval", configKey)), RefreshInt: Config.UInt(fmt.Sprintf("wtf.mods.%s.refreshInterval", configKey)),
Position: Position{ Position: Position{
@ -49,6 +51,10 @@ func (widget *TextWidget) Enabled() bool {
return widget.enabled return widget.enabled
} }
func (widget *TextWidget) Focusable() bool {
return widget.focusable
}
func (widget *TextWidget) RefreshInterval() int { func (widget *TextWidget) RefreshInterval() int {
return widget.RefreshInt return widget.RefreshInt
} }