mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
@ -4610,17 +4610,33 @@ pub const RepeatableLink = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Deep copy of the struct. Required by Config.
|
/// Deep copy of the struct. Required by Config.
|
||||||
pub fn clone(self: *const Self, alloc: Allocator) error{}!Self {
|
pub fn clone(
|
||||||
_ = self;
|
self: *const Self,
|
||||||
_ = alloc;
|
alloc: Allocator,
|
||||||
return .{};
|
) Allocator.Error!Self {
|
||||||
|
// Note: we don't do any errdefers below since the allocation
|
||||||
|
// is expected to be arena allocated.
|
||||||
|
|
||||||
|
var list = try std.ArrayListUnmanaged(inputpkg.Link).initCapacity(
|
||||||
|
alloc,
|
||||||
|
self.links.items.len,
|
||||||
|
);
|
||||||
|
for (self.links.items) |item| {
|
||||||
|
const copy = try item.clone(alloc);
|
||||||
|
list.appendAssumeCapacity(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return .{ .links = list };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compare if two of our value are requal. Required by Config.
|
/// Compare if two of our value are requal. Required by Config.
|
||||||
pub fn equal(self: Self, other: Self) bool {
|
pub fn equal(self: Self, other: Self) bool {
|
||||||
_ = self;
|
const itemsA = self.links.items;
|
||||||
_ = other;
|
const itemsB = other.links.items;
|
||||||
return true;
|
if (itemsA.len != itemsB.len) return false;
|
||||||
|
for (itemsA, itemsB) |*a, *b| {
|
||||||
|
if (!a.equal(b)) return false;
|
||||||
|
} else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used by Formatter
|
/// Used by Formatter
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
//! action types.
|
//! action types.
|
||||||
const Link = @This();
|
const Link = @This();
|
||||||
|
|
||||||
|
const std = @import("std");
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
const oni = @import("oniguruma");
|
const oni = @import("oniguruma");
|
||||||
const Mods = @import("key.zig").Mods;
|
const Mods = @import("key.zig").Mods;
|
||||||
|
|
||||||
@ -59,3 +61,19 @@ pub fn oniRegex(self: *const Link) !oni.Regex {
|
|||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deep clone the link.
|
||||||
|
pub fn clone(self: *const Link, alloc: Allocator) Allocator.Error!Link {
|
||||||
|
return .{
|
||||||
|
.regex = try alloc.dupe(u8, self.regex),
|
||||||
|
.action = self.action,
|
||||||
|
.highlight = self.highlight,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if two links are equal.
|
||||||
|
pub fn equal(self: *const Link, other: *const Link) bool {
|
||||||
|
return std.meta.eql(self.action, other.action) and
|
||||||
|
std.meta.eql(self.highlight, other.highlight) and
|
||||||
|
std.mem.eql(u8, self.regex, other.regex);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user