Skip to content
Myr

Update examples for Bubbles v0.8.0

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 02a0509 · Browse files · 3 files+10 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−9 removed

  • other:+10 added−9 removed

3 files+10 added−9 removed

modified:examples/glamour/main.go+5 added-4 removed
87 unmodified lines
88 switch msg.String() {89 case "q", "ctrl+c":90 return e, tea.Quit91 default:92 vp, _ := viewport.Update(msg, e.viewport)92 vp, cmd := e.viewport.Update(msg)93 e.viewport = vp94 return e, cmd95 }96 default:97 return e, nil98 }9697 return e, nil99}100101func (e example) View() string {101 return viewport.View(e.viewport) + e.helpView()102 return e.viewport.View() + e.helpView()103}104105func (e example) helpView() string {106 return termenv.String("\n ↑/↓: Navigate • q: Quit\n").Foreground(term.Color("241")).String()
14 unmodified lines
modified:examples/pager/main.go+2 added-2 removed
124 unmodified lines
125 //126 // * Recieves messages from the Bubble Tea runtime127 // * Returns commands to the Bubble Tea runtime128 //129 m.viewport, cmd = viewport.Update(msg, m.viewport)129 m.viewport, cmd = m.viewport.Update(msg)130 if useHighPerformanceRenderer {131 cmds = append(cmds, cmd)132 }133
19 unmodified lines
153 footerMid = strings.Repeat("─", gapSize) + footerMid154 footerBot = strings.Repeat(" ", gapSize) + footerBot155 footer := fmt.Sprintf("%s\n%s\n%s", footerTop, footerMid, footerBot)156157 return fmt.Sprintf("%s\n%s\n%s", header, viewport.View(m.viewport), footer)157 return fmt.Sprintf("%s\n%s\n%s", header, m.viewport.View(), footer)158}
modified:examples/spinner/main.go+3 added-3 removed
35 unmodified lines
36 return model{spinner: s}37}3839func (m model) Init() tea.Cmd {40 return spinner.Tick(m.spinner)40 return spinner.Tick41}4243func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {44 switch msg := msg.(type) {
16 unmodified lines
61 return m, nil6263 default:64 var cmd tea.Cmd65 m.spinner, cmd = spinner.Update(msg, m.spinner)65 m.spinner, cmd = m.spinner.Update(msg)66 return m, cmd67 }6869}
2 unmodified lines
72 if m.err != nil {73 return m.err.Error()74 }75 s := termenv.76 String(spinner.View(m.spinner)).76 String(m.spinner.View()).77 Foreground(term.Color("205")).78 String()79 str := fmt.Sprintf("\n\n %s Loading forever...press q to quit\n\n", s)80 if m.quitting {
4 unmodified lines