mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 19:26:09 +03:00
use enum for underline styles
This commit is contained in:
@ -911,7 +911,7 @@ pub fn updateCell(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell.attrs.underline) {
|
if (cell.attrs.underline != .none) {
|
||||||
self.cells.appendAssumeCapacity(.{
|
self.cells.appendAssumeCapacity(.{
|
||||||
.mode = .underline,
|
.mode = .underline,
|
||||||
.grid_pos = .{ @intToFloat(f32, x), @intToFloat(f32, y) },
|
.grid_pos = .{ @intToFloat(f32, x), @intToFloat(f32, y) },
|
||||||
|
@ -928,7 +928,7 @@ pub fn updateCell(
|
|||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
if (colors.bg != null) i += 1;
|
if (colors.bg != null) i += 1;
|
||||||
if (!cell.empty()) 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;
|
if (cell.attrs.strikethrough) i += 1;
|
||||||
break :needed i;
|
break :needed i;
|
||||||
};
|
};
|
||||||
@ -1002,7 +1002,7 @@ pub fn updateCell(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell.attrs.underline) {
|
if (cell.attrs.underline != .none) {
|
||||||
self.cells.appendAssumeCapacity(.{
|
self.cells.appendAssumeCapacity(.{
|
||||||
.mode = .underline,
|
.mode = .underline,
|
||||||
.grid_col = @intCast(u16, x),
|
.grid_col = @intCast(u16, x),
|
||||||
|
@ -56,6 +56,7 @@ const Allocator = std.mem.Allocator;
|
|||||||
|
|
||||||
const utf8proc = @import("utf8proc");
|
const utf8proc = @import("utf8proc");
|
||||||
const trace = @import("tracy").trace;
|
const trace = @import("tracy").trace;
|
||||||
|
const sgr = @import("sgr.zig");
|
||||||
const color = @import("color.zig");
|
const color = @import("color.zig");
|
||||||
const point = @import("point.zig");
|
const point = @import("point.zig");
|
||||||
const CircBuf = @import("circ_buf.zig").CircBuf;
|
const CircBuf = @import("circ_buf.zig").CircBuf;
|
||||||
@ -167,10 +168,10 @@ pub const Cell = struct {
|
|||||||
bold: bool = false,
|
bold: bool = false,
|
||||||
italic: bool = false,
|
italic: bool = false,
|
||||||
faint: bool = false,
|
faint: bool = false,
|
||||||
underline: bool = false,
|
|
||||||
blink: bool = false,
|
blink: bool = false,
|
||||||
inverse: bool = false,
|
inverse: bool = false,
|
||||||
strikethrough: bool = false,
|
strikethrough: bool = false,
|
||||||
|
underline: sgr.Attribute.Underline = .none,
|
||||||
|
|
||||||
/// True if this is a wide character. This char takes up
|
/// True if this is a wide character. This char takes up
|
||||||
/// two cells. The following cell ALWAYS is a space.
|
/// two cells. The following cell ALWAYS is a space.
|
||||||
@ -241,7 +242,7 @@ pub const Cell = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test {
|
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));
|
try std.testing.expectEqual(12, @sizeOf(Cell));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -379,12 +379,12 @@ pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
|
|||||||
self.screen.cursor.pen.attrs.faint = true;
|
self.screen.cursor.pen.attrs.faint = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
.underline => {
|
.underline => |v| {
|
||||||
self.screen.cursor.pen.attrs.underline = true;
|
self.screen.cursor.pen.attrs.underline = v;
|
||||||
},
|
},
|
||||||
|
|
||||||
.reset_underline => {
|
.reset_underline => {
|
||||||
self.screen.cursor.pen.attrs.underline = false;
|
self.screen.cursor.pen.attrs.underline = .none;
|
||||||
},
|
},
|
||||||
|
|
||||||
.blink => {
|
.blink => {
|
||||||
|
@ -31,7 +31,7 @@ pub const Attribute = union(enum) {
|
|||||||
faint: void,
|
faint: void,
|
||||||
|
|
||||||
/// Underline the text
|
/// Underline the text
|
||||||
underline: void,
|
underline: Underline,
|
||||||
reset_underline: void,
|
reset_underline: void,
|
||||||
|
|
||||||
/// Blink the text
|
/// Blink the text
|
||||||
@ -75,6 +75,15 @@ pub const Attribute = union(enum) {
|
|||||||
g: u8,
|
g: u8,
|
||||||
b: 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.
|
/// Parser parses the attributes from a list of SGR parameters.
|
||||||
@ -107,7 +116,7 @@ pub const Parser = struct {
|
|||||||
|
|
||||||
3 => return Attribute{ .italic = {} },
|
3 => return Attribute{ .italic = {} },
|
||||||
|
|
||||||
4 => return Attribute{ .underline = {} },
|
4 => return Attribute{ .underline = .single },
|
||||||
|
|
||||||
5 => return Attribute{ .blink = {} },
|
5 => return Attribute{ .blink = {} },
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user