diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 1b340c6ad..bee7327c4 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1397,12 +1397,26 @@ fn addCursor( screen: *terminal.Screen, cursor_style: renderer.CursorStyle, ) ?*const mtl_shaders.Cell { - // Add the cursor - const cell = screen.getCell( - .active, - screen.cursor.y, - screen.cursor.x, - ); + // Add the cursor. We render the cursor over the wide character if + // we're on the wide characer tail. + const cell, const x = cell: { + // The cursor goes over the screen cursor position. + const cell = screen.getCell( + .active, + screen.cursor.y, + screen.cursor.x, + ); + if (!cell.attrs.wide_spacer_tail or screen.cursor.x == 0) + break :cell .{ cell, screen.cursor.x }; + + // If we're part of a wide character, we move the cursor back to + // the actual character. + break :cell .{ screen.getCell( + .active, + screen.cursor.y, + screen.cursor.x - 1, + ), screen.cursor.x - 1 }; + }; const color = self.config.cursor_color orelse terminal.color.RGB{ .r = 0xFF, @@ -1430,7 +1444,7 @@ fn addCursor( self.cells.appendAssumeCapacity(.{ .mode = .fg, .grid_pos = .{ - @as(f32, @floatFromInt(screen.cursor.x)), + @as(f32, @floatFromInt(x)), @as(f32, @floatFromInt(screen.cursor.y)), }, .cell_width = if (cell.attrs.wide) 2 else 1, diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 3ea2cfc30..8bc935559 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -848,12 +848,26 @@ fn addCursor( screen: *terminal.Screen, cursor_style: renderer.CursorStyle, ) ?*const GPUCell { - // Add the cursor - const cell = screen.getCell( - .active, - screen.cursor.y, - screen.cursor.x, - ); + // Add the cursor. We render the cursor over the wide character if + // we're on the wide characer tail. + const cell, const x = cell: { + // The cursor goes over the screen cursor position. + const cell = screen.getCell( + .active, + screen.cursor.y, + screen.cursor.x, + ); + if (!cell.attrs.wide_spacer_tail or screen.cursor.x == 0) + break :cell .{ cell, screen.cursor.x }; + + // If we're part of a wide character, we move the cursor back to + // the actual character. + break :cell .{ screen.getCell( + .active, + screen.cursor.y, + screen.cursor.x - 1, + ), screen.cursor.x - 1 }; + }; const color = self.config.cursor_color orelse terminal.color.RGB{ .r = 0xFF, @@ -880,7 +894,7 @@ fn addCursor( self.cells.appendAssumeCapacity(.{ .mode = .fg, - .grid_col = @intCast(screen.cursor.x), + .grid_col = @intCast(x), .grid_row = @intCast(screen.cursor.y), .grid_width = if (cell.attrs.wide) 2 else 1, .fg_r = color.r,