mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-19 06:34:18 +02:00
Migrate from Boba to Bubble Tea and Bubbles
This commit is contained in:
parent
21b1a2822f
commit
77ba75d680
6 changed files with 78 additions and 81 deletions
10
go.mod
10
go.mod
|
|
@ -4,17 +4,15 @@ go 1.13
|
|||
|
||||
require (
|
||||
github.com/charmbracelet/boba v0.6.3
|
||||
github.com/charmbracelet/charm v0.5.0
|
||||
github.com/charmbracelet/bubbles v0.0.0-20200526000837-87c7cd778f80
|
||||
github.com/charmbracelet/bubbletea v0.7.0
|
||||
github.com/charmbracelet/charm v0.5.1
|
||||
github.com/charmbracelet/glamour v0.2.0
|
||||
github.com/charmbracelet/tea v0.3.0
|
||||
github.com/charmbracelet/teaparty v0.0.0-20200504225426-da64445a0e0d
|
||||
github.com/dlclark/regexp2 v1.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
|
||||
github.com/muesli/reflow v0.1.0
|
||||
github.com/muesli/termenv v0.6.0
|
||||
github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 // indirect
|
||||
github.com/spf13/cobra v0.0.7
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121
|
||||
)
|
||||
|
|
|
|||
21
go.sum
21
go.sum
|
|
@ -15,16 +15,17 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
|
|||
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/boba v0.6.1/go.mod h1:xqhji08CbPctzbvCi/GzmNvIFOhnWJnkl9N8T65gnK0=
|
||||
github.com/charmbracelet/boba v0.6.3 h1:3YisdYQ35tieYXbfpf8acdVN6d1DJHGKZc5kDJNkjg0=
|
||||
github.com/charmbracelet/boba v0.6.3/go.mod h1:9TUvThAOqjXWYZGOrZ4qyluTrmodxb8SqNR81BJluOU=
|
||||
github.com/charmbracelet/charm v0.5.0 h1:4GUkDyDOMgzGaTjSB97uyvH5rfxQeDTLPTr9xpKojsQ=
|
||||
github.com/charmbracelet/charm v0.5.0/go.mod h1:xZgRIZCddA0IAmbsR4zk4HHCj4Z1PLvQcqcZqtk0Pzo=
|
||||
github.com/charmbracelet/bubbles v0.0.0-20200526000837-87c7cd778f80 h1:cfaoL1+tHPABTLEAg831PIFG96teW69Wamz9M025r5M=
|
||||
github.com/charmbracelet/bubbles v0.0.0-20200526000837-87c7cd778f80/go.mod h1:/AeLRFlL2Uf4X7U5LjnswTII6u4maPzMm1+vZfeUJKc=
|
||||
github.com/charmbracelet/bubbletea v0.6.4-0.20200525234836-3b8b011b5a26/go.mod h1:BTzHOUvUlKecQz7ZB8NgPRWi2Z8NRCV04qwyFOfO1Kk=
|
||||
github.com/charmbracelet/bubbletea v0.7.0 h1:nf0FEQCCc1e0qRGgpnz08QFsy25eDitzVwxV+Z/p4UI=
|
||||
github.com/charmbracelet/bubbletea v0.7.0/go.mod h1:BTzHOUvUlKecQz7ZB8NgPRWi2Z8NRCV04qwyFOfO1Kk=
|
||||
github.com/charmbracelet/charm v0.5.1 h1:2r6QYeIepEk+wmCXSN4TlotwTF5twlWm87AMGXLahnk=
|
||||
github.com/charmbracelet/charm v0.5.1/go.mod h1:XBsJjir4zSEMSbbI42JSuyTYQAOcg43bsxe+GUoQHUo=
|
||||
github.com/charmbracelet/glamour v0.2.0 h1:mTgaiNiumpqTZp3qVM6DH9UB0NlbY17wejoMf1kM8Pg=
|
||||
github.com/charmbracelet/glamour v0.2.0/go.mod h1:UA27Kwj3QHialP74iU6C+Gpc8Y7IOAKupeKMLLBURWM=
|
||||
github.com/charmbracelet/tea v0.2.0/go.mod h1:lADjwO2mMub9qvXSCA9vAkabVWO0HeUrv4uO/lG3C+k=
|
||||
github.com/charmbracelet/tea v0.3.0/go.mod h1:uA/DUzCuyIZ1NFyAdCz6k+gF8lspujo6ZvoavcSsLCM=
|
||||
github.com/charmbracelet/teaparty v0.0.0-20200504225426-da64445a0e0d/go.mod h1:PsGcwPVbwjZv3XGW7qGoJ+EkhKqk2owMVUuX3IBUsTw=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
|
|
@ -94,8 +95,8 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
|
|||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/muesli/reflow v0.1.0 h1:oQdpLfO56lr5pgLvqD0TcjW85rDjSYSBVdiG1Ch1ddM=
|
||||
github.com/muesli/reflow v0.1.0/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
github.com/muesli/termenv v0.5.0/go.mod h1:O1/I6sw+6KcrgAmcs6uiUVr7Lui+DNVbHTzt9Lm/PlI=
|
||||
github.com/muesli/termenv v0.5.2/go.mod h1:O1/I6sw+6KcrgAmcs6uiUVr7Lui+DNVbHTzt9Lm/PlI=
|
||||
github.com/muesli/termenv v0.5.3-0.20200526053627-d728968dcf83/go.mod h1:O1/I6sw+6KcrgAmcs6uiUVr7Lui+DNVbHTzt9Lm/PlI=
|
||||
github.com/muesli/termenv v0.6.0 h1:zxvzTBmo4ZcxhNGGWeMz+Tttm51eF5bmPjfy4MCRYlk=
|
||||
github.com/muesli/termenv v0.6.0/go.mod h1:SohX91w6swWA4AYU+QmPx+aSgXhWO0juiyID9UZmbpA=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
|
|
@ -106,7 +107,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
|
|||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
|
||||
github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 h1:pd4YKIqCB0U7O2I4gWHgEUA2mCEOENmco0l/bM957bU=
|
||||
github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03/go.mod h1:Z9+Ul5bCbBKnbCvdOWbLqTHhJiYV414CURZJba6L8qA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
|
|
@ -176,11 +176,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200430202703-d923437fa56d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
|
|
|||
30
ui/pager.go
30
ui/pager.go
|
|
@ -7,9 +7,9 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/boba"
|
||||
"github.com/charmbracelet/boba/textinput"
|
||||
"github.com/charmbracelet/boba/viewport"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
"github.com/charmbracelet/bubbles/viewport"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/charm"
|
||||
"github.com/charmbracelet/charm/ui/common"
|
||||
"github.com/charmbracelet/glamour"
|
||||
|
|
@ -105,15 +105,15 @@ func (m *pagerModel) unload() {
|
|||
|
||||
// UPDATE
|
||||
|
||||
func pagerUpdate(msg boba.Msg, m pagerModel) (pagerModel, boba.Cmd) {
|
||||
func pagerUpdate(msg tea.Msg, m pagerModel) (pagerModel, tea.Cmd) {
|
||||
var (
|
||||
cmd boba.Cmd
|
||||
cmds []boba.Cmd
|
||||
cmd tea.Cmd
|
||||
cmds []tea.Cmd
|
||||
)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
|
||||
case boba.KeyMsg:
|
||||
case tea.KeyMsg:
|
||||
switch m.state {
|
||||
case pagerStateSetNote:
|
||||
switch msg.String() {
|
||||
|
|
@ -123,7 +123,7 @@ func pagerUpdate(msg boba.Msg, m pagerModel) (pagerModel, boba.Cmd) {
|
|||
m.state = pagerStateBrowse
|
||||
return m, nil
|
||||
case "enter":
|
||||
var cmd boba.Cmd
|
||||
var cmd tea.Cmd
|
||||
if m.textInput.Value() != m.currentDocument.Note { // don't update if the note didn't change
|
||||
m.currentDocument.Note = m.textInput.Value() // update optimistically
|
||||
cmd = saveDocumentNote(m.cc, m.currentDocument.ID, m.currentDocument.Note)
|
||||
|
|
@ -170,7 +170,7 @@ func pagerUpdate(msg boba.Msg, m pagerModel) (pagerModel, boba.Cmd) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
var cmd boba.Cmd
|
||||
var cmd tea.Cmd
|
||||
if m.currentDocument != nil {
|
||||
cmd = renderWithGlamour(m, m.currentDocument.Body)
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ func pagerUpdate(msg boba.Msg, m pagerModel) (pagerModel, boba.Cmd) {
|
|||
cmds = append(cmds, cmd)
|
||||
}
|
||||
|
||||
return m, boba.Batch(cmds...)
|
||||
return m, tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
// VIEW
|
||||
|
|
@ -243,8 +243,8 @@ func pagerSetNoteView(m pagerModel) string {
|
|||
|
||||
// CMD
|
||||
|
||||
func renderWithGlamour(m pagerModel, md string) boba.Cmd {
|
||||
return func() boba.Msg {
|
||||
func renderWithGlamour(m pagerModel, md string) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
s, err := glamourRender(m, md)
|
||||
if err != nil {
|
||||
return errMsg(err)
|
||||
|
|
@ -253,13 +253,13 @@ func renderWithGlamour(m pagerModel, md string) boba.Cmd {
|
|||
}
|
||||
}
|
||||
|
||||
func saveDocumentNote(cc *charm.Client, id int, note string) boba.Cmd {
|
||||
func saveDocumentNote(cc *charm.Client, id int, note string) tea.Cmd {
|
||||
if cc == nil {
|
||||
return func() boba.Msg {
|
||||
return func() tea.Msg {
|
||||
return errMsg(errors.New("can't set note; no charm client"))
|
||||
}
|
||||
}
|
||||
return func() boba.Msg {
|
||||
return func() tea.Msg {
|
||||
if err := cc.SetMarkdownNote(id, note); err != nil {
|
||||
return errMsg(err)
|
||||
}
|
||||
|
|
|
|||
44
ui/stash.go
44
ui/stash.go
|
|
@ -7,10 +7,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/boba"
|
||||
"github.com/charmbracelet/boba/paginator"
|
||||
"github.com/charmbracelet/boba/spinner"
|
||||
"github.com/charmbracelet/boba/textinput"
|
||||
"github.com/charmbracelet/bubbles/paginator"
|
||||
"github.com/charmbracelet/bubbles/spinner"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/charm"
|
||||
"github.com/charmbracelet/charm/ui/common"
|
||||
"github.com/dustin/go-humanize"
|
||||
|
|
@ -145,11 +145,11 @@ func (m *stashModel) addMarkdowns(mds ...*markdown) {
|
|||
|
||||
// INIT
|
||||
|
||||
func stashInit(cc *charm.Client) (stashModel, boba.Cmd) {
|
||||
func stashInit(cc *charm.Client) (stashModel, tea.Cmd) {
|
||||
s := spinner.NewModel()
|
||||
s.Type = spinner.Dot
|
||||
s.ForegroundColor = common.SpinnerColor
|
||||
s.CustomMsgFunc = func() boba.Msg { return stashSpinnerTickMsg{} }
|
||||
s.CustomMsgFunc = func() tea.Msg { return stashSpinnerTickMsg{} }
|
||||
|
||||
p := paginator.NewModel()
|
||||
p.Type = paginator.Dots
|
||||
|
|
@ -169,7 +169,7 @@ func stashInit(cc *charm.Client) (stashModel, boba.Cmd) {
|
|||
paginator: p,
|
||||
}
|
||||
|
||||
return m, boba.Batch(
|
||||
return m, tea.Batch(
|
||||
loadStash(m),
|
||||
loadNews(m),
|
||||
spinner.Tick(s),
|
||||
|
|
@ -178,10 +178,10 @@ func stashInit(cc *charm.Client) (stashModel, boba.Cmd) {
|
|||
|
||||
// UPDATE
|
||||
|
||||
func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
||||
func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
|
||||
var (
|
||||
cmd boba.Cmd
|
||||
cmds []boba.Cmd
|
||||
cmd tea.Cmd
|
||||
cmds []tea.Cmd
|
||||
)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
|
|
@ -233,7 +233,7 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
|
||||
switch m.state {
|
||||
case stashStateReady:
|
||||
if msg, ok := msg.(boba.KeyMsg); ok {
|
||||
if msg, ok := msg.(tea.KeyMsg); ok {
|
||||
switch msg.String() {
|
||||
|
||||
case "k":
|
||||
|
|
@ -320,7 +320,7 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
}
|
||||
|
||||
case stashStatePromptDelete:
|
||||
if msg, ok := msg.(boba.KeyMsg); ok {
|
||||
if msg, ok := msg.(tea.KeyMsg); ok {
|
||||
switch msg.String() {
|
||||
|
||||
// Confirm deletion
|
||||
|
|
@ -351,7 +351,7 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
|
||||
case stashStateSettingNote:
|
||||
|
||||
if msg, ok := msg.(boba.KeyMsg); ok {
|
||||
if msg, ok := msg.(tea.KeyMsg); ok {
|
||||
switch msg.String() {
|
||||
case "q":
|
||||
fallthrough
|
||||
|
|
@ -380,7 +380,7 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
// If an item is being confirmed for delete, any key (other than the key
|
||||
// used for confirmation above) cancels the deletion
|
||||
|
||||
return m, boba.Batch(cmds...)
|
||||
return m, tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
// VIEW
|
||||
|
|
@ -508,8 +508,8 @@ func stashHelpView(m stashModel) string {
|
|||
|
||||
// CMD
|
||||
|
||||
func loadStash(m stashModel) boba.Cmd {
|
||||
return func() boba.Msg {
|
||||
func loadStash(m stashModel) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
stash, err := m.cc.GetStash(m.page)
|
||||
if err != nil {
|
||||
return errMsg(err)
|
||||
|
|
@ -518,8 +518,8 @@ func loadStash(m stashModel) boba.Cmd {
|
|||
}
|
||||
}
|
||||
|
||||
func loadNews(m stashModel) boba.Cmd {
|
||||
return func() boba.Msg {
|
||||
func loadNews(m stashModel) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
news, err := m.cc.GetNews(1) // just fetch the first page
|
||||
if err != nil {
|
||||
return errMsg(err)
|
||||
|
|
@ -528,8 +528,8 @@ func loadNews(m stashModel) boba.Cmd {
|
|||
}
|
||||
}
|
||||
|
||||
func loadMarkdown(cc *charm.Client, id int, t markdownType) boba.Cmd {
|
||||
return func() boba.Msg {
|
||||
func loadMarkdown(cc *charm.Client, id int, t markdownType) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
var (
|
||||
md *charm.Markdown
|
||||
err error
|
||||
|
|
@ -549,8 +549,8 @@ func loadMarkdown(cc *charm.Client, id int, t markdownType) boba.Cmd {
|
|||
}
|
||||
}
|
||||
|
||||
func deleteStashedItem(cc *charm.Client, id int) boba.Cmd {
|
||||
return func() boba.Msg {
|
||||
func deleteStashedItem(cc *charm.Client, id int) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
err := cc.DeleteMarkdown(id)
|
||||
if err != nil {
|
||||
return errMsg(err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/boba/textinput"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
"github.com/charmbracelet/charm/ui/common"
|
||||
te "github.com/muesli/termenv"
|
||||
)
|
||||
|
|
|
|||
52
ui/ui.go
52
ui/ui.go
|
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/charmbracelet/boba"
|
||||
"github.com/charmbracelet/boba/spinner"
|
||||
"github.com/charmbracelet/bubbles/spinner"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/charm"
|
||||
"github.com/charmbracelet/charm/ui/common"
|
||||
"github.com/charmbracelet/charm/ui/keygen"
|
||||
|
|
@ -21,9 +21,9 @@ var (
|
|||
glowLogoTextColor = common.Color("#ECFD65")
|
||||
)
|
||||
|
||||
// NewProgram returns a new Boba program
|
||||
func NewProgram(style string) *boba.Program {
|
||||
return boba.NewProgram(initialize(style), update, view)
|
||||
// NewProgram returns a new Tea program
|
||||
func NewProgram(style string) *tea.Program {
|
||||
return tea.NewProgram(initialize(style), update, view)
|
||||
}
|
||||
|
||||
// MESSAGES
|
||||
|
|
@ -87,8 +87,8 @@ func (m *model) unloadDocument() {
|
|||
|
||||
// INIT
|
||||
|
||||
func initialize(style string) func() (boba.Model, boba.Cmd) {
|
||||
return func() (boba.Model, boba.Cmd) {
|
||||
func initialize(style string) func() (tea.Model, tea.Cmd) {
|
||||
return func() (tea.Model, tea.Cmd) {
|
||||
s := spinner.NewModel()
|
||||
s.Type = spinner.Dot
|
||||
s.ForegroundColor = common.SpinnerColor
|
||||
|
|
@ -106,7 +106,7 @@ func initialize(style string) func() (boba.Model, boba.Cmd) {
|
|||
spinner: s,
|
||||
pager: newPagerModel(style),
|
||||
state: stateInitCharmClient,
|
||||
}, boba.Batch(
|
||||
}, tea.Batch(
|
||||
newCharmClient,
|
||||
spinner.Tick(s),
|
||||
getTerminalSize(),
|
||||
|
|
@ -117,27 +117,27 @@ func initialize(style string) func() (boba.Model, boba.Cmd) {
|
|||
|
||||
// UPDATE
|
||||
|
||||
func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
|
||||
func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {
|
||||
m, ok := mdl.(model)
|
||||
if !ok {
|
||||
return model{
|
||||
err: errors.New("could not perform assertion on model in update"),
|
||||
}, boba.Quit
|
||||
}, tea.Quit
|
||||
}
|
||||
|
||||
var (
|
||||
cmd boba.Cmd
|
||||
cmds []boba.Cmd
|
||||
cmd tea.Cmd
|
||||
cmds []tea.Cmd
|
||||
)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
|
||||
case boba.KeyMsg:
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "q":
|
||||
fallthrough
|
||||
case "esc":
|
||||
var cmd boba.Cmd
|
||||
var cmd tea.Cmd
|
||||
|
||||
switch m.state {
|
||||
case stateShowStash:
|
||||
|
|
@ -159,10 +159,10 @@ func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
|
|||
return m, cmd
|
||||
}
|
||||
|
||||
return m, boba.Quit
|
||||
return m, tea.Quit
|
||||
|
||||
case "ctrl+c":
|
||||
return m, boba.Quit
|
||||
return m, tea.Quit
|
||||
|
||||
// Repaint
|
||||
case "ctrl+l":
|
||||
|
|
@ -201,7 +201,7 @@ func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
|
|||
} else {
|
||||
// The keygen didn't work and we can't auth
|
||||
m.err = errors.New("SSH authentication failed")
|
||||
return m, boba.Quit
|
||||
return m, tea.Quit
|
||||
}
|
||||
|
||||
case spinner.TickMsg:
|
||||
|
|
@ -243,11 +243,11 @@ func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
|
|||
|
||||
case stateKeygenRunning:
|
||||
// Process keygen
|
||||
mdl, cmd := keygen.Update(msg, boba.Model(m.keygen))
|
||||
mdl, cmd := keygen.Update(msg, tea.Model(m.keygen))
|
||||
keygenModel, ok := mdl.(keygen.Model)
|
||||
if !ok {
|
||||
m.err = errors.New("could not perform assertion on keygen model in main update")
|
||||
return m, boba.Quit
|
||||
return m, tea.Quit
|
||||
}
|
||||
m.keygen = keygenModel
|
||||
cmds = append(cmds, cmd)
|
||||
|
|
@ -263,12 +263,12 @@ func update(msg boba.Msg, mdl boba.Model) (boba.Model, boba.Cmd) {
|
|||
cmds = append(cmds, cmd)
|
||||
}
|
||||
|
||||
return m, boba.Batch(cmds...)
|
||||
return m, tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
// VIEW
|
||||
|
||||
func view(mdl boba.Model) string {
|
||||
func view(mdl tea.Model) string {
|
||||
m, ok := mdl.(model)
|
||||
if !ok {
|
||||
return "could not perform assertion on model in view"
|
||||
|
|
@ -297,19 +297,19 @@ func view(mdl boba.Model) string {
|
|||
|
||||
// COMMANDS
|
||||
|
||||
func listenForTerminalResize() boba.Cmd {
|
||||
return boba.OnResize(func() boba.Msg {
|
||||
func listenForTerminalResize() tea.Cmd {
|
||||
return tea.OnResize(func() tea.Msg {
|
||||
return terminalResizedMsg{}
|
||||
})
|
||||
}
|
||||
|
||||
func getTerminalSize() boba.Cmd {
|
||||
return boba.GetTerminalSize(func(w, h int, err error) boba.TerminalSizeMsg {
|
||||
func getTerminalSize() tea.Cmd {
|
||||
return tea.GetTerminalSize(func(w, h int, err error) tea.TerminalSizeMsg {
|
||||
return terminalSizeMsg{width: w, height: h, err: err}
|
||||
})
|
||||
}
|
||||
|
||||
func newCharmClient() boba.Msg {
|
||||
func newCharmClient() tea.Msg {
|
||||
cfg, err := charm.ConfigFromEnv()
|
||||
if err != nil {
|
||||
return errMsg(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue