1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:27:34 +00:00

LibVT: Implement bright color support

Previously, we only used bright colors when the bold attribute was set.
We now have the option to set it via escape sequences. We also needed to
make the bold text behavior optional, as some color schemes do weird
things with it. For example, Solarized uses it for various shades of
gray, so bold green would turn into a light shade of gray.

The following new escape sequences are supported:
- `CSI 90;m` to `CSI 97;m`: set bright foreground color
- `CSI 100;m` to `CSI 107;m`: set bright background color
This commit is contained in:
Daniel Bertalan 2021-06-03 17:26:25 +02:00 committed by Linus Groh
parent acbd1d14d0
commit 53099b216c
5 changed files with 56 additions and 12 deletions

View file

@ -267,9 +267,7 @@ void Terminal::SGR(Parameters params)
case 36:
case 37:
// Foreground color
if (m_current_state.attribute.flags & Attribute::Bold)
param += 8;
m_current_state.attribute.foreground_color = Color::named((Color::ANSIColor)(param - 30));
m_current_state.attribute.foreground_color = Color::named(static_cast<Color::ANSIColor>(param - 30));
break;
case 39:
// reset foreground
@ -284,14 +282,34 @@ void Terminal::SGR(Parameters params)
case 46:
case 47:
// Background color
if (m_current_state.attribute.flags & Attribute::Bold)
param += 8;
m_current_state.attribute.background_color = Color::named((Color::ANSIColor)(param - 40));
m_current_state.attribute.background_color = Color::named(static_cast<Color::ANSIColor>(param - 40));
break;
case 49:
// reset background
m_current_state.attribute.background_color = Attribute::default_background_color;
break;
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
// Bright foreground color
m_current_state.attribute.foreground_color = Color::named(static_cast<Color::ANSIColor>(8 + param - 90));
break;
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
// Bright background color
m_current_state.attribute.background_color = Color::named(static_cast<Color::ANSIColor>(8 + param - 100));
break;
default:
dbgln("FIXME: SGR: p: {}", param);
}