sgr: parse italic (render not implemented)

This commit is contained in:
Mitchell Hashimoto
2022-11-07 14:04:40 -08:00
parent 73c4395fc2
commit c1a9184ebd
3 changed files with 15 additions and 0 deletions

View File

@ -161,6 +161,7 @@ pub const Cell = struct {
has_fg: bool = false, has_fg: bool = false,
bold: bool = false, bold: bool = false,
italic: bool = false,
faint: bool = false, faint: bool = false,
underline: bool = false, underline: bool = false,
inverse: bool = false, inverse: bool = false,

View File

@ -351,6 +351,10 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
self.screen.cursor.pen.attrs.bold = true; self.screen.cursor.pen.attrs.bold = true;
}, },
.italic => {
self.screen.cursor.pen.attrs.italic = true;
},
.faint => { .faint => {
self.screen.cursor.pen.attrs.faint = true; self.screen.cursor.pen.attrs.faint = true;
}, },

View File

@ -21,6 +21,9 @@ pub const Attribute = union(enum) {
/// Bold the text. /// Bold the text.
bold: void, bold: void,
/// Italic text.
italic: void,
/// Faint/dim text. /// Faint/dim text.
faint: void, faint: void,
@ -97,6 +100,8 @@ pub const Parser = struct {
2 => return Attribute{ .faint = {} }, 2 => return Attribute{ .faint = {} },
3 => return Attribute{ .italic = {} },
4 => return Attribute{ .underline = {} }, 4 => return Attribute{ .underline = {} },
5 => return Attribute{ .blink = {} }, 5 => return Attribute{ .blink = {} },
@ -224,6 +229,11 @@ test "sgr: bold" {
try testing.expect(v == .bold); try testing.expect(v == .bold);
} }
test "sgr: italic" {
const v = testParse(&[_]u16{3});
try testing.expect(v == .italic);
}
test "sgr: inverse" { test "sgr: inverse" {
{ {
const v = testParse(&[_]u16{7}); const v = testParse(&[_]u16{7});