diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 0b8da73ba..33eadeb24 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -911,7 +911,7 @@ pub fn updateCell( }); } - if (cell.attrs.underline) { + if (cell.attrs.underline != .none) { self.cells.appendAssumeCapacity(.{ .mode = .underline, .grid_pos = .{ @intToFloat(f32, x), @intToFloat(f32, y) }, diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 662963e2c..2771b1a65 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -928,7 +928,7 @@ pub fn updateCell( var i: usize = 0; if (colors.bg != null) i += 1; if (!cell.empty()) i += 1; - if (cell.attrs.underline) i += 1; + if (cell.attrs.underline != .none) i += 1; if (cell.attrs.strikethrough) i += 1; break :needed i; }; @@ -1002,7 +1002,7 @@ pub fn updateCell( }); } - if (cell.attrs.underline) { + if (cell.attrs.underline != .none) { self.cells.appendAssumeCapacity(.{ .mode = .underline, .grid_col = @intCast(u16, x), diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 993e0a4e0..4b9161077 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -56,6 +56,7 @@ const Allocator = std.mem.Allocator; const utf8proc = @import("utf8proc"); const trace = @import("tracy").trace; +const sgr = @import("sgr.zig"); const color = @import("color.zig"); const point = @import("point.zig"); const CircBuf = @import("circ_buf.zig").CircBuf; @@ -167,10 +168,10 @@ pub const Cell = struct { bold: bool = false, italic: bool = false, faint: bool = false, - underline: bool = false, blink: bool = false, inverse: bool = false, strikethrough: bool = false, + underline: sgr.Attribute.Underline = .none, /// True if this is a wide character. This char takes up /// two cells. The following cell ALWAYS is a space. @@ -241,7 +242,7 @@ pub const Cell = struct { } test { - //log.warn("CELL={} {}", .{ @sizeOf(Cell), @alignOf(Cell) }); + //log.warn("CELL={} bits={} {}", .{ @sizeOf(Cell), @bitSizeOf(Cell), @alignOf(Cell) }); try std.testing.expectEqual(12, @sizeOf(Cell)); } }; diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 91b1ac21d..90867da0c 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -379,12 +379,12 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void { self.screen.cursor.pen.attrs.faint = true; }, - .underline => { - self.screen.cursor.pen.attrs.underline = true; + .underline => |v| { + self.screen.cursor.pen.attrs.underline = v; }, .reset_underline => { - self.screen.cursor.pen.attrs.underline = false; + self.screen.cursor.pen.attrs.underline = .none; }, .blink => { diff --git a/src/terminal/sgr.zig b/src/terminal/sgr.zig index 835694092..8d031c4a1 100644 --- a/src/terminal/sgr.zig +++ b/src/terminal/sgr.zig @@ -31,7 +31,7 @@ pub const Attribute = union(enum) { faint: void, /// Underline the text - underline: void, + underline: Underline, reset_underline: void, /// Blink the text @@ -75,6 +75,15 @@ pub const Attribute = union(enum) { g: u8, b: u8, }; + + pub const Underline = enum(u3) { + none = 0, + single = 1, + double = 2, + curly = 3, + dotted = 4, + dashed = 5, + }; }; /// Parser parses the attributes from a list of SGR parameters. @@ -107,7 +116,7 @@ pub const Parser = struct { 3 => return Attribute{ .italic = {} }, - 4 => return Attribute{ .underline = {} }, + 4 => return Attribute{ .underline = .single }, 5 => return Attribute{ .blink = {} },