|
|
|
@ -14,7 +14,11 @@ import (
|
|
|
|
|
"golang.org/x/term"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var tty string
|
|
|
|
|
var (
|
|
|
|
|
tty string
|
|
|
|
|
ttyin *os.File
|
|
|
|
|
ttyout *os.File
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func IsLightRendererSupported() bool {
|
|
|
|
|
return true
|
|
|
|
@ -47,8 +51,7 @@ func (r *LightRenderer) initPlatform() error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *LightRenderer) closePlatform() {
|
|
|
|
|
r.ttyin.Close()
|
|
|
|
|
r.ttyout.Close()
|
|
|
|
|
// NOOP
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func openTty(mode int) (*os.File, error) {
|
|
|
|
@ -68,11 +71,25 @@ func openTty(mode int) (*os.File, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func openTtyIn() (*os.File, error) {
|
|
|
|
|
return openTty(syscall.O_RDONLY)
|
|
|
|
|
if ttyin != nil {
|
|
|
|
|
return ttyin, nil
|
|
|
|
|
}
|
|
|
|
|
in, err := openTty(syscall.O_RDONLY)
|
|
|
|
|
if err == nil {
|
|
|
|
|
ttyin = in
|
|
|
|
|
}
|
|
|
|
|
return in, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func openTtyOut() (*os.File, error) {
|
|
|
|
|
return openTty(syscall.O_WRONLY)
|
|
|
|
|
if ttyout != nil {
|
|
|
|
|
return ttyout, nil
|
|
|
|
|
}
|
|
|
|
|
out, err := openTty(syscall.O_WRONLY)
|
|
|
|
|
if err == nil {
|
|
|
|
|
ttyout = out
|
|
|
|
|
}
|
|
|
|
|
return out, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *LightRenderer) setupTerminal() {
|
|
|
|
|