KeyMap Expansion

This commit is contained in:
2025-07-31 13:31:14 -05:00
parent 174fab2c6d
commit 9e88799391
7 changed files with 111 additions and 54 deletions

View File

@@ -68,7 +68,7 @@ func (w *Searcher) Init(id string, style tcell.Style) {
w.search.SetOnChange(func(prev, curr string) {
w.updateFilter()
})
w.keyMap = NewKeyMap(map[tcell.Key]func() bool{
w.keyMap = NewKeyMap(map[tcell.Key]func(ev *tcell.EventKey) bool{
tcell.KeyUp: w.handleKeyUp,
tcell.KeyDown: w.handleKeyDown,
tcell.KeyHome: w.handleKeyHome,
@@ -90,17 +90,17 @@ func (w *Searcher) HandleKey(ev *tcell.EventKey) bool {
return w.search.HandleKey(ev)
}
func (w *Searcher) handleKeyUp() bool {
func (w *Searcher) handleKeyUp(ev *tcell.EventKey) bool {
w.cursor = ((w.cursor - 1) + len(w.filteredData)) % len(w.filteredData)
return true
}
func (w *Searcher) handleKeyDown() bool {
func (w *Searcher) handleKeyDown(ev *tcell.EventKey) bool {
w.cursor = ((w.cursor + 1) + len(w.filteredData)) % len(w.filteredData)
return true
}
func (w *Searcher) handleKeyHome() bool {
func (w *Searcher) handleKeyHome(ev *tcell.EventKey) bool {
if w.cursor == 0 {
return false
}
@@ -108,7 +108,7 @@ func (w *Searcher) handleKeyHome() bool {
return true
}
func (w *Searcher) handleKeyEnd() bool {
func (w *Searcher) handleKeyEnd(ev *tcell.EventKey) bool {
if w.cursor == len(w.filteredData)-1 {
return false
}
@@ -116,7 +116,7 @@ func (w *Searcher) handleKeyEnd() bool {
return true
}
func (w *Searcher) handleKeyPgUp() bool {
func (w *Searcher) handleKeyPgUp(ev *tcell.EventKey) bool {
if w.cursor == 0 {
return false
}
@@ -128,7 +128,7 @@ func (w *Searcher) handleKeyPgUp() bool {
return false
}
func (w *Searcher) handleKeyPgDn() bool {
func (w *Searcher) handleKeyPgDn(ev *tcell.EventKey) bool {
mx := len(w.filteredData) - 1
if w.cursor == mx {
return false
@@ -140,7 +140,7 @@ func (w *Searcher) handleKeyPgDn() bool {
return false
}
func (w *Searcher) handleKeyEnter() bool {
func (w *Searcher) handleKeyEnter(ev *tcell.EventKey) bool {
if w.hideOnSelect {
w.visible = false
}