| 147 | } |
| 148 | |
| 149 | void cleanup() { |
| 150 | // Reset console display |
| 151 | set_display(DISPLAY_TYPE_RESET); |
| 152 | |
| 153 | #if !defined(_WIN32) |
| 154 | // Restore settings on POSIX systems |
| 155 | if (!simple_io) { |
| 156 | if (tty != nullptr) { |
| 157 | out = stdout; |
| 158 | fclose(tty); |
| 159 | tty = nullptr; |
| 160 | } |
| 161 | tcsetattr(STDIN_FILENO, TCSANOW, &initial_state); |
| 162 | } |
| 163 | #endif |
| 164 | } |
| 165 | |
| 166 | // |
| 167 | // Display and IO |