Combined emphases into a single escape sequence (#4528)

This commit is contained in:
Anas
2025-09-05 09:50:56 -07:00
committed by GitHub
parent 053d262944
commit 0a94e06750
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -409,13 +409,16 @@ template <typename Char> struct ansi_color_escape {
if (has_emphasis(em, emphasis::conceal)) em_codes[6] = 8;
if (has_emphasis(em, emphasis::strikethrough)) em_codes[7] = 9;
buffer[size++] = static_cast<Char>('\x1b');
buffer[size++] = static_cast<Char>('[');
for (size_t i = 0; i < num_emphases; ++i) {
if (!em_codes[i]) continue;
buffer[size++] = static_cast<Char>('\x1b');
buffer[size++] = static_cast<Char>('[');
buffer[size++] = static_cast<Char>('0' + em_codes[i]);
buffer[size++] = static_cast<Char>('m');
buffer[size++] = static_cast<Char>(';');
}
buffer[size - 1] = static_cast<Char>('m');
}
FMT_CONSTEXPR operator const Char*() const noexcept { return buffer; }