updateDebugFocus is the key handler used while the debug panel is focused. It owns ↑/↓ navigation, Enter to drill in, Esc to back out, and forwards scroll keys to the viewport so PgUp/PgDn still work inside long payloads.
(msg tea.KeyMsg)
| 672 | // It owns ↑/↓ navigation, Enter to drill in, Esc to back out, and forwards |
| 673 | // scroll keys to the viewport so PgUp/PgDn still work inside long payloads. |
| 674 | func (m harness) updateDebugFocus(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
| 675 | switch msg.Type { |
| 676 | case tea.KeyCtrlD, tea.KeyCtrlC: |
| 677 | return m, tea.Quit |
| 678 | |
| 679 | case tea.KeyEsc: |
| 680 | if m.debugMode == debugDetail { |
| 681 | m.debugMode = debugList |
| 682 | m.layout() |
| 683 | m.refreshDebugContent() |
| 684 | return m, nil |
| 685 | } |
| 686 | m.debugFocus = false |
| 687 | m.input.Focus() |
| 688 | m.refreshDebugContent() |
| 689 | return m, nil |
| 690 | |
| 691 | case tea.KeyEnter: |
| 692 | if m.debugMode == debugList && m.debugSelected != 0 { |
| 693 | m.debugMode = debugDetail |
| 694 | m.layout() |
| 695 | m.refreshDebugContent() |
| 696 | } |
| 697 | return m, nil |
| 698 | |
| 699 | case tea.KeyUp: |
| 700 | if m.debugMode == debugList { |
| 701 | m.moveSelection(-1) |
| 702 | m.refreshDebugContent() |
| 703 | return m, nil |
| 704 | } |
| 705 | |
| 706 | case tea.KeyDown: |
| 707 | if m.debugMode == debugList { |
| 708 | m.moveSelection(+1) |
| 709 | m.refreshDebugContent() |
| 710 | return m, nil |
| 711 | } |
| 712 | |
| 713 | case tea.KeyLeft, tea.KeyRight: |
| 714 | // In detail mode, ←/→ jumps to the paired event (request ↔ response) |
| 715 | // so the user can flip between halves of an exchange without backing |
| 716 | // out to the list. In list mode these aren't bound to anything. |
| 717 | if m.debugMode == debugDetail { |
| 718 | if p, ok := debug.Pair(m.debugSelected); ok { |
| 719 | m.debugSelected = p.ID |
| 720 | m.refreshDebugContent() |
| 721 | } |
| 722 | return m, nil |
| 723 | } |
| 724 | |
| 725 | case tea.KeyHome: |
| 726 | if m.debugMode == debugList { |
| 727 | if events := debug.Snapshot(); len(events) > 0 { |
| 728 | m.debugSelected = events[0].ID |
| 729 | m.refreshDebugContent() |
| 730 | } |
| 731 | return m, nil |
no test coverage detected