From 5d34c88692014112821eaeeb92e9d6e93dbf9af5 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 31 Oct 2020 20:58:24 -0400 Subject: [PATCH] Update examples for Bubbles v0.8.0 --- examples/glamour/main.go | 9 +++++---- examples/pager/main.go | 4 ++-- examples/spinner/main.go | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/glamour/main.go b/examples/glamour/main.go index 5546929..4d95587 100644 --- a/examples/glamour/main.go +++ b/examples/glamour/main.go @@ -89,16 +89,17 @@ func (e example) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "q", "ctrl+c": return e, tea.Quit default: - vp, _ := viewport.Update(msg, e.viewport) + vp, cmd := e.viewport.Update(msg) e.viewport = vp + return e, cmd } + default: + return e, nil } - - return e, nil } func (e example) View() string { - return viewport.View(e.viewport) + e.helpView() + return e.viewport.View() + e.helpView() } func (e example) helpView() string { diff --git a/examples/pager/main.go b/examples/pager/main.go index 9cf5454..ddc8bd3 100644 --- a/examples/pager/main.go +++ b/examples/pager/main.go @@ -126,7 +126,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // * Recieves messages from the Bubble Tea runtime // * Returns commands to the Bubble Tea runtime // - m.viewport, cmd = viewport.Update(msg, m.viewport) + m.viewport, cmd = m.viewport.Update(msg) if useHighPerformanceRenderer { cmds = append(cmds, cmd) } @@ -154,5 +154,5 @@ func (m model) View() string { footerBot = strings.Repeat(" ", gapSize) + footerBot footer := fmt.Sprintf("%s\n%s\n%s", footerTop, footerMid, footerBot) - return fmt.Sprintf("%s\n%s\n%s", header, viewport.View(m.viewport), footer) + return fmt.Sprintf("%s\n%s\n%s", header, m.viewport.View(), footer) } diff --git a/examples/spinner/main.go b/examples/spinner/main.go index 3fe3ef9..3e31db0 100644 --- a/examples/spinner/main.go +++ b/examples/spinner/main.go @@ -37,7 +37,7 @@ func initialModel() model { } func (m model) Init() tea.Cmd { - return spinner.Tick(m.spinner) + return spinner.Tick } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -62,7 +62,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { default: var cmd tea.Cmd - m.spinner, cmd = spinner.Update(msg, m.spinner) + m.spinner, cmd = m.spinner.Update(msg) return m, cmd } @@ -73,7 +73,7 @@ func (m model) View() string { return m.err.Error() } s := termenv. - String(spinner.View(m.spinner)). + String(m.spinner.View()). Foreground(term.Color("205")). String() str := fmt.Sprintf("\n\n %s Loading forever...press q to quit\n\n", s)