parse more SGR attrs

This commit is contained in:
Mitchell Hashimoto
2022-06-26 17:37:08 -07:00
parent bcc6b7604d
commit e325ea1616
4 changed files with 33 additions and 0 deletions

View File

@@ -15,6 +15,15 @@ pub const Attribute = union(enum) {
/// Bold the text.
bold: void,
/// Underline the text
underline: void,
/// Blink the text
blink: void,
/// Invert fg/bg colors.
inverse: void,
/// Set foreground color as RGB values.
direct_color_fg: RGB,
@@ -68,6 +77,12 @@ pub const Parser = struct {
1 => return Attribute{ .bold = {} },
4 => return Attribute{ .underline = {} },
5 => return Attribute{ .blink = {} },
7 => return Attribute{ .inverse = {} },
30...37 => return Attribute{
.@"8_fg" = @intToEnum(color.Name, slice[0] - 30),
},
@@ -178,6 +193,11 @@ test "sgr: bold" {
try testing.expect(v == .bold);
}
test "sgr: inverse" {
const v = testParse(&[_]u16{7});
try testing.expect(v == .inverse);
}
test "sgr: 8 color" {
var p: Parser = .{ .params = &[_]u16{ 31, 43, 103 } };