mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
dashed underlines
This commit is contained in:
@ -17,6 +17,7 @@ pub const Sprite = enum(u32) {
|
||||
underline = start,
|
||||
underline_double = start + 1,
|
||||
underline_dotted = start + 2,
|
||||
underline_dashed = start + 3,
|
||||
|
||||
// Note: we don't currently put the box drawing glyphs in here because
|
||||
// there are a LOT and I'm lazy. What I want to do is spend more time
|
||||
|
@ -86,6 +86,7 @@ const Kind = enum {
|
||||
.underline,
|
||||
.underline_double,
|
||||
.underline_dotted,
|
||||
.underline_dashed,
|
||||
=> .underline,
|
||||
},
|
||||
|
||||
|
@ -70,6 +70,7 @@ const Draw = struct {
|
||||
.underline => self.drawSingle(canvas),
|
||||
.underline_double => self.drawDouble(canvas),
|
||||
.underline_dotted => self.drawDotted(canvas),
|
||||
.underline_dashed => self.drawDashed(canvas),
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +115,21 @@ const Draw = struct {
|
||||
}, .on);
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw a dashed underline.
|
||||
fn drawDashed(self: Draw, canvas: *font.sprite.Canvas) void {
|
||||
const dash_width = self.width / 3 + 1;
|
||||
const dash_count = (self.width / dash_width) + 1;
|
||||
var i: u32 = 0;
|
||||
while (i < dash_count) : (i += 2) {
|
||||
canvas.rect(.{
|
||||
.x = i * dash_width,
|
||||
.y = self.pos,
|
||||
.width = dash_width,
|
||||
.height = self.thickness,
|
||||
}, .on);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
test "single" {
|
||||
|
@ -1010,6 +1010,7 @@ pub fn updateCell(
|
||||
.single => .underline,
|
||||
.double => .underline_double,
|
||||
.dotted => .underline_dotted,
|
||||
.dashed => .underline_dashed,
|
||||
else => .underline,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user