Much Work

- Definable KeyMaps
- Change 'Tabbable' to just use 'Focusable'
This commit is contained in:
2025-09-04 11:09:34 -05:00
parent c1db729bb3
commit f571b13a31
26 changed files with 881 additions and 615 deletions

View File

@@ -33,11 +33,11 @@ type Searcher struct {
id string
style tcell.Style
x, y int
w, h int
active bool
visible bool
tabbable bool
x, y int
w, h int
active bool
visible bool
focusable bool
title string
search *Field
@@ -79,7 +79,7 @@ func (w *Searcher) Init(id string, style tcell.Style) {
tcell.KeyPgDn: w.handleKeyPgDn,
tcell.KeyEnter: w.handleKeyEnter,
})
w.tabbable = true
w.focusable = true
}
func (w *Searcher) Id() string { return w.id }
@@ -94,6 +94,17 @@ func (w *Searcher) HandleResize(ev *tcell.EventResize) {
w.search.HandleResize(Coord{X: aW, Y: aH}.ResizeEvent())
}
func (w *Searcher) SetKeyMap(km KeyMap) { w.keyMap = km }
func (w *Searcher) AddToKeyMap(km KeyMap) { w.keyMap.Merge(km) }
func (w *Searcher) RemoveFromKeyMap(km KeyMap) {
for k := range km.Keys {
w.keyMap.Remove(k)
}
for r := range km.Runes {
w.keyMap.RemoveRune(r)
}
}
func (w *Searcher) HandleKey(ev *tcell.EventKey) bool {
if !w.active {
return false
@@ -245,16 +256,15 @@ func (w *Searcher) WantH() int {
return ret
}
func (w *Searcher) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Searcher) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Searcher) SetW(x int) { w.w = x }
func (w *Searcher) SetH(y int) { w.h = y }
func (w *Searcher) GetW() int { return w.w }
func (w *Searcher) GetH() int { return w.h }
func (w *Searcher) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Searcher) Focusable() bool { return true }
func (w *Searcher) SetTabbable(b bool) { w.tabbable = b }
func (w *Searcher) Tabbable() bool { return w.tabbable }
func (w *Searcher) GetPos() Coord { return Coord{X: w.x, Y: w.y} }
func (w *Searcher) SetPos(c Coord) { w.x, w.y = c.X, c.Y }
func (w *Searcher) SetW(x int) { w.w = x }
func (w *Searcher) SetH(y int) { w.h = y }
func (w *Searcher) GetW() int { return w.w }
func (w *Searcher) GetH() int { return w.h }
func (w *Searcher) SetSize(c Coord) { w.w, w.h = c.X, c.Y }
func (w *Searcher) Focusable() bool { return w.focusable }
func (w *Searcher) SetFocusable(b bool) { w.focusable = b }
func (w *Searcher) MinW() int {
return 2 + w.search.MinW()
}