()
| 20 | } |
| 21 | |
| 22 | func (t *termRaw) Next() byte { |
| 23 | oldState, err := term.MakeRaw(t.fd) |
| 24 | if err != nil { |
| 25 | panic(err) |
| 26 | } |
| 27 | defer term.Restore(t.fd, oldState) |
| 28 | |
| 29 | buf := make([]byte, 3) |
| 30 | n, err := os.Stdin.Read(buf) |
| 31 | if err != nil { |
| 32 | panic(err) |
| 33 | } |
| 34 | |
| 35 | // The third byte is the key specific value we are looking for. |
| 36 | // See: https://en.wikipedia.org/wiki/ANSI_escape_code |
| 37 | if n == 3 { |
| 38 | return buf[2] |
| 39 | } |
| 40 | |
| 41 | return buf[0] |
| 42 | } |
| 43 | |
| 44 | func (t *termRaw) GetSize() (width int, height int, err error) { |
| 45 | return term.GetSize(t.fd) |
no test coverage detected