mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-24 22:54:39 +03:00
Updates for Tea v0.2.0
This commit is contained in:
parent
64c8cd27ae
commit
d964fbe3d7
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/charmbracelet/teaparty
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/charmbracelet/tea v0.0.0-20200220032354-23432f30dd46
|
github.com/charmbracelet/tea v0.2.0
|
||||||
github.com/muesli/termenv v0.5.0
|
github.com/muesli/termenv v0.5.0
|
||||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
|
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
|
||||||
)
|
)
|
||||||
|
1
go.sum
1
go.sum
@ -1,5 +1,6 @@
|
|||||||
github.com/charmbracelet/tea v0.0.0-20200220032354-23432f30dd46 h1:ZRxnZ9WA8+DX7IpIrUjaAzue12wCA8bHgDWSrqARvGY=
|
github.com/charmbracelet/tea v0.0.0-20200220032354-23432f30dd46 h1:ZRxnZ9WA8+DX7IpIrUjaAzue12wCA8bHgDWSrqARvGY=
|
||||||
github.com/charmbracelet/tea v0.0.0-20200220032354-23432f30dd46/go.mod h1:96S8RyGdd7HfPcgDC8XqPKe+eH/1etFkw6lfhQCesgU=
|
github.com/charmbracelet/tea v0.0.0-20200220032354-23432f30dd46/go.mod h1:96S8RyGdd7HfPcgDC8XqPKe+eH/1etFkw6lfhQCesgU=
|
||||||
|
github.com/charmbracelet/tea v0.2.0/go.mod h1:lADjwO2mMub9qvXSCA9vAkabVWO0HeUrv4uO/lG3C+k=
|
||||||
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=
|
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=
|
||||||
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
|
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package input
|
package input
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/tea"
|
"github.com/charmbracelet/tea"
|
||||||
|
|
||||||
"github.com/muesli/termenv"
|
"github.com/muesli/termenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +13,10 @@ var (
|
|||||||
color func(s string) termenv.Color = termenv.ColorProfile().Color
|
color func(s string) termenv.Color = termenv.ColorProfile().Color
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ErrMsg error
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
|
Err error
|
||||||
Prompt string
|
Prompt string
|
||||||
Value string
|
Value string
|
||||||
Cursor string
|
Cursor string
|
||||||
@ -149,6 +152,10 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ErrMsg:
|
||||||
|
m.Err = msg
|
||||||
|
return m, nil
|
||||||
|
|
||||||
case CursorBlinkMsg:
|
case CursorBlinkMsg:
|
||||||
m.blink = !m.blink
|
m.blink = !m.blink
|
||||||
return m, nil
|
return m, nil
|
||||||
@ -215,7 +222,7 @@ func cursorView(s string, m Model) string {
|
|||||||
func Blink(model tea.Model) tea.Msg {
|
func Blink(model tea.Model) tea.Msg {
|
||||||
m, ok := model.(Model)
|
m, ok := model.(Model)
|
||||||
if !ok {
|
if !ok {
|
||||||
return tea.NewErrMsg("could not assert given model to the model we expected; make sure you're passing as input model")
|
return ErrMsg(errors.New("could not assert given model to the model we expected; make sure you're passing as input model"))
|
||||||
}
|
}
|
||||||
time.Sleep(m.BlinkSpeed)
|
time.Sleep(m.BlinkSpeed)
|
||||||
return CursorBlinkMsg{}
|
return CursorBlinkMsg{}
|
||||||
|
Loading…
Reference in New Issue
Block a user