mirror of
https://github.com/Adembc/lazyssh.git
synced 2026-07-14 12:13:34 +02:00
feat: add 'j' and 'k' as keybindings for navigation (#9)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user