github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/cmds/core/elvish/edit/tty/reader.go (about)

     1  package tty
     2  
     3  import "os"
     4  
     5  // Reader reads terminal events and makes them available on a channel.
     6  type Reader interface {
     7  	// SetRaw turns the raw mode on or off. In raw mode, the Reader does not
     8  	// decode special sequences, but simply deliver them as RawRune events. If
     9  	// the Reader is in the middle of reading one event, it takes effect after
    10  	// this event is fully read. On platforms (i.e. Windows) where events are
    11  	// not encoded as special sequences, SetRaw has no effect.
    12  	SetRaw(bool)
    13  	// EventChan returns the channel onto which the Reader writes events that it
    14  	// has read.
    15  	EventChan() <-chan Event
    16  	// Start starts the Reader.
    17  	Start()
    18  	// Stop stops the Reader.
    19  	Stop()
    20  	// Close releases resources associated with the Reader. It does not affect
    21  	// resources used to create it.
    22  	Close()
    23  }
    24  
    25  // NewReader creates a new Reader on the given terminal file.
    26  // TODO: NewReader should return an error as well. Right now failure to
    27  // initialize Reader panics.
    28  func NewReader(f *os.File) Reader {
    29  	return newReader(f)
    30  }