refactor: lots more writergate fixes - first successful build

This commit is contained in:
CJ van den Berg 2025-09-25 22:01:29 +02:00
parent 5094aa8c85
commit bf0d4402ea
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
48 changed files with 404 additions and 413 deletions

View file

@ -69,20 +69,22 @@ pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts:
const self = try allocator.create(Self);
errdefer allocator.destroy(self);
self.* = .{
.allocator = allocator,
.parent = parent,
.plane = n,
.opts = opts,
.label = std.ArrayList(u8).init(allocator),
.text = std.ArrayList(u8).init(allocator),
.label = .empty,
.text = .empty,
.icon_width = @intCast(if (tui.config().show_fileicons) if (opts.icon) |icon| n.egc_chunk_width(icon, 0, 1) else 0 else 0),
};
try self.label.appendSlice(self.opts.label);
try self.label.appendSlice(self.allocator, self.opts.label);
self.opts.label = self.label.items;
return Widget.to(self);
}
pub fn State(ctx_type: type) type {
return struct {
allocator: std.mem.Allocator,
parent: Plane,
plane: Plane,
active: bool = false,
@ -97,8 +99,8 @@ pub fn State(ctx_type: type) type {
pub const Context = ctx_type;
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
self.text.deinit();
self.label.deinit();
self.text.deinit(self.allocator);
self.label.deinit(self.allocator);
self.plane.deinit();
allocator.destroy(self);
}