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

Merge branch 'master' into patch-1

This commit is contained in:
Chris Cummer 2018-10-17 19:04:41 -07:00 committed by GitHub
commit aa5389c820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 4 deletions

View File

@ -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

View File

@ -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)),
}