Skip to content

Conversation

rtuszik
Copy link
Contributor

@rtuszik rtuszik commented Sep 2, 2025

adds j and k as up and down navigation keys in addition to arrow keys as commonly used with tui applications

@Adembc
Copy link
Owner

Adembc commented Sep 2, 2025

Thanks for the PR! 🙌 It looks great.
Just one small tweak, currently the up/down arrow keys wrap around when hitting the first/last server, so j and k should behave the same way.Fix this and I’ll merge it!

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)
		}
	}
}

@rtuszik
Copy link
Contributor Author

rtuszik commented Sep 2, 2025

Good point.
Added!

@Adembc Adembc merged commit c1e3129 into Adembc:main Sep 3, 2025
tan9 pushed a commit to tan9/lazyssh that referenced this pull request Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants