Fix custom shader cursor uniforms not set for non-block cursors (#7893)

Fixes #7893

Previously, custom shader cursor uniforms were only updated when the
cursor glyph was in the front (block) cursor list. This caused non-block
cursors (such as bar, underline, hollow block, and lock) to be missing
from custom shader effects.

This commit adds a helper to the cell contents struct to retrieve the
current cursor glyph from either the front or back cursor lists, and
updates the renderer to use this helper when setting custom shader
uniforms. As a result, custom shaders now receive correct cursor
information for all supported cursor styles.
This commit is contained in:
ClearAspect
2025-07-10 00:08:37 -04:00
parent d0c5191aef
commit 88736a2ddb
2 changed files with 12 additions and 4 deletions

View File

@ -156,6 +156,17 @@ pub const Contents = struct {
} }
} }
/// Returns the current cursor glyph if present, checking both cursor lists.
pub fn getCursorGlyph(self: *Contents) ?shaderpkg.CellText {
if (self.fg_rows.lists[0].items.len > 0) {
return self.fg_rows.lists[0].items[0];
}
if (self.fg_rows.lists[self.size.rows + 1].items.len > 0) {
return self.fg_rows.lists[self.size.rows + 1].items[0];
}
return null;
}
/// Access a background cell. Prefer this function over direct indexing /// Access a background cell. Prefer this function over direct indexing
/// of `bg_cells` in order to avoid integer size bugs causing overflows. /// of `bg_cells` in order to avoid integer size bugs causing overflows.
pub inline fn bgCell( pub inline fn bgCell(

View File

@ -2218,10 +2218,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
}; };
// Update custom cursor uniforms, if we have a cursor. // Update custom cursor uniforms, if we have a cursor.
if (self.cells.fg_rows.lists[0].items.len > 0) { if (self.cells.getCursorGlyph()) |cursor| {
const cursor: shaderpkg.CellText =
self.cells.fg_rows.lists[0].items[0];
const cursor_width: f32 = @floatFromInt(cursor.glyph_size[0]); const cursor_width: f32 = @floatFromInt(cursor.glyph_size[0]);
const cursor_height: f32 = @floatFromInt(cursor.glyph_size[1]); const cursor_height: f32 = @floatFromInt(cursor.glyph_size[1]);