mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
implement animated underline cursor and correct its position
This commit is contained in:
@ -133,6 +133,7 @@ pub fn renderGlyph(
|
|||||||
width,
|
width,
|
||||||
metrics.cursor_height,
|
metrics.cursor_height,
|
||||||
metrics.cursor_thickness,
|
metrics.cursor_thickness,
|
||||||
|
metrics.underline_position,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cursors are drawn at their specified height
|
// Cursors are drawn at their specified height
|
||||||
|
@ -14,6 +14,7 @@ pub fn renderGlyph(
|
|||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
thickness: u32,
|
thickness: u32,
|
||||||
|
underline_pos: u32,
|
||||||
) !font.Glyph {
|
) !font.Glyph {
|
||||||
// Make a canvas of the desired size
|
// Make a canvas of the desired size
|
||||||
var canvas = try font.sprite.Canvas.init(alloc, width, height);
|
var canvas = try font.sprite.Canvas.init(alloc, width, height);
|
||||||
@ -45,7 +46,7 @@ pub fn renderGlyph(
|
|||||||
}, .on),
|
}, .on),
|
||||||
Sprite.cursor_underline => canvas.rect(.{
|
Sprite.cursor_underline => canvas.rect(.{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
.y = height -| thickness,
|
.y = 0,
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = thickness,
|
.height = thickness,
|
||||||
}, .on),
|
}, .on),
|
||||||
@ -61,9 +62,9 @@ pub fn renderGlyph(
|
|||||||
// uniform code. -- In the future code will be introduced to
|
// uniform code. -- In the future code will be introduced to
|
||||||
// auto-crop the canvas so that this isn't needed.
|
// auto-crop the canvas so that this isn't needed.
|
||||||
.width = if (sprite == .cursor_bar) thickness else width,
|
.width = if (sprite == .cursor_bar) thickness else width,
|
||||||
.height = height,
|
.height = if (sprite == .cursor_underline) thickness else height,
|
||||||
.offset_x = 0,
|
.offset_x = 0,
|
||||||
.offset_y = @intCast(height),
|
.offset_y = if (sprite == .cursor_underline) @intCast(height -| underline_pos) else @intCast(height),
|
||||||
.atlas_x = region.x,
|
.atlas_x = region.x,
|
||||||
.atlas_y = region.y,
|
.atlas_y = region.y,
|
||||||
.advance_x = @floatFromInt(width),
|
.advance_x = @floatFromInt(width),
|
||||||
|
Reference in New Issue
Block a user