mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
add static hot key assignments for text widgets
This commit is contained in:
parent
a48d15079a
commit
7d9dd56aaa
@ -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
|
||||
|
@ -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)),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user