renderer(metal): set defaults for cell mode enum

To reduce code duplication and bring it more in line with the OpenGL
equivalent.
This commit is contained in:
Leah Amelia Chen
2024-09-01 21:20:37 +02:00
parent 99742879c2
commit 4834c706db
2 changed files with 10 additions and 45 deletions

View File

@ -2555,14 +2555,7 @@ fn updateCell(
break :glyph; break :glyph;
} }
var mode: mtl_shaders.CellText.Mode = .{ var mode: mtl_shaders.CellText.Mode = .{ .fg = true };
.fg = true,
.fg_constrained = false,
.fg_color = false,
.cursor = false,
.fg_powerline = false,
.fg_blink = false,
};
switch (try fgMode( switch (try fgMode(
render.presentation, render.presentation,
@ -2613,14 +2606,7 @@ fn updateCell(
const color = style.underlineColor(palette) orelse colors.fg; const color = style.underlineColor(palette) orelse colors.fg;
try self.cells.add(self.alloc, .underline, .{ try self.cells.add(self.alloc, .underline, .{
.mode = .{ .mode = .{ .fg = true },
.fg = true,
.fg_constrained = false,
.fg_color = false,
.cursor = false,
.fg_powerline = false,
.fg_blink = false,
},
.grid_pos = .{ @intCast(coord.x), @intCast(coord.y) }, .grid_pos = .{ @intCast(coord.x), @intCast(coord.y) },
.constraint_width = cell.gridWidth(), .constraint_width = cell.gridWidth(),
.color = .{ color.r, color.g, color.b, alpha }, .color = .{ color.r, color.g, color.b, alpha },
@ -2645,14 +2631,7 @@ fn updateCell(
); );
try self.cells.add(self.alloc, .strikethrough, .{ try self.cells.add(self.alloc, .strikethrough, .{
.mode = .{ .mode = .{ .fg = true },
.fg = true,
.fg_constrained = false,
.fg_color = false,
.cursor = false,
.fg_powerline = false,
.fg_blink = false,
},
.grid_pos = .{ @intCast(coord.x), @intCast(coord.y) }, .grid_pos = .{ @intCast(coord.x), @intCast(coord.y) },
.constraint_width = cell.gridWidth(), .constraint_width = cell.gridWidth(),
.color = .{ colors.fg.r, colors.fg.g, colors.fg.b, alpha }, .color = .{ colors.fg.r, colors.fg.g, colors.fg.b, alpha },
@ -2714,14 +2693,7 @@ fn addCursor(
}; };
self.cells.setCursor(.{ self.cells.setCursor(.{
.mode = .{ .mode = .{ .fg = false, .cursor = true },
.fg = false,
.fg_constrained = false,
.fg_color = false,
.cursor = true,
.fg_powerline = false,
.fg_blink = false,
},
.grid_pos = .{ x, screen.cursor.y }, .grid_pos = .{ x, screen.cursor.y },
.color = .{ cursor_color.r, cursor_color.g, cursor_color.b, alpha }, .color = .{ cursor_color.r, cursor_color.g, cursor_color.b, alpha },
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y }, .glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
@ -2770,14 +2742,7 @@ fn addPreeditCell(
// Add our text // Add our text
try self.cells.add(self.alloc, .text, .{ try self.cells.add(self.alloc, .text, .{
.mode = .{ .mode = .{ .fg = true },
.fg = true,
.fg_constrained = false,
.fg_color = false,
.cursor = false,
.fg_powerline = false,
.fg_blink = false,
},
.grid_pos = .{ @intCast(coord.x), @intCast(coord.y) }, .grid_pos = .{ @intCast(coord.x), @intCast(coord.y) },
.color = .{ fg.r, fg.g, fg.b, 255 }, .color = .{ fg.r, fg.g, fg.b, 255 },
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y }, .glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },

View File

@ -329,11 +329,11 @@ pub const CellText = extern struct {
pub const Mode = packed struct(u8) { pub const Mode = packed struct(u8) {
fg: bool, fg: bool,
fg_constrained: bool, fg_constrained: bool = false,
fg_color: bool, fg_color: bool = false,
cursor: bool, cursor: bool = false,
fg_powerline: bool, fg_powerline: bool = false,
fg_blink: bool, fg_blink: bool = false,
_padding: u2 = 0, _padding: u2 = 0,
}; };