| 11 | #include "../tty.hpp" |
| 12 | |
| 13 | char Term::Platform::read_raw_stdin() { |
| 14 | char c = static_cast<char>(getchar()); |
| 15 | if (c >= 0) { |
| 16 | return c; |
| 17 | } else if (c == EOF) { |
| 18 | //In non-raw (blocking) mode this happens when the input file |
| 19 | //ends. In such a case, return the End of Transmission (EOT) |
| 20 | //character (Ctrl-D) |
| 21 | return 0x04; |
| 22 | } else { |
| 23 | throw Exception("getchar() failed."); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | bool Term::Platform::read_raw(char* s) { |
| 28 | //Do nothing when TTY is not connected. |