github.1git.de/docker/cli@v26.1.3+incompatible/cli/streams/stream.go (about)

     1  package streams
     2  
     3  import (
     4  	"github.com/moby/term"
     5  )
     6  
     7  type commonStream struct {
     8  	fd         uintptr
     9  	isTerminal bool
    10  	state      *term.State
    11  }
    12  
    13  // FD returns the file descriptor number for this stream.
    14  func (s *commonStream) FD() uintptr {
    15  	return s.fd
    16  }
    17  
    18  // IsTerminal returns true if this stream is connected to a terminal.
    19  func (s *commonStream) IsTerminal() bool {
    20  	return s.isTerminal
    21  }
    22  
    23  // RestoreTerminal restores normal mode to the terminal.
    24  func (s *commonStream) RestoreTerminal() {
    25  	if s.state != nil {
    26  		_ = term.RestoreTerminal(s.fd, s.state)
    27  	}
    28  }
    29  
    30  // SetIsTerminal overrides whether a terminal is connected. It is used to
    31  // override this property in unit-tests, and should not be depended on for
    32  // other purposes.
    33  func (s *commonStream) SetIsTerminal(isTerminal bool) {
    34  	s.isTerminal = isTerminal
    35  }