summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:34:57 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:02:08 -0300
commitc7bab5ec27f8dc1058e282fbbfc8fe9f01cd78bf (patch)
tree97e6d279f61c4963ec98b2c87de4b39e40d4184b
parent22643b1a1f37f9bf8cc1fcd4a80fb0876b9a0ff9 (diff)
downloadpardes-c7bab5ec27f8dc1058e282fbbfc8fe9f01cd78bf.tar.gz
pardes-c7bab5ec27f8dc1058e282fbbfc8fe9f01cd78bf.zip
terminal and pager: SGR's underline style becomes a cell's by a cast, where two switches mapped one enum onto the same one; a comptime check in terminal.zig holds the two in one order (`off` the cell's `none`)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--src/pager.zig10
-rw-r--r--src/terminal.zig16
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),