Tty is an abstraction of a tty (traditionally "teletype"). This allows applications to provide for alternate backends, as there are situations where the traditional /dev/tty does not work, or where more flexible handling is required. This interface is for use with the terminfo-style based API. It
| 30 | // a successful Start), and Stop may be called while an outstanding Read or Write |
| 31 | // call is pending. (Stop should interrupt any blocking read.) |
| 32 | type Tty interface { |
| 33 | // Start is used to activate the Tty for use. Upon return the terminal should be |
| 34 | // in raw mode, non-blocking, etc. The implementation should take care of saving |
| 35 | // any state that is required so that it may be restored when Stop is called. |
| 36 | // Start must be idempotent. |
| 37 | Start() error |
| 38 | |
| 39 | // Stop is used to stop using this Tty instance. This may be a suspend, so that other |
| 40 | // terminal based applications can run in the foreground. Implementations should |
| 41 | // restore any state collected at Start(), and return to ordinary blocking mode, etc. |
| 42 | // Drain is called first to drain the input. Once this is called, no more Read |
| 43 | // or Write calls will be made until Start is called again. |
| 44 | Stop() error |
| 45 | |
| 46 | // Drain is called before Stop, and ensures that the reader will wake up appropriately |
| 47 | // if it was blocked. This workaround is required for /dev/tty on certain UNIX systems |
| 48 | // to ensure that Read() does not block forever. This typically arranges for the tty driver |
| 49 | // to send data immediately (e.g. VMIN and VTIME both set zero) and sets a deadline on input. |
| 50 | // Implementations may reasonably make this a no-op. There will still be control sequences |
| 51 | // emitted between the time this is called, and when Stop is called. |
| 52 | Drain() error |
| 53 | |
| 54 | // NotifyResize is used to post a signal that will be written to (non-blocking) if the |
| 55 | // system detects that a resize event happened. If the channel is null, then the caller |
| 56 | // does not desire such notifications (or no longer desires them.) |
| 57 | // The standard UNIX implementation links this to a handler for SIGWINCH. |
| 58 | // |
| 59 | // If window resize events are delivered inline as part of Read, then the implementation may stub this. |
| 60 | // If the caller determines that the underlying terminal can deliver notifications without OS support |
| 61 | // (i.e. the terminal supports in-band resize notifications), then it may not call this function at all. |
| 62 | NotifyResize(chan<- bool) |
| 63 | |
| 64 | // WindowSize is called to determine the terminal dimensions. This might be determined |
| 65 | // by an ioctl or other means. |
| 66 | WindowSize() (WindowSize, error) |
| 67 | |
| 68 | io.ReadWriteCloser |
| 69 | } |
no outgoing calls
no test coverage detected