mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
parse more SGR attrs
This commit is contained in:
@ -280,6 +280,8 @@ pub fn updateCells(self: *Grid, term: Terminal) !void {
|
|||||||
defer y += 1;
|
defer y += 1;
|
||||||
|
|
||||||
for (line) |cell, x| {
|
for (line) |cell, x| {
|
||||||
|
// TODO: inverse
|
||||||
|
|
||||||
// If the cell has a background, we always draw it.
|
// If the cell has a background, we always draw it.
|
||||||
if (cell.bg) |rgb| {
|
if (cell.bg) |rgb| {
|
||||||
self.cells.appendAssumeCapacity(.{
|
self.cells.appendAssumeCapacity(.{
|
||||||
|
@ -20,6 +20,12 @@ pub const Cell = struct {
|
|||||||
fg: ?color.RGB = null,
|
fg: ?color.RGB = null,
|
||||||
bg: ?color.RGB = null,
|
bg: ?color.RGB = null,
|
||||||
|
|
||||||
|
/// On/off attributes that can be set
|
||||||
|
/// TODO: pack it
|
||||||
|
attrs: struct {
|
||||||
|
inverse: u1 = 0,
|
||||||
|
} = .{},
|
||||||
|
|
||||||
/// True if the cell should be skipped for drawing
|
/// True if the cell should be skipped for drawing
|
||||||
pub fn empty(self: Cell) bool {
|
pub fn empty(self: Cell) bool {
|
||||||
return self.char == 0;
|
return self.char == 0;
|
||||||
|
@ -147,6 +147,11 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
|
|||||||
.unset => {
|
.unset => {
|
||||||
self.cursor.pen.fg = null;
|
self.cursor.pen.fg = null;
|
||||||
self.cursor.pen.bg = null;
|
self.cursor.pen.bg = null;
|
||||||
|
self.cursor.pen.attrs = .{};
|
||||||
|
},
|
||||||
|
|
||||||
|
.inverse => {
|
||||||
|
self.cursor.pen.attrs.inverse = 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
.direct_color_fg => |rgb| {
|
.direct_color_fg => |rgb| {
|
||||||
|
@ -15,6 +15,15 @@ pub const Attribute = union(enum) {
|
|||||||
/// Bold the text.
|
/// Bold the text.
|
||||||
bold: void,
|
bold: void,
|
||||||
|
|
||||||
|
/// Underline the text
|
||||||
|
underline: void,
|
||||||
|
|
||||||
|
/// Blink the text
|
||||||
|
blink: void,
|
||||||
|
|
||||||
|
/// Invert fg/bg colors.
|
||||||
|
inverse: void,
|
||||||
|
|
||||||
/// Set foreground color as RGB values.
|
/// Set foreground color as RGB values.
|
||||||
direct_color_fg: RGB,
|
direct_color_fg: RGB,
|
||||||
|
|
||||||
@ -68,6 +77,12 @@ pub const Parser = struct {
|
|||||||
|
|
||||||
1 => return Attribute{ .bold = {} },
|
1 => return Attribute{ .bold = {} },
|
||||||
|
|
||||||
|
4 => return Attribute{ .underline = {} },
|
||||||
|
|
||||||
|
5 => return Attribute{ .blink = {} },
|
||||||
|
|
||||||
|
7 => return Attribute{ .inverse = {} },
|
||||||
|
|
||||||
30...37 => return Attribute{
|
30...37 => return Attribute{
|
||||||
.@"8_fg" = @intToEnum(color.Name, slice[0] - 30),
|
.@"8_fg" = @intToEnum(color.Name, slice[0] - 30),
|
||||||
},
|
},
|
||||||
@ -178,6 +193,11 @@ test "sgr: bold" {
|
|||||||
try testing.expect(v == .bold);
|
try testing.expect(v == .bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "sgr: inverse" {
|
||||||
|
const v = testParse(&[_]u16{7});
|
||||||
|
try testing.expect(v == .inverse);
|
||||||
|
}
|
||||||
|
|
||||||
test "sgr: 8 color" {
|
test "sgr: 8 color" {
|
||||||
var p: Parser = .{ .params = &[_]u16{ 31, 43, 103 } };
|
var p: Parser = .{ .params = &[_]u16{ 31, 43, 103 } };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user