reset inverse attribute

This commit is contained in:
Mitchell Hashimoto
2022-07-26 09:37:52 -07:00
parent e34c8958c2
commit 28acd99d7d
2 changed files with 16 additions and 2 deletions

View File

@ -263,6 +263,10 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
self.screen.cursor.pen.attrs.inverse = 1;
},
.reset_inverse => {
self.screen.cursor.pen.attrs.inverse = 0;
},
.direct_color_fg => |rgb| {
self.screen.cursor.pen.fg = .{
.r = rgb.r,

View File

@ -23,6 +23,7 @@ pub const Attribute = union(enum) {
/// Invert fg/bg colors.
inverse: void,
reset_inverse: void,
/// Set foreground color as RGB values.
direct_color_fg: RGB,
@ -83,6 +84,8 @@ pub const Parser = struct {
7 => return Attribute{ .inverse = {} },
27 => return Attribute{ .reset_inverse = {} },
30...37 => return Attribute{
.@"8_fg" = @intToEnum(color.Name, slice[0] - 30),
},
@ -194,10 +197,17 @@ test "sgr: bold" {
}
test "sgr: inverse" {
{
const v = testParse(&[_]u16{7});
try testing.expect(v == .inverse);
}
{
const v = testParse(&[_]u16{27});
try testing.expect(v == .reset_inverse);
}
}
test "sgr: 8 color" {
var p: Parser = .{ .params = &[_]u16{ 31, 43, 103 } };