diff --git a/go.mod b/go.mod index 7746b36..2f8c1cc 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.13 require ( github.com/alecthomas/chroma v0.8.0 // indirect - github.com/charmbracelet/bubbles v0.7.1 - github.com/charmbracelet/bubbletea v0.12.1 + github.com/charmbracelet/bubbles v0.7.5 + github.com/charmbracelet/bubbletea v0.12.2 github.com/charmbracelet/charm v0.8.2 github.com/charmbracelet/glamour v0.2.1-0.20200829234023-6c0e29c4dae5 github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac diff --git a/go.sum b/go.sum index 932681c..eb18c1b 100644 --- a/go.sum +++ b/go.sum @@ -43,12 +43,12 @@ github.com/calmh/randomart v1.1.0 h1:evl+iwc10LXtHdMZhzLxmsCQVmWnkXs44SbC6Uk0Il8 github.com/calmh/randomart v1.1.0/go.mod h1:DQUbPVyP+7PAs21w/AnfMKG5NioxS3TbZ2F9MSK/jFM= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/charmbracelet/bubbles v0.6.0/go.mod h1:MxySU+YRGbAhZQJavZlW2os+fIeOW69MI3iXqA+2/WA= -github.com/charmbracelet/bubbles v0.7.1 h1:qvXoIh7ItTA+IA+IO2xxuI9ntp+uVprDAK+IoMzC5OI= -github.com/charmbracelet/bubbles v0.7.1/go.mod h1:UV3dot0XR45cnQX2d8gtohfUFMepquRG2WE56LPKWNc= +github.com/charmbracelet/bubbles v0.7.5 h1:N6TiahuRt2iGNE5gYxKBQ5/C6Lc8xxSp5LY9QJ09mS4= +github.com/charmbracelet/bubbles v0.7.5/go.mod h1:IRTORFvhEI6OUH7WhN2Ks8Z8miNGimk1BE6cmHijOkM= github.com/charmbracelet/bubbletea v0.10.3/go.mod h1:fB1bVmlaXBYYv4G0jtuGSP/m8V2sMM97pq7QqQnubWI= github.com/charmbracelet/bubbletea v0.10.5/go.mod h1:Nay5oWkkSZvc6E/be+W3nDFXAsVytNUNKV9jbXcuae0= -github.com/charmbracelet/bubbletea v0.12.1 h1:t21pkG2IDBRduPbt2J64Dx5yt8yIidAkXwhhrc11SzY= -github.com/charmbracelet/bubbletea v0.12.1/go.mod h1:3gZkYELUOiEUOp0bTInkxguucy/xRbGSOcbMs1geLxg= +github.com/charmbracelet/bubbletea v0.12.2 h1:y9Yo2Pv8tcm3mAJsWONGsmHhzrbNxJVxpVtemikxE9A= +github.com/charmbracelet/bubbletea v0.12.2/go.mod h1:3gZkYELUOiEUOp0bTInkxguucy/xRbGSOcbMs1geLxg= github.com/charmbracelet/charm v0.8.2 h1:sYJhP7YopJUvjWE8VKlNrcAHAaRZsEgKn8z2FoIhHOI= github.com/charmbracelet/charm v0.8.2/go.mod h1:xi3evUxj8hw+dMApaXRczb2SiEzrn8a3NYobj0off+c= github.com/charmbracelet/glamour v0.2.1-0.20200829234023-6c0e29c4dae5 h1:XgXVfMdJTNTq/ajMvwiB1OW3Tg/TXHtM3tYr/vYF76w= diff --git a/ui/pager.go b/ui/pager.go index 8e88528..0141b1c 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -244,7 +244,7 @@ func (m pagerModel) Update(msg tea.Msg) (pagerModel, tea.Cmd) { m.textInput.CursorEnd() } - return m, textinput.Blink(m.textInput) + return m, textinput.Blink case "s": if m.authStatus != authOK { break @@ -257,7 +257,7 @@ func (m pagerModel) Update(msg tea.Msg) (pagerModel, tea.Cmd) { cmds = append( cmds, stashDocument(m.cc, m.currentDocument), - spinner.Tick(m.spinner), + spinner.Tick, ) } case "?": @@ -270,7 +270,7 @@ func (m pagerModel) Update(msg tea.Msg) (pagerModel, tea.Cmd) { case spinner.TickMsg: if m.state == pagerStateStashing || m.spinner.Visible() { - newSpinnerModel, cmd := spinner.Update(msg, m.spinner) + newSpinnerModel, cmd := m.spinner.Update(msg) m.spinner = newSpinnerModel cmds = append(cmds, cmd) } else if m.state == pagerStateStashSuccess && !m.spinner.Visible() { @@ -319,10 +319,10 @@ func (m pagerModel) Update(msg tea.Msg) (pagerModel, tea.Cmd) { switch m.state { case pagerStateSetNote: - m.textInput, cmd = textinput.Update(msg, m.textInput) + m.textInput, cmd = m.textInput.Update(msg) cmds = append(cmds, cmd) default: - m.viewport, cmd = viewport.Update(msg, m.viewport) + m.viewport, cmd = m.viewport.Update(msg) cmds = append(cmds, cmd) } @@ -331,7 +331,7 @@ func (m pagerModel) Update(msg tea.Msg) (pagerModel, tea.Cmd) { func (m pagerModel) View() string { var b strings.Builder - fmt.Fprint(&b, viewport.View(m.viewport)+"\n") + fmt.Fprint(&b, m.viewport.View()+"\n") // Footer switch m.state { @@ -383,7 +383,7 @@ func (m pagerModel) statusBarView(b *strings.Builder) { var statusIndicator string if m.state == pagerStateStashing || m.state == pagerStateStashSuccess { if m.spinner.Visible() { - statusIndicator = statusBarNoteStyle(" ") + spinner.View(m.spinner) + statusIndicator = statusBarNoteStyle(" ") + m.spinner.View() } } else if isStashed && showStatusMessage { statusIndicator = statusBarMessageStashIconStyle(" " + pagerStashIcon) @@ -442,7 +442,7 @@ func (m pagerModel) statusBarView(b *strings.Builder) { func (m pagerModel) setNoteView(b *strings.Builder) { fmt.Fprint(b, noteHeading) - fmt.Fprint(b, textinput.View(m.textInput)) + fmt.Fprint(b, m.textInput.View()) } func (m pagerModel) helpView() (s string) { diff --git a/ui/stash.go b/ui/stash.go index 6cb2825..9b9f79c 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -306,7 +306,7 @@ func (m *stashModel) moveCursorDown() { func newStashModel(cfg *Config, as authStatus) stashModel { sp := spinner.NewModel() - sp.Frames = spinner.Line + sp.Spinner = spinner.Line sp.ForegroundColor = common.SpinnerColor.String() sp.HideFor = time.Millisecond * 50 sp.MinimumLifetime = time.Millisecond * 180 @@ -399,7 +399,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { m.spinner.Visible() if condition { - newSpinnerModel, cmd := spinner.Update(msg, m.spinner) + newSpinnerModel, cmd := m.spinner.Update(msg) m.spinner = newSpinnerModel cmds = append(cmds, cmd) } @@ -484,7 +484,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { cmds = append(cmds, loadRemoteMarkdown(m.cc, md.ID, md.markdownType)) } - cmds = append(cmds, spinner.Tick(m.spinner)) + cmds = append(cmds, spinner.Tick) // Search through your notes case "/": @@ -495,7 +495,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { m.state = stashStateSearchNotes m.searchInput.CursorEnd() m.searchInput.Focus() - return m, textinput.Blink(m.searchInput) + return m, textinput.Blink // Set note case "m": @@ -514,7 +514,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { m.state = stashStateSettingNote m.noteInput.SetValue(md.Note) m.noteInput.CursorEnd() - return m, textinput.Blink(m.noteInput) + return m, textinput.Blink } // Stash @@ -546,7 +546,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { if m.loadingDone() && !m.spinner.Visible() { m.spinner.Start() - cmds = append(cmds, spinner.Tick(m.spinner)) + cmds = append(cmds, spinner.Tick) } // Prompt for deletion @@ -577,19 +577,17 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { // Update paginator. Pagination key handling is done here, but it could // also be moved up to this level, in which case we'd use model methods // like model.PageUp(). - newPaginatorModel, cmd := paginator.Update(msg, m.paginator) + newPaginatorModel, cmd := m.paginator.Update(msg) m.paginator = newPaginatorModel cmds = append(cmds, cmd) // Extra paginator keystrokes if key, ok := msg.(tea.KeyMsg); ok { - if key.Type == tea.KeyRune { - switch key.Rune { - case 'b', 'u': - m.paginator.PrevPage() - case 'f', 'd': - m.paginator.NextPage() - } + switch key.String() { + case "b", "u": + m.paginator.PrevPage() + case "f", "d": + m.paginator.NextPage() } } @@ -699,7 +697,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { } // Update the search text input component - newSearchInputModel, cmd := textinput.Update(msg, m.searchInput) + newSearchInputModel, cmd := m.searchInput.Update(msg) m.searchInput = newSearchInputModel cmds = append(cmds, cmd) @@ -732,7 +730,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { } // Update the note text input component - newNoteInputModel, cmd := textinput.Update(msg, m.noteInput) + newNoteInputModel, cmd := m.noteInput.Update(msg) m.noteInput = newNoteInputModel cmds = append(cmds, cmd) @@ -756,12 +754,12 @@ func stashView(m stashModel) string { case stashStateShowingError: return errorView(m.err, false) case stashStateLoadingDocument: - s += " " + spinner.View(m.spinner) + " Loading document..." + s += " " + m.spinner.View() + " Loading document..." case stashStateReady, stashStateSettingNote, stashStatePromptDelete, stashStateSearchNotes, stashStateShowFiltered: loadingIndicator := " " if !m.localOnly() && (!m.loadingDone() || m.loadingFromNetwork || m.spinner.Visible()) { - loadingIndicator = spinner.View(m.spinner) + loadingIndicator = m.spinner.View() } // We need to fill any empty height with newlines so the footer reaches @@ -794,18 +792,18 @@ func stashView(m stashModel) string { // If we're filtering we replace the logo with the search field if m.state == stashStateSearchNotes || m.state == stashStateShowFiltered { - logoOrSearch = textinput.View(m.searchInput) + logoOrSearch = m.searchInput.View() } var pagination string if m.paginator.TotalPages > 1 { - pagination = paginator.View(m.paginator) + pagination = m.paginator.View() // If the dot pagination is wider than the width of the window // switch to the arabic paginator. if ansi.PrintableRuneWidth(pagination) > m.terminalWidth-stashViewHorizontalPadding { m.paginator.Type = paginator.Arabic - pagination = common.Subtle(paginator.View(m.paginator)) + pagination = common.Subtle(m.paginator.View()) } // We could also look at m.stashFullyLoaded and add an indicator diff --git a/ui/stashitem.go b/ui/stashitem.go index 80dfb28..f211756 100644 --- a/ui/stashitem.go +++ b/ui/stashitem.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/charmbracelet/bubbles/textinput" rw "github.com/mattn/go-runewidth" ) @@ -61,7 +60,7 @@ func stashItemView(b *strings.Builder, m stashModel, index int, md *markdown) { case stashStateSettingNote: gutter = dullYellowFg(verticalLine) icon = "" - title = textinput.View(m.noteInput) + title = m.noteInput.View() date = dullYellowFg(date) default: gutter = dullFuchsiaFg(verticalLine) diff --git a/ui/ui.go b/ui/ui.go index 2908e2c..826e024 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -171,7 +171,7 @@ func (m *model) unloadDocument() []tea.Cmd { } if !m.stash.loadingDone() || m.stash.loadingFromNetwork { - batch = append(batch, spinner.Tick(m.stash.spinner)) + batch = append(batch, spinner.Tick) } return batch } @@ -213,7 +213,7 @@ func (m model) Init() tea.Cmd { if m.cfg.DocumentTypes&StashedDocuments != 0 || m.cfg.DocumentTypes&NewsDocuments != 0 { cmds = append(cmds, newCharmClient, - spinner.Tick(m.stash.spinner), + spinner.Tick, ) }