stream.go 783 B

12345678910111213141516171819202122232425262728293031323334
  1. package command
  2. import (
  3. "github.com/docker/docker/pkg/term"
  4. )
  5. // CommonStream is an input stream used by the DockerCli to read user input
  6. type CommonStream struct {
  7. fd uintptr
  8. isTerminal bool
  9. state *term.State
  10. }
  11. // FD returns the file descriptor number for this stream
  12. func (s *CommonStream) FD() uintptr {
  13. return s.fd
  14. }
  15. // IsTerminal returns true if this stream is connected to a terminal
  16. func (s *CommonStream) IsTerminal() bool {
  17. return s.isTerminal
  18. }
  19. // RestoreTerminal restores normal mode to the terminal
  20. func (s *CommonStream) RestoreTerminal() {
  21. if s.state != nil {
  22. term.RestoreTerminal(s.fd, s.state)
  23. }
  24. }
  25. // SetIsTerminal sets the boolean used for isTerminal
  26. func (s *CommonStream) SetIsTerminal(isTerminal bool) {
  27. s.isTerminal = isTerminal
  28. }