Reworking Keymaps

This commit is contained in:
2025-10-26 08:47:07 -05:00
parent cf47b5a4e4
commit d63e3a414a
30 changed files with 384 additions and 715 deletions

View File

@@ -40,7 +40,7 @@ type Text struct {
visible bool
active bool
focusable bool
keyMap KeyMap
keyMap *KeyMap
}
var _ Widget = (*Text)(nil)
@@ -62,16 +62,9 @@ func (w *Text) Init(id string, style tcell.Style) {
func (w *Text) Id() string { return w.id }
func (w *Text) HandleResize(ev *tcell.EventResize) { w.w, w.h = ev.Size() }
func (w *Text) SetKeyMap(km KeyMap, def bool) { w.keyMap = km }
func (w *Text) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *Text) RemoveFromKeyMap(km KeyMap) {
for k := range km.Keys {
w.keyMap.Remove(k)
}
for r := range km.Runes {
w.keyMap.RemoveRune(r)
}
}
func (w *Text) GetKeyMap() *KeyMap { return w.keyMap }
func (w *Text) SetKeyMap(km *KeyMap) { w.keyMap = km }
func (w *Text) HandleKey(ev *tcell.EventKey) bool { return w.keyMap.Handle(ev) }
func (w *Text) HandleTime(ev *tcell.EventTime) {}
func (w *Text) Draw(screen tcell.Screen) {