mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Add platform-specific terminal init & restore
This commit is contained in:
28
tty_unix.go
Normal file
28
tty_unix.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package tea
|
||||
|
||||
import (
|
||||
"github.com/pkg/term"
|
||||
)
|
||||
|
||||
var (
|
||||
tty *term.Term
|
||||
)
|
||||
|
||||
func initTerminal() error {
|
||||
var err error
|
||||
tty, err = term.Open("/dev/tty")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tty.SetRaw()
|
||||
hideCursor()
|
||||
return nil
|
||||
}
|
||||
|
||||
func restoreTerminal() {
|
||||
showCursor()
|
||||
tty.Restore()
|
||||
}
|
||||
Reference in New Issue
Block a user