mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
Use comptime for eql() to ensure Style struct coverage.
This commit is contained in:
@@ -84,11 +84,23 @@ pub const Style = struct {
|
||||
}
|
||||
|
||||
/// True if the style is equal to another style.
|
||||
/// For performance do direct comparisons first.
|
||||
pub fn eql(self: Style, other: Style) bool {
|
||||
return self.flags == other.flags and
|
||||
std.meta.eql(self.fg_color, other.fg_color) and
|
||||
std.meta.eql(self.bg_color, other.bg_color) and
|
||||
std.meta.eql(self.underline_color, other.underline_color);
|
||||
inline for (comptime std.meta.fields(Style)) |field| {
|
||||
if (comptime std.meta.hasUniqueRepresentation(field.type)) {
|
||||
if (@field(self, field.name) != @field(other, field.name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
inline for (comptime std.meta.fields(Style)) |field| {
|
||||
if (comptime !std.meta.hasUniqueRepresentation(field.type)) {
|
||||
if (!std.meta.eql(@field(self, field.name), @field(other, field.name))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Returns the bg color for a cell with this style given the cell
|
||||
|
Reference in New Issue
Block a user