(msg tea.Msg)
| 289 | } |
| 290 | |
| 291 | func (m *agentPickerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 292 | switch msg := msg.(type) { |
| 293 | case tea.WindowSizeMsg: |
| 294 | m.width = msg.Width |
| 295 | m.height = msg.Height |
| 296 | m.clampOffset() |
| 297 | m.resizeDetails() |
| 298 | return m, nil |
| 299 | case tea.KeyPressMsg: |
| 300 | // While the YAML dialog is open it captures all keys: scrolling is |
| 301 | // delegated to the viewport, and any close key dismisses it. |
| 302 | if m.showDetails { |
| 303 | switch { |
| 304 | case key.Matches(msg, agentPickerKeys.Quit), key.Matches(msg, agentPickerKeys.Details): |
| 305 | m.showDetails = false |
| 306 | m.resetClickTracking() |
| 307 | return m, nil |
| 308 | } |
| 309 | var cmd tea.Cmd |
| 310 | m.details, cmd = m.details.Update(msg) |
| 311 | m.syncDetailsBar() |
| 312 | return m, cmd |
| 313 | } |
| 314 | |
| 315 | switch { |
| 316 | case key.Matches(msg, agentPickerKeys.Quit): |
| 317 | m.cancelled = true |
| 318 | return m, tea.Quit |
| 319 | case key.Matches(msg, agentPickerKeys.Up): |
| 320 | m.moveUp() |
| 321 | return m, nil |
| 322 | case key.Matches(msg, agentPickerKeys.Down): |
| 323 | m.moveDown() |
| 324 | return m, nil |
| 325 | case key.Matches(msg, agentPickerKeys.Details): |
| 326 | m.openDetails() |
| 327 | return m, nil |
| 328 | case key.Matches(msg, agentPickerKeys.Lean): |
| 329 | m.leanMode = !m.leanMode |
| 330 | return m, nil |
| 331 | case key.Matches(msg, agentPickerKeys.Choose): |
| 332 | return m, tea.Quit |
| 333 | } |
| 334 | case tea.MouseWheelMsg: |
| 335 | if m.showDetails { |
| 336 | var cmd tea.Cmd |
| 337 | m.details, cmd = m.details.Update(msg) |
| 338 | m.syncDetailsBar() |
| 339 | return m, cmd |
| 340 | } |
| 341 | return m, nil |
| 342 | case tea.MouseMotionMsg: |
| 343 | if !m.showDetails { |
| 344 | if i, ok := m.cardAt(msg.X, msg.Y); ok { |
| 345 | m.cursor = i |
| 346 | } |
| 347 | } |
| 348 | return m, nil |
nothing calls this directly
no test coverage detected