Make sure we pass our mutex by reference

This commit is contained in:
Christian Rocha 2021-02-26 15:11:23 -05:00
parent 65cb46c475
commit 4e2643f318
1 changed files with 3 additions and 2 deletions

5
tea.go
View File

@ -100,7 +100,7 @@ func WithoutCatchPanics() ProgramOption {
type Program struct { type Program struct {
initialModel Model initialModel Model
mtx sync.Mutex mtx *sync.Mutex
output io.Writer // where to send output. this will usually be os.Stdout. output io.Writer // where to send output. this will usually be os.Stdout.
input io.Reader // this will usually be os.Stdin. input io.Reader // this will usually be os.Stdin.
@ -152,6 +152,7 @@ type hideCursorMsg struct{}
// NewProgram creates a new Program. // NewProgram creates a new Program.
func NewProgram(model Model, opts ...ProgramOption) *Program { func NewProgram(model Model, opts ...ProgramOption) *Program {
p := &Program{ p := &Program{
mtx: &sync.Mutex{},
initialModel: model, initialModel: model,
output: os.Stdout, output: os.Stdout,
input: os.Stdin, input: os.Stdin,
@ -221,7 +222,7 @@ func (p *Program) Start() error {
}() }()
} }
p.renderer = newRenderer(p.output, &p.mtx) p.renderer = newRenderer(p.output, p.mtx)
// Check if output is a TTY before entering raw mode, hiding the cursor and // Check if output is a TTY before entering raw mode, hiding the cursor and
// so on. // so on.