restore_original_console_font will restore the console font and code page * settings to what they were when NetHack was launched. */
| 2235 | * settings to what they were when NetHack was launched. |
| 2236 | */ |
| 2237 | void |
| 2238 | restore_original_console_font(void) |
| 2239 | { |
| 2240 | #ifdef VIRTUAL_TERMINAL_SEQUENCES |
| 2241 | char *tmplocalestr; |
| 2242 | #endif /* VIRTUAL_TERMINAL_SEQUENCES */ |
| 2243 | |
| 2244 | if (console.font_changed) { |
| 2245 | BOOL success; |
| 2246 | #ifndef VIRTUAL_TERMINAL_SEQUENCES |
| 2247 | raw_print("Restoring original font and code page\n"); |
| 2248 | success = SetConsoleOutputCP(console.orig_code_page); |
| 2249 | #else /* VIRTUAL_TERMINAL_SEQUENCES */ |
| 2250 | if (wizard) |
| 2251 | raw_print("Restoring original font, code page and locale\n"); |
| 2252 | |
| 2253 | tmplocalestr = setlocale(LC_ALL, console.orig_localestr); |
| 2254 | if (tmplocalestr) { |
| 2255 | if (console.localestr) |
| 2256 | free(console.localestr); |
| 2257 | console.localestr = dupstr(tmplocalestr); |
| 2258 | } |
| 2259 | success = SetConsoleOutputCP(console.orig_code_page); |
| 2260 | #endif /* VIRTUAL_TERMINAL_SEQUENCES */ |
| 2261 | if (!success) |
| 2262 | raw_print("Unable to restore original code page\n"); |
| 2263 | |
| 2264 | success = SetCurrentConsoleFontEx(console.hConOut, FALSE, |
| 2265 | &console.orig_font_info); |
| 2266 | if (!success) |
| 2267 | raw_print("Unable to restore original font\n"); |
| 2268 | |
| 2269 | console.font_changed = FALSE; |
| 2270 | } |
| 2271 | } |
| 2272 | |
| 2273 | /* set_cp_map() creates a mapping of every possible character of a code |
| 2274 | * page to its corresponding WCHAR. This is necessary due to the high |