diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pager.zig | 10 | ||||
| -rw-r--r-- | src/terminal.zig | 16 |
2 files changed, 10 insertions, 16 deletions
diff --git a/src/pager.zig b/src/pager.zig index aba73d43..ed3b9c35 100644 --- a/src/pager.zig +++ b/src/pager.zig @@ -222,14 +222,8 @@ const Handler = struct { .faint => s.dim = true, .italic => s.italic = true, .reset_italic => s.italic = false, - .underline => |u| s.ul = switch (u) { - .none => .off, - .single => .single, - .double => .double, - .curly => .curly, - .dotted => .dotted, - .dashed => .dashed, - }, + // SGR's styles in a cell's order (terminal.zig checks it). + .underline => |u| s.ul = @enumFromInt(@intFromEnum(u)), .blink => s.blink = true, .reset_blink => s.blink = false, .inverse => s.reverse = true, diff --git a/src/terminal.zig b/src/terminal.zig index 1d97318b..acc7efdf 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -2500,6 +2500,13 @@ fn cellAt(pages: *const ghostty_vt.PageList, row: ghostty_vt.Pin, x: u16) ?ghost return .{ .node = row.node, .row = rac.row, .cell = rac.cell, .row_idx = row.y, .col_idx = x }; } +// A cell's underline styles are SGR's, in SGR's order (`off` its `none`): a +// cast takes one to the other (cellStyle, pager.zig). +comptime { + if (enabled) for (@typeInfo(@FieldType(pardes.CellStyle, "ul")).@"enum".field_names, 0..) |name, i| + if (@intFromEnum(@field(ghostty_vt.sgr.Attribute.Underline, if (std.mem.eql(u8, name, "off")) "none" else name)) != i) @compileError("a cell's underline styles are not SGR's"); +} + fn cellStyle(p: *Pardes, ci: ghostty_vt.PageList.Cell, filtered: ?*FilteredColors, scnm: bool) pardes.CellStyle { const style = ci.style(); var cs: pardes.CellStyle = .{ @@ -2512,14 +2519,7 @@ fn cellStyle(p: *Pardes, ci: ghostty_vt.PageList.Cell, filtered: ?*FilteredColor .reverse = style.flags.inverse, .invisible = style.flags.invisible, .strikethrough = style.flags.strikethrough, - .ul = switch (style.flags.underline) { - .none => .off, - .single => .single, - .double => .double, - .curly => .curly, - .dotted => .dotted, - .dashed => .dashed, - }, + .ul = @enumFromInt(@intFromEnum(style.flags.underline)), }; if (filtered == null) switch (ci.cell.content_tag) { .bg_color_palette => cs.bg = palColor(p, ci.cell.content.color_palette.data), |
