| 1239 | xputc_core(char ch) |
| 1240 | #else |
| 1241 | void |
| 1242 | xputc_core(int ch) |
| 1243 | #endif |
| 1244 | { |
| 1245 | ccount = 1; /* default to non-zero */ |
| 1246 | #ifndef VIRTUAL_TERMINAL_SEQUENCES |
| 1247 | boolean inverse = FALSE; |
| 1248 | #else |
| 1249 | WCHAR wch[2]; |
| 1250 | #endif |
| 1251 | nhassert(console.cursor.X >= 0 && console.cursor.X < console.width); |
| 1252 | nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height); |
| 1253 | |
| 1254 | cell_t cell; |
| 1255 | |
| 1256 | switch (ch) { |
| 1257 | case '\n': |
| 1258 | if (console.cursor.Y < console.height - 1) |
| 1259 | console.cursor.Y++; |
| 1260 | FALLTHROUGH; |
| 1261 | /* FALLTHRU */ |
| 1262 | case '\r': |
| 1263 | console.cursor.X = 1; |
| 1264 | break; |
| 1265 | case '\b': |
| 1266 | if (console.cursor.X > 1) { |
| 1267 | console.cursor.X--; |
| 1268 | } else if (console.cursor.Y > 0) { |
| 1269 | console.cursor.X = console.width - 1; |
| 1270 | console.cursor.Y--; |
| 1271 | } |
| 1272 | break; |
| 1273 | default: |
| 1274 | #ifdef VIRTUAL_TERMINAL_SEQUENCES |
| 1275 | /* this causes way too much performance degradation */ |
| 1276 | /* cell.color24 = customcolors[console.current_nhcolor]; */ |
| 1277 | cell.colorseq = esc_seq_colors[console.current_nhcolor]; |
| 1278 | cell.bkcolorseq = esc_seq_bkcolors[console.current_nhbkcolor]; |
| 1279 | cell.attr = console.attr; |
| 1280 | // if (console.color24) |
| 1281 | // __debugbreak(); |
| 1282 | cell.color24 = 0L; |
| 1283 | cell.color256idx = 0; |
| 1284 | wch[1] = 0; |
| 1285 | if (console.has_unicode) { |
| 1286 | wch[0] = (ch >= 0 && ch < SIZE(console.cpMap)) ? console.cpMap[ch] |
| 1287 | : ch; |
| 1288 | #ifdef UTF8_FROM_CORE |
| 1289 | if (SYMHANDLING(H_UTF8)) { |
| 1290 | /* we have to convert it to UTF-8 for cell.utf8str */ |
| 1291 | ccount = WideCharToMultiByte( |
| 1292 | CP_UTF8, 0, wch, -1, (char *) cell.utf8str, |
| 1293 | (int) sizeof cell.utf8str, NULL, NULL); |
| 1294 | } else { |
| 1295 | #endif |
| 1296 | /* store the wide version here also, so we don't slow |
| 1297 | down back_buffer_flip() with conversions */ |
| 1298 | cell.wcharacter = wch[0]; |
no test coverage detected