mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #1019 from mitchellh/underline-palette
terminal: support `58;5` for setting underline color via 256 palette
This commit is contained in:
@ -515,6 +515,11 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.@"256_underline_color" => |idx| {
|
||||||
|
self.screen.cursor.pen.attrs.underline_color = true;
|
||||||
|
self.screen.cursor.pen.underline_fg = self.color_palette.colors[idx];
|
||||||
|
},
|
||||||
|
|
||||||
.reset_underline_color => {
|
.reset_underline_color => {
|
||||||
self.screen.cursor.pen.attrs.underline_color = false;
|
self.screen.cursor.pen.attrs.underline_color = false;
|
||||||
},
|
},
|
||||||
|
@ -34,6 +34,7 @@ pub const Attribute = union(enum) {
|
|||||||
underline: Underline,
|
underline: Underline,
|
||||||
reset_underline: void,
|
reset_underline: void,
|
||||||
underline_color: color.RGB,
|
underline_color: color.RGB,
|
||||||
|
@"256_underline_color": u8,
|
||||||
reset_underline_color: void,
|
reset_underline_color: void,
|
||||||
|
|
||||||
/// Blink the text
|
/// Blink the text
|
||||||
@ -253,6 +254,11 @@ pub const Parser = struct {
|
|||||||
.b = @truncate(rgb[2]),
|
.b = @truncate(rgb[2]),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} else if (slice.len >= 3 and slice[1] == 5) {
|
||||||
|
self.idx += 2;
|
||||||
|
return Attribute{
|
||||||
|
.@"256_underline_color" = @truncate(slice[2]),
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
59 => return Attribute{ .reset_underline_color = {} },
|
59 => return Attribute{ .reset_underline_color = {} },
|
||||||
@ -462,6 +468,13 @@ test "sgr: 256 color" {
|
|||||||
var p: Parser = .{ .params = &[_]u16{ 38, 5, 161, 48, 5, 236 } };
|
var p: Parser = .{ .params = &[_]u16{ 38, 5, 161, 48, 5, 236 } };
|
||||||
try testing.expect(p.next().? == .@"256_fg");
|
try testing.expect(p.next().? == .@"256_fg");
|
||||||
try testing.expect(p.next().? == .@"256_bg");
|
try testing.expect(p.next().? == .@"256_bg");
|
||||||
|
try testing.expect(p.next() == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "sgr: 256 color underline" {
|
||||||
|
var p: Parser = .{ .params = &[_]u16{ 58, 5, 9 } };
|
||||||
|
try testing.expect(p.next().? == .@"256_underline_color");
|
||||||
|
try testing.expect(p.next() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "sgr: 24-bit bg color" {
|
test "sgr: 24-bit bg color" {
|
||||||
|
@ -577,6 +577,7 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
// SGR - Select Graphic Rendition
|
// SGR - Select Graphic Rendition
|
||||||
'm' => switch (action.intermediates.len) {
|
'm' => switch (action.intermediates.len) {
|
||||||
0 => if (@hasDecl(T, "setAttribute")) {
|
0 => if (@hasDecl(T, "setAttribute")) {
|
||||||
|
// log.info("parse SGR params={any}", .{action.params});
|
||||||
var p: sgr.Parser = .{ .params = action.params, .colon = action.sep == .colon };
|
var p: sgr.Parser = .{ .params = action.params, .colon = action.sep == .colon };
|
||||||
while (p.next()) |attr| {
|
while (p.next()) |attr| {
|
||||||
// log.info("SGR attribute: {}", .{attr});
|
// log.info("SGR attribute: {}", .{attr});
|
||||||
|
Reference in New Issue
Block a user