github.com/panekj/cli@v0.0.0-20230304125325-467dd2f3797e/cli/streams/stream.go (about) 1 package streams 2 3 import ( 4 "github.com/moby/term" 5 ) 6 7 // commonStream is an input stream used by the DockerCli to read user input 8 type commonStream struct { 9 fd uintptr 10 isTerminal bool 11 state *term.State 12 } 13 14 // FD returns the file descriptor number for this stream 15 func (s *commonStream) FD() uintptr { 16 return s.fd 17 } 18 19 // IsTerminal returns true if this stream is connected to a terminal 20 func (s *commonStream) IsTerminal() bool { 21 return s.isTerminal 22 } 23 24 // RestoreTerminal restores normal mode to the terminal 25 func (s *commonStream) RestoreTerminal() { 26 if s.state != nil { 27 term.RestoreTerminal(s.fd, s.state) 28 } 29 } 30 31 // SetIsTerminal sets the boolean used for isTerminal 32 func (s *commonStream) SetIsTerminal(isTerminal bool) { 33 s.isTerminal = isTerminal 34 }