[#1223] lens/tui: fix records view input handling

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-08-06 01:14:31 +03:00
parent b05fb6b767
commit 98215ff06b
No known key found for this signature in database

View file

@ -171,12 +171,12 @@ func (v *RecordsView) selectLastRecord() {
func (v *RecordsView) InputHandler() func(event *tcell.EventKey, _ func(p tview.Primitive)) {
return v.WrapInputHandler(func(event *tcell.EventKey, _ func(p tview.Primitive)) {
switch _, k := event.Modifiers(), event.Key(); {
case k == tcell.KeyLeft:
switch m, k := event.Modifiers(), event.Key(); {
case m == 0 && (k == tcell.KeyLeft || k == tcell.KeyPgUp):
v.moveToPrevPage()
case k == tcell.KeyRight:
case m == 0 && (k == tcell.KeyRight || k == tcell.KeyPgDn):
v.moveToNextPage()
case k == tcell.KeyDown:
case m == 0 && k == tcell.KeyDown:
// Need to move onto the next page.
if v.selectedRecordIndex+1 == v.lastRecordIndex {
v.moveToNextPage()
@ -187,13 +187,13 @@ func (v *RecordsView) InputHandler() func(event *tcell.EventKey, _ func(p tview.
} else {
v.selectedRecordIndex++
}
case k == tcell.KeyUp:
case m == 0 && k == tcell.KeyUp:
v.selectedRecordIndex = max(v.selectedRecordIndex-1, 0)
if v.selectedRecordIndex < v.firstRecordIndex {
v.moveToPrevPage()
v.selectLastRecord()
}
case k == tcell.KeyRune && event.Rune() == 'd':
case m&tcell.ModCtrl != 0 && k == tcell.KeyRight:
current := v.getSelectedItem()
if current != nil {
v.ui.moveNextPage(NewDetailedView(current.Result.DetailedString()))