diff --git a/wtf/focus_tracker.go b/wtf/focus_tracker.go index 06b1f16c..b7296f01 100644 --- a/wtf/focus_tracker.go +++ b/wtf/focus_tracker.go @@ -29,9 +29,25 @@ func (tracker *FocusTracker) AssignHotKeys() { return } + usedKeys := make(map[string]bool) + focusables := tracker.focusables() i := 1 - for _, focusable := range tracker.focusables() { + for _, focusable := range focusables { + if focusable.FocusChar() != "" { + usedKeys[focusable.FocusChar()] = true + } + } + for _, focusable := range focusables { + if focusable.FocusChar() != "" { + continue + } + if _, foundKey := usedKeys[string('0'+i)]; foundKey { + for ; foundKey; _, foundKey = usedKeys[string('0'+i)] { + i++ + } + } + // Don't have nav characters > "9" if i >= 10 { break diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 3ca58480..1e661e9b 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -22,10 +22,16 @@ type TextWidget struct { } func NewTextWidget(app *tview.Application, name string, configKey string, focusable bool) TextWidget { - widget := TextWidget{ - enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false), - focusable: focusable, + focusCharValue := Config.UInt(fmt.Sprintf("wtf.mods.%s.focusChar", configKey), -1) + focusChar := string('0' + focusCharValue) + if focusCharValue == -1 { + focusChar = "" + } + widget := TextWidget{ + enabled: Config.UBool(fmt.Sprintf("wtf.mods.%s.enabled", configKey), false), + focusable: focusable, + focusChar: focusChar, Name: Config.UString(fmt.Sprintf("wtf.mods.%s.title", configKey), name), RefreshInt: Config.UInt(fmt.Sprintf("wtf.mods.%s.refreshInterval", configKey)), }