setupKeyHandlers configures vi-style navigation.
()
| 342 | |
| 343 | // setupKeyHandlers configures vi-style navigation. |
| 344 | func (tl *TasksList) setupKeyHandlers() { |
| 345 | var historyPendingG bool |
| 346 | var activePendingG bool |
| 347 | |
| 348 | handler := func(event *tcell.EventKey) *tcell.EventKey { |
| 349 | if handleVimTopBottomRune(event, &historyPendingG, func() { |
| 350 | jumpTableTop(tl.historyTable) |
| 351 | }, func() { |
| 352 | jumpTableBottom(tl.historyTable) |
| 353 | }) { |
| 354 | return nil |
| 355 | } |
| 356 | |
| 357 | switch event.Key() { |
| 358 | case tcell.KeyTab: |
| 359 | if tl.showActive { |
| 360 | tl.focusOtherPane() |
| 361 | return nil |
| 362 | } |
| 363 | case tcell.KeyBacktab: |
| 364 | if tl.showActive { |
| 365 | tl.focusOtherPane() |
| 366 | return nil |
| 367 | } |
| 368 | case tcell.KeyRune: |
| 369 | switch event.Rune() { |
| 370 | case 'j': |
| 371 | return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone) |
| 372 | case 'k': |
| 373 | return tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone) |
| 374 | } |
| 375 | } |
| 376 | if keyMatch(event, tl.tasksToggleQueueKeySpec()) { |
| 377 | tl.toggleActiveQueueVisibility() |
| 378 | return nil |
| 379 | } |
| 380 | return event |
| 381 | } |
| 382 | |
| 383 | tl.historyTable.SetInputCapture(handler) |
| 384 | |
| 385 | tl.activeTable.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 386 | if handleVimTopBottomRune(event, &activePendingG, func() { |
| 387 | jumpTableTop(tl.activeTable) |
| 388 | }, func() { |
| 389 | jumpTableBottom(tl.activeTable) |
| 390 | }) { |
| 391 | return nil |
| 392 | } |
| 393 | |
| 394 | if keyMatch(event, tl.tasksToggleQueueKeySpec()) { |
| 395 | tl.toggleActiveQueueVisibility() |
| 396 | return nil |
| 397 | } |
| 398 | if keyMatch(event, tl.taskStopCancelKeySpec()) { |
| 399 | // Stop task |
| 400 | row, _ := tl.activeTable.GetSelection() |
| 401 | if row > 0 { |
no test coverage detected