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