Wonkiness on layout

This commit is contained in:
2025-10-10 16:46:29 -05:00
parent 79a212e601
commit 7a1afd67ac
28 changed files with 362 additions and 156 deletions

View File

@@ -47,7 +47,7 @@ type Menu struct {
expanded bool
vimMode bool
keyMap KeyMap
keyMap, customKeyMap KeyMap
}
type MenuType int
@@ -81,6 +81,7 @@ func (w *Menu) Init(id string, style tcell.Style) {
return false
},
})
w.customKeyMap = BlankKeyMap()
w.focusable = true
}
func (w *Menu) Id() string { return w.id }
@@ -123,14 +124,20 @@ func (w *Menu) handleResizeV(_ *tcell.EventResize) {
}
}
func (w *Menu) SetKeyMap(km KeyMap) { w.keyMap = km }
func (w *Menu) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *Menu) SetKeyMap(km KeyMap, def bool) {
if def {
w.keyMap = km
} else {
w.customKeyMap = km
}
}
func (w *Menu) AddToKeyMap(km KeyMap) { w.customKeyMap.Merge(km) }
func (w *Menu) RemoveFromKeyMap(km KeyMap) {
for k := range km.Keys {
w.keyMap.Remove(k)
w.customKeyMap.Remove(k)
}
for r := range km.Runes {
w.keyMap.RemoveRune(r)
w.customKeyMap.RemoveRune(r)
}
}
@@ -144,10 +151,12 @@ func (w *Menu) HandleKey(ev *tcell.EventKey) bool {
w.SetActive(false)
}
return true
} else if ok := w.keyMap.Handle(ev); ok {
// Otherwise see if we handle it
}
b1, b2 := w.keyMap.Handle(ev), w.customKeyMap.Handle(ev)
if b1 || b2 {
return true
}
// See if we can find an item that matches the key pressed
for i := range w.items {
if wh.RuneEqualsNC(ev.Rune(), w.items[i].GetHotKey()) {