bubbletea/tty.go

36 lines
466 B
Go
Raw Normal View History

2020-10-13 12:52:30 -04:00
package tea
func (p *Program) initTerminal() error {
err := p.initInput()
if err != nil {
return err
2021-01-11 16:33:14 -05:00
}
if p.console != nil {
err = p.console.SetRaw()
2021-01-11 16:33:14 -05:00
if err != nil {
return err
}
}
hideCursor(p.output)
2020-10-13 12:52:30 -04:00
return nil
}
2021-01-11 16:33:14 -05:00
func (p Program) restoreTerminal() error {
showCursor(p.output)
if p.console != nil {
err := p.console.Reset()
if err != nil {
return err
}
2021-01-11 16:33:14 -05:00
}
if err := p.restoreInput(); err != nil {
return err
}
return nil
2020-10-13 12:52:30 -04:00
}