sgr parsing bright colors now sets color properly

This commit is contained in:
Mitchell Hashimoto
2022-08-27 10:55:10 -07:00
parent 1609c8e775
commit 8ff98446a9

View File

@ -158,7 +158,8 @@ pub const Parser = struct {
49 => return Attribute{ .reset_bg = {} }, 49 => return Attribute{ .reset_bg = {} },
90...97 => return Attribute{ 90...97 => return Attribute{
.@"8_bright_fg" = @intToEnum(color.Name, slice[0] - 90), // 82 instead of 90 to offset to "bright" colors
.@"8_bright_fg" = @intToEnum(color.Name, slice[0] - 82),
}, },
100...107 => return Attribute{ 100...107 => return Attribute{
@ -228,7 +229,7 @@ test "sgr: inverse" {
} }
test "sgr: 8 color" { test "sgr: 8 color" {
var p: Parser = .{ .params = &[_]u16{ 31, 43, 103 } }; var p: Parser = .{ .params = &[_]u16{ 31, 43, 90, 103 } };
{ {
const v = p.next().?; const v = p.next().?;
@ -242,6 +243,12 @@ test "sgr: 8 color" {
try testing.expect(v.@"8_bg" == .yellow); try testing.expect(v.@"8_bg" == .yellow);
} }
{
const v = p.next().?;
try testing.expect(v == .@"8_bright_fg");
try testing.expect(v.@"8_bright_fg" == .bright_black);
}
{ {
const v = p.next().?; const v = p.next().?;
try testing.expect(v == .@"8_bright_bg"); try testing.expect(v == .@"8_bright_bg");