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:
@@ -138,22 +138,22 @@ make run
|
||||
|
||||
## ⌨️ Key Bindings
|
||||
|
||||
| Key | Action |
|
||||
|---|---|
|
||||
| / | Toggle search bar |
|
||||
| ↑/↓ | Navigate servers |
|
||||
| Enter | SSH into selected server |
|
||||
| c | Copy SSH command to clipboard |
|
||||
| g | Ping selected server |
|
||||
| r | Refresh background data |
|
||||
| a | Add server |
|
||||
| e | Edit server |
|
||||
| t | Edit tags |
|
||||
| d | Delete server |
|
||||
| p | Pin/Unpin server |
|
||||
| s | Toggle sort field |
|
||||
| S | Reverse sort order |
|
||||
| q | Quit |
|
||||
| Key | Action |
|
||||
| ----- | ----------------------------- |
|
||||
| / | Toggle search bar |
|
||||
| ↑↓/jk | Navigate servers |
|
||||
| Enter | SSH into selected server |
|
||||
| c | Copy SSH command to clipboard |
|
||||
| g | Ping selected server |
|
||||
| r | Refresh background data |
|
||||
| a | Add server |
|
||||
| e | Edit server |
|
||||
| t | Edit tags |
|
||||
| d | Delete server |
|
||||
| p | Pin/Unpin server |
|
||||
| s | Toggle sort field |
|
||||
| S | Reverse sort order |
|
||||
| q | Quit |
|
||||
|
||||
Tip: The hint bar at the top of the list shows the most useful shortcuts.
|
||||
|
||||
|
||||
@@ -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