MCPcopy
hub / github.com/charmbracelet/glow / update

Method update

ui/stash.go:412–458  ·  view source on GitHub ↗

UPDATE

(msg tea.Msg)

Source from the content-addressed store, hash-verified

410// UPDATE
411
412func (m stashModel) update(msg tea.Msg) (stashModel, tea.Cmd) {
413 var cmds []tea.Cmd
414
415 switch msg := msg.(type) {
416 case errMsg:
417 m.err = msg
418
419 case localFileSearchFinished:
420 // We're finished searching for local files
421 m.loaded = true
422
423 case filteredMarkdownMsg:
424 m.filteredMarkdowns = msg
425 m.setCursor(0)
426 return m, nil
427
428 case spinner.TickMsg:
429 if m.shouldSpin() {
430 var cmd tea.Cmd
431 m.spinner, cmd = m.spinner.Update(msg)
432 cmds = append(cmds, cmd)
433 }
434
435 case statusMessageTimeoutMsg:
436 if applicationContext(msg) == stashContext {
437 m.hideStatusMessage()
438 }
439 }
440
441 if m.filterState == filtering {
442 cmds = append(cmds, m.handleFiltering(msg))
443 return m, tea.Batch(cmds...)
444 }
445
446 // Updates per the current state
447 switch m.viewState { //nolint:exhaustive
448 case stashStateReady:
449 cmds = append(cmds, m.handleDocumentBrowsing(msg))
450 case stashStateShowingError:
451 // Any key exists the error view
452 if _, ok := msg.(tea.KeyMsg); ok {
453 m.viewState = stashStateReady
454 }
455 }
456
457 return m, tea.Batch(cmds...)
458}
459
460// Updates for when a user is browsing the markdown listing.
461func (m *stashModel) handleDocumentBrowsing(msg tea.Msg) tea.Cmd {

Callers 1

UpdateMethod · 0.45

Calls 7

setCursorMethod · 0.95
shouldSpinMethod · 0.95
hideStatusMessageMethod · 0.95
handleFilteringMethod · 0.95
applicationContextTypeAlias · 0.85
UpdateMethod · 0.80

Tested by

no test coverage detected