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:
@@ -139,9 +139,9 @@ make run
|
|||||||
## ⌨️ Key Bindings
|
## ⌨️ Key Bindings
|
||||||
|
|
||||||
| Key | Action |
|
| Key | Action |
|
||||||
|---|---|
|
| ----- | ----------------------------- |
|
||||||
| / | Toggle search bar |
|
| / | Toggle search bar |
|
||||||
| ↑/↓ | Navigate servers |
|
| ↑↓/jk | Navigate servers |
|
||||||
| Enter | SSH into selected server |
|
| Enter | SSH into selected server |
|
||||||
| c | Copy SSH command to clipboard |
|
| c | Copy SSH command to clipboard |
|
||||||
| g | Ping selected server |
|
| g | Ping selected server |
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ func (t *tui) handleGlobalKeys(event *tcell.EventKey) *tcell.EventKey {
|
|||||||
case 't':
|
case 't':
|
||||||
t.handleTagsEdit()
|
t.handleTagsEdit()
|
||||||
return nil
|
return nil
|
||||||
|
case 'j':
|
||||||
|
t.handleNavigateDown()
|
||||||
|
return nil
|
||||||
|
case 'k':
|
||||||
|
t.handleNavigateUp()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.Key() == tcell.KeyEnter {
|
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) {
|
func (t *tui) handleSearchInput(query string) {
|
||||||
filtered, _ := t.serverService.ListServers(query)
|
filtered, _ := t.serverService.ListServers(query)
|
||||||
sortServersForUI(filtered, t.sortMode)
|
sortServersForUI(filtered, t.sortMode)
|
||||||
|
|||||||
Reference in New Issue
Block a user