/* * @brief Draws at most len chars or size bytes of the specified string. Color escape * sequences are not visible chars. Returns the number of chars drawn. */ size_t R_DrawSizedString(r_pixel_t x, r_pixel_t y, const char *s, size_t len, size_t size, int32_t color) { size_t i, j; i = j = 0; while (*s && i < len && j < size) { if (IS_COLOR(s)) { // color escapes color = *(s + 1) - '0'; j += 2; s += 2; continue; } if (IS_LEGACY_COLOR(s)) { // legacy colors color = CON_COLOR_ALT; j++; s++; continue; } R_DrawChar(x, y, *s, color); x += r_draw.font->char_width; // next char position in line i++; j++; s++; } return i; }
/** * @brief */ static void Sv_DrawConsole_Buffer(void) { char *lines[sv_console.height]; const size_t count = Con_Tail(&sv_console, lines, sv_console.height); size_t row = sv_console.height; for (size_t i = 0; i < count; i++) { const size_t j = count - i - 1; char *line = lines[j]; char *s = line; Sv_DrawConsole_Color(j ? StrrColor(lines[j - 1]) : CON_COLOR_DEFAULT); size_t col = 1; while (*s) { if (IS_LEGACY_COLOR(s)) { Sv_DrawConsole_Color(CON_COLOR_ALT); } else if (IS_COLOR(s)) { Sv_DrawConsole_Color(*(s + 1) - '0'); s++; } else if (isascii(*s)) { mvaddch((int32_t) row, (int32_t) col++, *s); } s++; } g_free(line); row--; } Sv_DrawConsole_Color(CON_COLOR_DEFAULT); }