Fixed dim and bold not mixing well (#460)

One single reset code controls both the dim and bold properties. Mixing both led to one of the properties being wrongly reset.

Co-authored-by: Arthur Sonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Jan Sende 2022-08-20 02:03:56 +09:00 committed by GitHub
parent 36460fea2a
commit 7cc68cfbd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,22 +56,24 @@ void UpdatePixelStyle(std::stringstream& ss,
return;
}
if ((!next.bold && previous.bold) || //
(!next.dim && previous.dim)) {
ss << "\x1B[22m"; // BOLD_RESET and DIM_RESET
// We might have wrongfully reset dim or bold because they share the same
// resetter. Take it into account so that the side effect will cause it to
// be set again below.
previous.bold = false;
previous.dim = false;
}
if (next.bold && !previous.bold) {
ss << "\x1B[1m"; // BOLD_SET
}
if (!next.bold && previous.bold) {
ss << "\x1B[22m"; // BOLD_RESET
}
if (next.dim && !previous.dim) {
ss << "\x1B[2m"; // DIM_SET
}
if (!next.dim && previous.dim) {
ss << "\x1B[22m"; // DIM_RESET
}
if (next.underlined && !previous.underlined) {
ss << "\x1B[4m"; // UNDERLINED_SET
}