feat: add 'j' and 'k' as keybindings for navigation (#9)

This commit is contained in:
Robin Tuszik
2025-09-03 08:22:58 +01:00
committed by GitHub
parent b41eeecbf7
commit c1e31290ac
2 changed files with 45 additions and 16 deletions
+29
View File
@@ -72,6 +72,12 @@ func (t *tui) handleGlobalKeys(event *tcell.EventKey) *tcell.EventKey {
case 't':
t.handleTagsEdit()
return nil
case 'j':
t.handleNavigateDown()
return nil
case 'k':
t.handleNavigateUp()
return nil
}
if event.Key() == tcell.KeyEnter {
@@ -125,6 +131,29 @@ func (t *tui) handleTagsEdit() {
}
}
func (t *tui) handleNavigateDown() {
if t.app.GetFocus() == t.serverList {
currentIdx := t.serverList.GetCurrentItem()
itemCount := t.serverList.GetItemCount()
if currentIdx < itemCount-1 {
t.serverList.SetCurrentItem(currentIdx + 1)
} else {
t.serverList.SetCurrentItem(0)
}
}
}
func (t *tui) handleNavigateUp() {
if t.app.GetFocus() == t.serverList {
currentIdx := t.serverList.GetCurrentItem()
if currentIdx > 0 {
t.serverList.SetCurrentItem(currentIdx - 1)
} else {
t.serverList.SetCurrentItem(t.serverList.GetItemCount() - 1)
}
}
}
func (t *tui) handleSearchInput(query string) {
filtered, _ := t.serverService.ListServers(query)
sortServersForUI(filtered, t.sortMode)