Bump Bubble Tea to v0.19.3 and update deprecated methods

* Update deprecated altscreen methods
* Update deprecated mouse methods
This commit is contained in:
Christian Rocha 2022-01-29 19:21:14 -05:00
parent b37df2f640
commit 2f37a2760d
5 changed files with 13 additions and 12 deletions

2
go.mod
View file

@ -4,7 +4,7 @@ go 1.16
require (
github.com/charmbracelet/bubbles v0.9.0
github.com/charmbracelet/bubbletea v0.19.1
github.com/charmbracelet/bubbletea v0.19.3
github.com/charmbracelet/charm v0.9.1
github.com/charmbracelet/glamour v0.2.1-0.20210402234443-abe9cda419ba
github.com/charmbracelet/lipgloss v0.4.0

4
go.sum
View file

@ -62,8 +62,8 @@ github.com/charmbracelet/bubbles v0.9.0/go.mod h1:NWT/c+0rYEnYChz5qCyX4Lj6fDw9gG
github.com/charmbracelet/bubbletea v0.13.1/go.mod h1:tp9tr9Dadh0PLhgiwchE5zZJXm5543JYjHG9oY+5qSg=
github.com/charmbracelet/bubbletea v0.14.1/go.mod h1:b5lOf5mLjMg1tRn1HVla54guZB+jvsyV0yYAQja95zE=
github.com/charmbracelet/bubbletea v0.19.0/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA=
github.com/charmbracelet/bubbletea v0.19.1 h1:VHuzkJbnTAkxhOfi9+Lb5PYfNM9+Oh+qhP8uDX5ReOU=
github.com/charmbracelet/bubbletea v0.19.1/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA=
github.com/charmbracelet/bubbletea v0.19.3 h1:OKeO/Y13rQQqt4snX+lePB0QrnW80UdrMNolnCcmoAw=
github.com/charmbracelet/bubbletea v0.19.3/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA=
github.com/charmbracelet/charm v0.9.1 h1:lcBUL8OruDLuP56erZ1iD1viJ41H7TyyHeIOIZ4T0v4=
github.com/charmbracelet/charm v0.9.1/go.mod h1:0EnHP/Gh/m7gah8+f0f9WL0oSS9yOu0ZMTXNdzx919k=
github.com/charmbracelet/glamour v0.2.1-0.20210402234443-abe9cda419ba h1:smKYYwwVPZyMK2LCirIi2WY25tZZW0IU7GYe1ASGCe4=

10
main.go
View file

@ -333,6 +333,7 @@ func runTUI(workingDirectory string, stashedOnly bool) error {
cfg.ShowAllFiles = showAllFiles
cfg.GlamourMaxWidth = width
cfg.GlamourStyle = style
cfg.EnableMouse = mouse
if stashedOnly {
cfg.DocumentTypes.Add(ui.StashedDoc, ui.NewsDoc)
@ -341,14 +342,7 @@ func runTUI(workingDirectory string, stashedOnly bool) error {
}
// Run Bubble Tea program
p := ui.NewProgram(cfg)
p.EnterAltScreen()
defer p.ExitAltScreen()
if mouse {
p.EnableMouseCellMotion()
defer p.DisableMouseCellMotion()
}
if err := p.Start(); err != nil {
if err := ui.NewProgram(cfg).Start(); err != nil {
return err
}

View file

@ -8,6 +8,7 @@ type Config struct {
HomeDir string `env:"HOME"`
GlamourMaxWidth uint
GlamourStyle string
EnableMouse bool
// Which directory should we start from?
WorkingDirectory string

View file

@ -51,7 +51,13 @@ func NewProgram(cfg Config) *tea.Program {
debug = true
}
config = cfg
return tea.NewProgram(newModel(cfg))
opts := []tea.ProgramOption{tea.WithAltScreen()}
if cfg.EnableMouse {
opts = append(opts, tea.WithMouseCellMotion())
}
return tea.NewProgram(newModel(cfg), opts...)
}
type errMsg struct{ err error }