renderer: use proper cell style for cursor-color/text (#9694)
Regression from render state work.pull/9695/head
commit
54370c22ba
|
|
@ -2782,18 +2782,34 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
||||||
|
|
||||||
// Setup our cursor rendering information.
|
// Setup our cursor rendering information.
|
||||||
cursor: {
|
cursor: {
|
||||||
// By default, we don't handle cursor inversion on the shader.
|
// Clear our cursor by default.
|
||||||
self.cells.setCursor(null, null);
|
self.cells.setCursor(null, null);
|
||||||
self.uniforms.cursor_pos = .{
|
self.uniforms.cursor_pos = .{
|
||||||
std.math.maxInt(u16),
|
std.math.maxInt(u16),
|
||||||
std.math.maxInt(u16),
|
std.math.maxInt(u16),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the cursor isn't visible on the viewport, don't show
|
||||||
|
// a cursor. Otherwise, get our cursor cell, because we may
|
||||||
|
// need it for styling.
|
||||||
|
const cursor_vp = state.cursor.viewport orelse break :cursor;
|
||||||
|
const cursor_style: terminal.Style = cursor_style: {
|
||||||
|
const cells = state.row_data.items(.cells);
|
||||||
|
const cell = cells[cursor_vp.y].get(cursor_vp.x);
|
||||||
|
break :cursor_style if (cell.raw.hasStyling())
|
||||||
|
cell.style
|
||||||
|
else
|
||||||
|
.{};
|
||||||
|
};
|
||||||
|
|
||||||
// If we have preedit text, we don't setup a cursor
|
// If we have preedit text, we don't setup a cursor
|
||||||
if (preedit != null) break :cursor;
|
if (preedit != null) break :cursor;
|
||||||
|
|
||||||
// Prepare the cursor cell contents.
|
// If there isn't a cursor visual style requested then
|
||||||
|
// we don't render a cursor.
|
||||||
const style = cursor_style_ orelse break :cursor;
|
const style = cursor_style_ orelse break :cursor;
|
||||||
|
|
||||||
|
// Determine the cursor color.
|
||||||
const cursor_color = cursor_color: {
|
const cursor_color = cursor_color: {
|
||||||
// If an explicit cursor color was set by OSC 12, use that.
|
// If an explicit cursor color was set by OSC 12, use that.
|
||||||
if (state.colors.cursor) |v| break :cursor_color v;
|
if (state.colors.cursor) |v| break :cursor_color v;
|
||||||
|
|
@ -2801,24 +2817,30 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
||||||
// Use our configured color if specified
|
// Use our configured color if specified
|
||||||
if (self.config.cursor_color) |v| switch (v) {
|
if (self.config.cursor_color) |v| switch (v) {
|
||||||
.color => |color| break :cursor_color color.toTerminalRGB(),
|
.color => |color| break :cursor_color color.toTerminalRGB(),
|
||||||
|
|
||||||
inline .@"cell-foreground",
|
inline .@"cell-foreground",
|
||||||
.@"cell-background",
|
.@"cell-background",
|
||||||
=> |_, tag| {
|
=> |_, tag| {
|
||||||
const sty: terminal.Style = state.cursor.style;
|
const fg_style = cursor_style.fg(.{
|
||||||
const fg_style = sty.fg(.{
|
|
||||||
.default = state.colors.foreground,
|
.default = state.colors.foreground,
|
||||||
.palette = &state.colors.palette,
|
.palette = &state.colors.palette,
|
||||||
.bold = self.config.bold_color,
|
.bold = self.config.bold_color,
|
||||||
});
|
});
|
||||||
const bg_style = sty.bg(
|
const bg_style = cursor_style.bg(
|
||||||
&state.cursor.cell,
|
&state.cursor.cell,
|
||||||
&state.colors.palette,
|
&state.colors.palette,
|
||||||
) orelse state.colors.background;
|
) orelse state.colors.background;
|
||||||
|
|
||||||
break :cursor_color switch (tag) {
|
break :cursor_color switch (tag) {
|
||||||
.color => unreachable,
|
.color => unreachable,
|
||||||
.@"cell-foreground" => if (sty.flags.inverse) bg_style else fg_style,
|
.@"cell-foreground" => if (cursor_style.flags.inverse)
|
||||||
.@"cell-background" => if (sty.flags.inverse) fg_style else bg_style,
|
bg_style
|
||||||
|
else
|
||||||
|
fg_style,
|
||||||
|
.@"cell-background" => if (cursor_style.flags.inverse)
|
||||||
|
fg_style
|
||||||
|
else
|
||||||
|
bg_style,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -2833,9 +2855,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the cursor is visible then we set our uniforms.
|
// If the cursor is visible then we set our uniforms.
|
||||||
if (style == .block) cursor_uniforms: {
|
if (style == .block) {
|
||||||
const cursor_vp = state.cursor.viewport orelse
|
|
||||||
break :cursor_uniforms;
|
|
||||||
const wide = state.cursor.cell.wide;
|
const wide = state.cursor.cell.wide;
|
||||||
|
|
||||||
self.uniforms.cursor_pos = .{
|
self.uniforms.cursor_pos = .{
|
||||||
|
|
@ -2862,21 +2882,26 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
||||||
break :blk txt.color.toTerminalRGB();
|
break :blk txt.color.toTerminalRGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
const sty = state.cursor.style;
|
const fg_style = cursor_style.fg(.{
|
||||||
const fg_style = sty.fg(.{
|
|
||||||
.default = state.colors.foreground,
|
.default = state.colors.foreground,
|
||||||
.palette = &state.colors.palette,
|
.palette = &state.colors.palette,
|
||||||
.bold = self.config.bold_color,
|
.bold = self.config.bold_color,
|
||||||
});
|
});
|
||||||
const bg_style = sty.bg(
|
const bg_style = cursor_style.bg(
|
||||||
&state.cursor.cell,
|
&state.cursor.cell,
|
||||||
&state.colors.palette,
|
&state.colors.palette,
|
||||||
) orelse state.colors.background;
|
) orelse state.colors.background;
|
||||||
|
|
||||||
break :blk switch (txt) {
|
break :blk switch (txt) {
|
||||||
// If the cell is reversed, use the opposite cell color instead.
|
// If the cell is reversed, use the opposite cell color instead.
|
||||||
.@"cell-foreground" => if (sty.flags.inverse) bg_style else fg_style,
|
.@"cell-foreground" => if (cursor_style.flags.inverse)
|
||||||
.@"cell-background" => if (sty.flags.inverse) fg_style else bg_style,
|
bg_style
|
||||||
|
else
|
||||||
|
fg_style,
|
||||||
|
.@"cell-background" => if (cursor_style.flags.inverse)
|
||||||
|
fg_style
|
||||||
|
else
|
||||||
|
bg_style,
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
} else state.colors.background;
|
} else state.colors.background;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue