2020-10-13 12:52:30 -04:00
|
|
|
package tea
|
|
|
|
|
2021-02-26 18:38:52 -05:00
|
|
|
func (p *Program) initTerminal() error {
|
|
|
|
err := p.initInput()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2021-01-11 16:33:14 -05:00
|
|
|
}
|
|
|
|
|
2021-07-29 16:47:13 -04:00
|
|
|
if p.console != nil {
|
2021-02-26 18:38:52 -05:00
|
|
|
err = p.console.SetRaw()
|
2021-01-11 16:33:14 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-29 17:41:36 -04:00
|
|
|
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 {
|
2021-07-29 17:41:36 -04:00
|
|
|
showCursor(p.output)
|
2021-02-26 18:38:52 -05:00
|
|
|
|
|
|
|
if p.console != nil {
|
|
|
|
err := p.console.Reset()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-11 16:33:14 -05:00
|
|
|
}
|
2021-02-26 18:38:52 -05:00
|
|
|
|
2021-09-28 13:49:54 -04:00
|
|
|
return p.restoreInput()
|
2020-10-13 12:52:30 -04:00
|
|
|
}
|