feat(file): Add page up/down key bindings

This commit is contained in:
Leon Stam 2023-01-30 13:57:50 +01:00 committed by Maas Lalani
parent 83db83296a
commit 5431540431

View file

@ -129,6 +129,30 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.min--
m.max--
}
case "J", "pgdown":
m.selected += m.height
if m.selected >= len(m.files) {
m.selected = len(m.files) - 1
}
m.min += m.height
m.max += m.height
if m.max >= len(m.files) {
m.max = len(m.files) - 1
m.min = m.max - m.height
}
case "K", "pgup":
m.selected -= m.height
if m.selected < 0 {
m.selected = 0
}
m.min -= m.height
m.max -= m.height
if m.min < 0 {
m.min = 0
m.max = m.min + m.height
}
case "ctrl+c", "q":
m.path = ""
m.quitting = true