SetApp sets the parent app reference for focus management.
(app *App)
| 48 | |
| 49 | // SetApp sets the parent app reference for focus management. |
| 50 | func (vl *VMList) SetApp(app *App) { |
| 51 | vl.app = app |
| 52 | |
| 53 | // Set up input capture for arrow keys and VI-like navigation (hjkl) |
| 54 | navigationCapture := createNavigationInputCapture(vl.app, nil, vl.app.vmDetails) |
| 55 | var pendingG bool |
| 56 | vl.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 57 | if handleVimTopBottomRune(event, &pendingG, func() { |
| 58 | jumpListTop(vl.List) |
| 59 | }, func() { |
| 60 | jumpListBottom(vl.List) |
| 61 | }) { |
| 62 | return nil |
| 63 | } |
| 64 | if event.Key() == tcell.KeyRune && event.Rune() == ' ' { |
| 65 | if vm := vl.GetSelectedVM(); vm != nil && vl.app != nil { |
| 66 | vl.app.toggleGuestSelection(vm) |
| 67 | vl.SetVMs(vl.vms) |
| 68 | } |
| 69 | |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | return navigationCapture(event) |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | // SetVMs updates the list with the provided VMs. |
| 78 | func (vl *VMList) SetVMs(vms []*api.VM) { |
nothing calls this directly
no test coverage detected