Skip to content

Commit a93bfef

Browse files
committed
feat!: use bubbletea@v2-exp
1 parent d3bd075 commit a93bfef

File tree

14 files changed

+47
-35
lines changed

14 files changed

+47
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var DefaultKeyMap = KeyMap{
185185

186186
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
187187
switch msg := msg.(type) {
188-
case tea.KeyMsg:
188+
case tea.KeyPressMsg:
189189
switch {
190190
case key.Matches(msg, DefaultKeyMap.Up):
191191
// The user pressed up

filepicker/filepicker.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
254254
m.Height = msg.Height - marginBottom
255255
}
256256
m.max = m.Height - 1
257-
case tea.KeyMsg:
257+
case tea.KeyPressMsg:
258258
switch {
259259
case key.Matches(msg, m.KeyMap.GoToTop):
260260
m.selected = 0
@@ -463,7 +463,7 @@ func (m Model) didSelectFile(msg tea.Msg) (bool, string) {
463463
return false, ""
464464
}
465465
switch msg := msg.(type) {
466-
case tea.KeyMsg:
466+
case tea.KeyPressMsg:
467467
// If the msg does not match the Select keymap then this could not have been a selection.
468468
if !key.Matches(msg, m.KeyMap.Select) {
469469
return false, ""
@@ -494,8 +494,8 @@ func (m Model) didSelectFile(msg tea.Msg) (bool, string) {
494494
return true, m.Path
495495
}
496496

497-
// If the msg was not a KeyMsg, then the file could not have been selected this iteration.
498-
// Only a KeyMsg can select a file.
497+
// If the msg was not a KeyPressMsg, then the file could not have been selected this iteration.
498+
// Only a KeyPressMsg can select a file.
499499
default:
500500
return false, ""
501501
}

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/MakeNowJust/heredoc v1.0.0
77
github.com/atotto/clipboard v0.1.4
8-
github.com/charmbracelet/bubbletea v1.1.0
8+
github.com/charmbracelet/bubbletea v1.1.1-0.20240830154658-85c5adc127b3
99
github.com/charmbracelet/harmonica v0.2.0
1010
github.com/charmbracelet/lipgloss v0.13.0
1111
github.com/charmbracelet/x/ansi v0.2.3
@@ -22,12 +22,14 @@ require (
2222
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
2323
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
2424
github.com/charmbracelet/x/term v0.2.0 // indirect
25+
github.com/charmbracelet/x/windows v0.2.0 // indirect
2526
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
2627
github.com/kylelemons/godebug v1.1.0 // indirect
2728
github.com/mattn/go-isatty v0.0.20 // indirect
2829
github.com/mattn/go-localereader v0.0.1 // indirect
2930
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
3031
github.com/muesli/cancelreader v0.2.2 // indirect
32+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
3133
golang.org/x/sync v0.8.0 // indirect
3234
golang.org/x/sys v0.24.0 // indirect
3335
golang.org/x/text v0.3.8 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp
88
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
99
github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c=
1010
github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4=
11+
github.com/charmbracelet/bubbletea v1.1.1-0.20240830154658-85c5adc127b3 h1:oqDwkNLoIVbOjX0ZomkPljMtRKZvJMpYkR1A68QcbJo=
12+
github.com/charmbracelet/bubbletea v1.1.1-0.20240830154658-85c5adc127b3/go.mod h1:RYka31SjvShLlaYsbsBSiXnneU2JUEoKvI3nrOUaJuw=
1113
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
1214
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
1315
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
@@ -18,6 +20,8 @@ github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAM
1820
github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
1921
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
2022
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
23+
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
24+
github.com/charmbracelet/x/windows v0.2.0/go.mod h1:ZibNFR49ZFqCXgP76sYanisxRyC+EYrBE7TTknD8s1s=
2125
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
2226
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
2327
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
@@ -43,6 +47,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
4347
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
4448
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
4549
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
50+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
51+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
4652
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
4753
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
4854
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

key/key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//
2121
// func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2222
// switch msg := msg.(type) {
23-
// case tea.KeyMsg:
23+
// case tea.KeyPressMsg:
2424
// switch {
2525
// case key.Matches(msg, DefaultKeyMap.Up):
2626
// // The user pressed up

list/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
771771
var cmds []tea.Cmd
772772

773773
switch msg := msg.(type) {
774-
case tea.KeyMsg:
774+
case tea.KeyPressMsg:
775775
if key.Matches(msg, m.KeyMap.ForceQuit) {
776776
return m, tea.Quit
777777
}
@@ -806,7 +806,7 @@ func (m *Model) handleBrowsing(msg tea.Msg) tea.Cmd {
806806
numItems := len(m.VisibleItems())
807807

808808
switch msg := msg.(type) {
809-
case tea.KeyMsg:
809+
case tea.KeyPressMsg:
810810
switch {
811811
// Note: we match clear filter before quit because, by default, they're
812812
// both mapped to escape.
@@ -875,7 +875,7 @@ func (m *Model) handleFiltering(msg tea.Msg) tea.Cmd {
875875
var cmds []tea.Cmd
876876

877877
// Handle keys
878-
if msg, ok := msg.(tea.KeyMsg); ok {
878+
if msg, ok := msg.(tea.KeyPressMsg); ok {
879879
switch {
880880
case key.Matches(msg, m.KeyMap.CancelWhileFiltering):
881881
m.resetFiltering()

paginator/paginator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func WithPerPage(perPage int) Option {
175175
// Update is the Tea update function which binds keystrokes to pagination.
176176
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
177177
switch msg := msg.(type) {
178-
case tea.KeyMsg:
178+
case tea.KeyPressMsg:
179179
switch {
180180
case key.Matches(msg, m.KeyMap.NextPage):
181181
m.NextPage()

paginator/paginator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestPrevPage(t *testing.T) {
7676
model.SetTotalPages(tt.totalPages)
7777
model.Page = tt.page
7878

79-
model, _ = model.Update(tea.KeyMsg{Type: tea.KeyLeft, Alt: false, Runes: []rune{}})
79+
model, _ = model.Update(tea.KeyPressMsg{Code: tea.KeyLeft})
8080
if model.Page != tt.expected {
8181
t.Errorf("PrevPage() = %d, expected %d", model.Page, tt.expected)
8282
}
@@ -101,7 +101,7 @@ func TestNextPage(t *testing.T) {
101101
model.SetTotalPages(tt.totalPages)
102102
model.Page = tt.page
103103

104-
model, _ = model.Update(tea.KeyMsg{Type: tea.KeyRight, Alt: false, Runes: []rune{}})
104+
model, _ = model.Update(tea.KeyPressMsg{Code: tea.KeyRight})
105105
if model.Page != tt.expected {
106106
t.Errorf("NextPage() = %d, expected %d", model.Page, tt.expected)
107107
}

progress/progress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ func New(opts ...Option) Model {
205205
var NewModel = New
206206

207207
// Init exists to satisfy the tea.Model interface.
208-
func (m Model) Init() tea.Cmd {
209-
return nil
208+
func (m Model) Init() (tea.Model, tea.Cmd) {
209+
return m, nil
210210
}
211211

212212
// Update is used to animate the progress bar during transitions. Use

table/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
205205
}
206206

207207
switch msg := msg.(type) {
208-
case tea.KeyMsg:
208+
case tea.KeyPressMsg:
209209
switch {
210210
case key.Matches(msg, m.KeyMap.LineUp):
211211
m.MoveUp(1)

0 commit comments

Comments
 (0)