MCPcopy Create free account
hub / github.com/docker/docker-agent / Update

Method Update

cmd/root/agent_picker.go:291–353  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

289}
290
291func (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

Callers

nothing calls this directly

Calls 10

clampOffsetMethod · 0.95
resizeDetailsMethod · 0.95
resetClickTrackingMethod · 0.95
syncDetailsBarMethod · 0.95
moveUpMethod · 0.95
moveDownMethod · 0.95
openDetailsMethod · 0.95
cardAtMethod · 0.95
handleMouseClickMethod · 0.95
UpdateMethod · 0.65

Tested by

no test coverage detected