From 88736a2ddb6ab4b0f69d569201248728d6099f14 Mon Sep 17 00:00:00 2001 From: ClearAspect Date: Thu, 10 Jul 2025 00:08:37 -0400 Subject: [PATCH 1/2] 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. --- src/renderer/cell.zig | 11 +++++++++++ src/renderer/generic.zig | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index 43d744176..b8b218d99 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -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 /// of `bg_cells` in order to avoid integer size bugs causing overflows. pub inline fn bgCell( diff --git a/src/renderer/generic.zig b/src/renderer/generic.zig index 3965d302a..2374ec1b0 100644 --- a/src/renderer/generic.zig +++ b/src/renderer/generic.zig @@ -2218,10 +2218,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { }; // Update custom cursor uniforms, if we have a cursor. - if (self.cells.fg_rows.lists[0].items.len > 0) { - const cursor: shaderpkg.CellText = - self.cells.fg_rows.lists[0].items[0]; - + if (self.cells.getCursorGlyph()) |cursor| { const cursor_width: f32 = @floatFromInt(cursor.glyph_size[0]); const cursor_height: f32 = @floatFromInt(cursor.glyph_size[1]); From 36a3a3ffa42f829629f19934be05b1c97d741c8b Mon Sep 17 00:00:00 2001 From: ClearAspect Date: Thu, 10 Jul 2025 01:48:44 -0400 Subject: [PATCH 2/2] Add tests for getCursorGlyph() helper function --- src/renderer/cell.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index b8b218d99..b1ce4523c 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -361,14 +361,17 @@ test Contents { }; c.setCursor(cursor_cell, .block); try testing.expectEqual(cursor_cell, c.fg_rows.lists[0].items[0]); + try testing.expectEqual(cursor_cell, c.getCursorGlyph().?); // And remove it. c.setCursor(null, null); try testing.expectEqual(0, c.fg_rows.lists[0].items.len); + try testing.expect(c.getCursorGlyph() == null); // Add a hollow cursor. c.setCursor(cursor_cell, .block_hollow); try testing.expectEqual(cursor_cell, c.fg_rows.lists[rows + 1].items[0]); + try testing.expectEqual(cursor_cell, c.getCursorGlyph().?); } test "Contents clear retains other content" {