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:
commit
da75e116c1
@ -17,7 +17,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr"),
|
||||
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -16,7 +16,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 🕗 World Clocks ", "clocks"),
|
||||
TextWidget: wtf.NewTextWidget(" 🕗 World Clocks ", "clocks", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -19,7 +19,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal"),
|
||||
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Git ", "git"),
|
||||
TextWidget: wtf.NewTextWidget(" Git ", "git", true),
|
||||
Idx: 0,
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Github ", "github"),
|
||||
TextWidget: wtf.NewTextWidget(" Github ", "github", true),
|
||||
Idx: 0,
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget("JIRA", "jira"),
|
||||
TextWidget: wtf.NewTextWidget("JIRA", "jira", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -18,7 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic"),
|
||||
TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -18,7 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie"),
|
||||
TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -17,7 +17,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security"),
|
||||
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security", false),
|
||||
}
|
||||
|
||||
return &widget
|
||||
|
@ -19,7 +19,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status"),
|
||||
TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status", false),
|
||||
Current: 0,
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(builtAt, version string) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" System ", "system"),
|
||||
TextWidget: wtf.NewTextWidget(" System ", "system", false),
|
||||
BuiltAt: builtAt,
|
||||
Version: version,
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile"),
|
||||
TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile", true),
|
||||
FilePath: Config.UString("wtf.mods.textfile.filename"),
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" 📝 Todo ", "todo"),
|
||||
TextWidget: wtf.NewTextWidget(" 📝 Todo ", "todo", true),
|
||||
|
||||
app: app,
|
||||
pages: pages,
|
||||
|
@ -25,7 +25,7 @@ type Widget struct {
|
||||
// NewWidget creates and returns a new instance of the weather Widget.
|
||||
func NewWidget() *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Weather ", "weather"),
|
||||
TextWidget: wtf.NewTextWidget(" Weather ", "weather", true),
|
||||
APIKey: os.Getenv("WTF_OWM_API_KEY"),
|
||||
Idx: 0,
|
||||
}
|
||||
@ -186,6 +186,8 @@ func (widget *Widget) icon(data *owm.CurrentWeatherData) string {
|
||||
icon = "❄️"
|
||||
case "sunny":
|
||||
icon = "☀️"
|
||||
case "thunderstorm":
|
||||
icon = "⛈"
|
||||
default:
|
||||
icon = "💥"
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func (tracker *FocusTracker) Prev() {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (tracker *FocusTracker) blur(idx int) {
|
||||
view := tracker.Widgets[idx].TextView()
|
||||
view := tracker.focusable()[idx].TextView()
|
||||
view.Blur()
|
||||
view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.normal", "gray")))
|
||||
}
|
||||
@ -55,20 +55,32 @@ func (tracker *FocusTracker) decrement() {
|
||||
tracker.Idx = tracker.Idx - 1
|
||||
|
||||
if tracker.Idx < 0 {
|
||||
tracker.Idx = len(tracker.Widgets) - 1
|
||||
tracker.Idx = len(tracker.focusable()) - 1
|
||||
}
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) focus(idx int) {
|
||||
view := tracker.Widgets[idx].TextView()
|
||||
view := tracker.focusable()[idx].TextView()
|
||||
tracker.App.SetFocus(view)
|
||||
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() {
|
||||
tracker.Idx = tracker.Idx + 1
|
||||
|
||||
if tracker.Idx == len(tracker.Widgets) {
|
||||
if tracker.Idx == len(tracker.focusable()) {
|
||||
tracker.Idx = 0
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ type TextViewer interface {
|
||||
Enabler
|
||||
Scheduler
|
||||
|
||||
//Refresh()
|
||||
Focusable() bool
|
||||
TextView() *tview.TextView
|
||||
|
||||
Top() int
|
||||
|
@ -13,6 +13,7 @@ var Config *config.Config
|
||||
type TextWidget struct {
|
||||
enabled bool
|
||||
|
||||
focusable bool
|
||||
Name string
|
||||
RefreshedAt time.Time
|
||||
RefreshInt int
|
||||
@ -21,9 +22,10 @@ type TextWidget struct {
|
||||
Position
|
||||
}
|
||||
|
||||
func NewTextWidget(name string, configKey string) TextWidget {
|
||||
func NewTextWidget(name string, configKey string, focusable bool) TextWidget {
|
||||
widget := TextWidget{
|
||||
enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false),
|
||||
focusable: focusable,
|
||||
Name: name,
|
||||
RefreshInt: Config.UInt(fmt.Sprintf("wtf.mods.%s.refreshInterval", configKey)),
|
||||
Position: Position{
|
||||
@ -49,6 +51,10 @@ func (widget *TextWidget) Enabled() bool {
|
||||
return widget.enabled
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Focusable() bool {
|
||||
return widget.focusable
|
||||
}
|
||||
|
||||
func (widget *TextWidget) RefreshInterval() int {
|
||||
return widget.RefreshInt
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user