forked from Mirrors/bubbletea
fix: don't access output from outside renderer
This commit is contained in:
parent
5d1a7264c5
commit
6b6bf6ab6d
10
tea.go
10
tea.go
|
@ -257,17 +257,17 @@ func (p *Program) StartReturningModel() (Model, error) {
|
|||
}()
|
||||
}
|
||||
|
||||
// If no renderer is set use the standard one.
|
||||
if p.renderer == nil {
|
||||
p.renderer = newRenderer(p.output, p.startupOptions.has(withANSICompressor))
|
||||
}
|
||||
|
||||
// Check if output is a TTY before entering raw mode, hiding the cursor and
|
||||
// so on.
|
||||
if err := p.initTerminal(); err != nil {
|
||||
return p.initialModel, err
|
||||
}
|
||||
|
||||
// If no renderer is set use the standard one.
|
||||
if p.renderer == nil {
|
||||
p.renderer = newRenderer(p.output, p.startupOptions.has(withANSICompressor))
|
||||
}
|
||||
|
||||
// Honor program startup options.
|
||||
if p.startupOptions&withAltScreen != 0 {
|
||||
p.renderer.enterAltScreen()
|
||||
|
|
6
tty.go
6
tty.go
|
@ -21,14 +21,16 @@ func (p *Program) initTerminal() error {
|
|||
}
|
||||
}
|
||||
|
||||
p.output.HideCursor()
|
||||
p.renderer.hideCursor()
|
||||
return nil
|
||||
}
|
||||
|
||||
// restoreTerminalState restores the terminal to the state prior to running the
|
||||
// Bubble Tea program.
|
||||
func (p *Program) restoreTerminalState() error {
|
||||
p.output.ShowCursor()
|
||||
if p.renderer != nil {
|
||||
p.renderer.showCursor()
|
||||
}
|
||||
|
||||
if p.console != nil {
|
||||
err := p.console.Reset()
|
||||
|
|
Loading…
Reference in New Issue