Skip to content

Commit

Permalink
renderer: respect reverse with cursor-invert-fg-bg
Browse files Browse the repository at this point in the history
  • Loading branch information
gpanders committed Jan 7, 2025
1 parent 0065aae commit dfdff1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/renderer/Metal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2650,8 +2650,13 @@ fn rebuildCells(
const style = cursor_style_ orelse break :cursor;
const cursor_color = self.cursor_color orelse self.default_cursor_color orelse color: {
if (self.cursor_invert) {
// Use the foreground color from the cell under the cursor, if any.
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
break :color sty.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color;
break :color (if (sty.flags.inverse)
// If the cell is reversed, use background color instead.
sty.bg(screen.cursor.page_cell, color_palette)
else
sty.fg(color_palette, self.config.bold_is_bright)) orelse self.foreground_color orelse self.default_foreground_color;
} else {
break :color self.foreground_color orelse self.default_foreground_color;
}
Expand Down Expand Up @@ -2680,8 +2685,13 @@ fn rebuildCells(
};

const uniform_color = if (self.cursor_invert) blk: {
// Use the background color from the cell under the cursor, if any.
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
break :blk sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color;
break :blk (if (sty.flags.inverse)
// If the cell is reversed, use foreground color instead.
sty.fg(color_palette, self.config.bold_is_bright)
else
sty.bg(screen.cursor.page_cell, color_palette)) orelse self.background_color orelse self.default_background_color;
} else if (self.config.cursor_text) |txt|
txt
else
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/OpenGL.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1737,8 +1737,13 @@ pub fn rebuildCells(

const cursor_color = self.cursor_color orelse self.default_cursor_color orelse color: {
if (self.cursor_invert) {
// Use the foreground color from the cell under the cursor, if any.
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
break :color sty.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color;
break :color (if (sty.flags.inverse)
// If the cell is reversed, use background color instead.
sty.bg(screen.cursor.page_cell, color_palette)
else
sty.fg(color_palette, self.config.bold_is_bright)) orelse self.foreground_color orelse self.default_foreground_color;
} else {
break :color self.foreground_color orelse self.default_foreground_color;
}
Expand All @@ -1748,8 +1753,13 @@ pub fn rebuildCells(
for (cursor_cells.items) |*cell| {
if (cell.mode.isFg() and cell.mode != .fg_color) {
const cell_color = if (self.cursor_invert) blk: {
// Use the background color from the cell under the cursor, if any.
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
break :blk sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color;
break :blk (if (sty.flags.inverse)
// If the cell is reversed, use foreground color instead.
sty.fg(color_palette, self.config.bold_is_bright)
else
sty.bg(screen.cursor.page_cell, color_palette)) orelse self.background_color orelse self.default_background_color;
} else if (self.config.cursor_text) |txt|
txt
else
Expand Down

0 comments on commit dfdff1c

Please sign in to comment.