mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
rename setToDefault
to init
This commit is contained in:
@ -262,8 +262,8 @@ pub fn parseIntoField(
|
||||
if (value) |v| default: {
|
||||
if (v.len != 0) break :default;
|
||||
// Set default value if possible.
|
||||
if (canHaveDecls and @hasDecl(Field, "setToDefault")) {
|
||||
try @field(dst, field.name).setToDefault(alloc);
|
||||
if (canHaveDecls and @hasDecl(Field, "init")) {
|
||||
try @field(dst, field.name).init(alloc);
|
||||
return;
|
||||
}
|
||||
const raw = field.default_value orelse break :default;
|
||||
@ -767,7 +767,7 @@ test "parseIntoField: ignore underscore-prefixed fields" {
|
||||
try testing.expectEqualStrings("12", data._a);
|
||||
}
|
||||
|
||||
test "parseIntoField: struct with default func" {
|
||||
test "parseIntoField: struct with init func" {
|
||||
const testing = std.testing;
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
@ -779,7 +779,7 @@ test "parseIntoField: struct with default func" {
|
||||
|
||||
v: []const u8,
|
||||
|
||||
pub fn setToDefault(self: *Self, _alloc: Allocator) !void {
|
||||
pub fn init(self: *Self, _alloc: Allocator) !void {
|
||||
_ = _alloc;
|
||||
self.v = "HELLO!";
|
||||
}
|
||||
|
@ -2373,7 +2373,7 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
const alloc = result._arena.?.allocator();
|
||||
|
||||
// Add our default keybindings
|
||||
try result.keybind.setToDefault(alloc);
|
||||
try result.keybind.init(alloc);
|
||||
|
||||
// Add our default link for URL detection
|
||||
try result.link.links.append(alloc, .{
|
||||
@ -4492,7 +4492,7 @@ pub const RepeatableFontVariation = struct {
|
||||
pub const Keybinds = struct {
|
||||
set: inputpkg.Binding.Set = .{},
|
||||
|
||||
pub fn setToDefault(self: *Keybinds, alloc: Allocator) !void {
|
||||
pub fn init(self: *Keybinds, alloc: Allocator) !void {
|
||||
// We don't clear the memory because it's in the arena and unlikely
|
||||
// to be free-able anyways (since arenas can only clear the last
|
||||
// allocated value). This isn't a memory leak because the arena
|
||||
@ -5131,7 +5131,7 @@ pub const Keybinds = struct {
|
||||
// Check for special values
|
||||
if (value.len == 0) {
|
||||
log.info("config has 'keybind =', using default keybinds", .{});
|
||||
try self.setToDefault(alloc);
|
||||
try self.init(alloc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user