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

@@ -51,7 +51,7 @@ type Chat struct {
history []ChatMsg
historyPosition int
keyMap KeyMap
keyMap, customKeyMap KeyMap
}
var _ Widget = (*Chat)(nil)
@@ -74,14 +74,24 @@ func (w *Chat) HandleResize(ev *tcell.EventResize) {
w.w, w.h = ev.Size()
}
func (w *Chat) SetKeyMap(km KeyMap) { w.keyMap = km }
func (w *Chat) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *Chat) SetKeyMap(km KeyMap, def bool) {
if def {
w.keyMap = km
} else {
w.customKeyMap = km
}
}
func (w *Chat) AddToKeyMap(km KeyMap) {
w.customKeyMap.Merge(km)
}
func (w *Chat) 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)
}
}
@@ -101,7 +111,9 @@ func (w *Chat) HandleKey(ev *tcell.EventKey) bool {
w.value = w.value[:w.cursor] + w.value[w.cursor+1:]
}
}
if ok := w.keyMap.Handle(ev); ok {
b1 := w.keyMap.Handle(ev)
b2 := w.customKeyMap.Handle(ev)
if b1 || b2 {
return true
}
@@ -245,6 +257,7 @@ func (w *Chat) initKeyMap() {
return false
},
})
w.customKeyMap = BlankKeyMap()
}
func (w *Chat) SetTitle(ttl string) { w.title = ttl }
func (w *Chat) Title() string { return w.title }