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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user