Terminal: parse foreground+background in a single SGR escape.

* Whilst testing `starship`, it was apparent that setting both the
  foreground & background colours in a single SGR escape is deemed
  a valid escape sequence.
* E.g. `ESC[48;2;58;149;199;38;2;47;121;161m` would set the
  background to RGB(58,149,199) and foreground to RGB(47,121,161).

Change-Id: I3c14afe2ddf673c85d1678a01e7258587b17f21b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5210
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Jessica Hamilton 2022-04-15 22:20:25 +00:00 committed by Jérôme Duval
parent 945a908417
commit c285a1585e

View File

@ -836,12 +836,16 @@ TermParse::EscParse()
case 38:
{
if (nparam == 3 && param[1] == 5)
attributes.SetIndexedForeground(param[2]);
else if (nparam == 5 && param[1] == 2)
attributes.SetDirectForeground(param[2], param[3], param[4]);
if (nparam >= 3 && param[row+1] == 5) {
attributes.SetIndexedForeground(param[row+2]);
row += 2;
} else if (nparam >= 5 && param[row+1] == 2) {
attributes.SetDirectForeground(param[row+2], param[row+3], param[row+4]);
row += 4;
} else {
row = nparam; // force exit of the parsing
}
row = nparam; // force exit of the parsing
break;
}
@ -871,12 +875,16 @@ TermParse::EscParse()
case 48:
{
if (nparam == 3 && param[1] == 5)
attributes.SetIndexedBackground(param[2]);
else if (nparam == 5 && param[1] == 2)
attributes.SetDirectBackground(param[2], param[3], param[4]);
if (nparam >= 3 && param[row+1] == 5) {
attributes.SetIndexedBackground(param[row+2]);
row += 2;
} else if (nparam >= 5 && param[row+1] == 2) {
attributes.SetDirectBackground(param[row+2], param[row+3], param[row+4]);
row += 4;
} else {
row = nparam; // force exit of the parsing
}
row = nparam; // force exit of the parsing
break;
}