refactor: change a -> allocator

This commit is contained in:
CJ van den Berg 2024-09-02 14:31:49 +02:00
parent ad58b1868d
commit 7b812d73ea
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
63 changed files with 896 additions and 896 deletions

View file

@ -18,16 +18,16 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
return .{
.handler = EventHandler.to_owned(self),
@ -39,7 +39,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,17 +17,17 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -42,7 +42,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,18 +17,18 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
count: usize = 0,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -44,7 +44,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,18 +17,18 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
count: usize = 0,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -44,7 +44,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -12,14 +12,14 @@ const EventHandler = @import("../../EventHandler.zig");
const Self = @This();
a: std.mem.Allocator,
allocator: std.mem.Allocator,
f: usize = 0,
leader: ?struct { keypress: u32, modifiers: u32 } = null,
pub fn create(a: std.mem.Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.allocator = allocator,
};
return .{
.handler = EventHandler.to_owned(self),
@ -30,7 +30,7 @@ pub fn create(a: std.mem.Allocator) !tui.Mode {
}
pub fn deinit(self: *Self) void {
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,17 +17,17 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -42,7 +42,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,18 +17,18 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
count: usize = 0,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -44,7 +44,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -17,18 +17,18 @@ const eql = @import("std").mem.eql;
const Self = @This();
const input_buffer_size = 1024;
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_cmd: []const u8 = "",
leader: ?struct { keypress: u32, modifiers: u32 } = null,
count: usize = 0,
commands: Commands = undefined,
pub fn create(a: Allocator) !tui.Mode {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator) !tui.Mode {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = try ArrayList(u8).initCapacity(a, input_buffer_size),
.allocator = allocator,
.input = try ArrayList(u8).initCapacity(allocator, input_buffer_size),
};
try self.commands.init(self);
return .{
@ -44,7 +44,7 @@ pub fn create(a: Allocator) !tui.Mode {
pub fn deinit(self: *Self) void {
self.commands.deinit();
self.input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {

View file

@ -19,7 +19,7 @@ const max_complete_paths = 1024;
pub fn Create(options: type) type {
return struct {
a: std.mem.Allocator,
allocator: std.mem.Allocator,
file_path: std.ArrayList(u8),
query: std.ArrayList(u8),
match: std.ArrayList(u8),
@ -34,14 +34,14 @@ pub fn Create(options: type) type {
type: enum { dir, file, link },
};
pub fn create(a: std.mem.Allocator, _: command.Context) !*Self {
const self: *Self = try a.create(Self);
pub fn create(allocator: std.mem.Allocator, _: command.Context) !*Self {
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.file_path = std.ArrayList(u8).init(a),
.query = std.ArrayList(u8).init(a),
.match = std.ArrayList(u8).init(a),
.entries = std.ArrayList(Entry).init(a),
.allocator = allocator,
.file_path = std.ArrayList(u8).init(allocator),
.query = std.ArrayList(u8).init(allocator),
.match = std.ArrayList(u8).init(allocator),
.entries = std.ArrayList(Entry).init(allocator),
};
try tui.current().message_filters.add(MessageFilter.bind(self, receive_path_entry));
try options.load_entries(self);
@ -57,7 +57,7 @@ pub fn Create(options: type) type {
self.match.deinit();
self.query.deinit();
self.file_path.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {
@ -171,7 +171,7 @@ pub fn Create(options: type) type {
}
fn clear_entries(self: *Self) void {
for (self.entries.items) |entry| self.a.free(entry.name);
for (self.entries.items) |entry| self.allocator.free(entry.name);
self.entries.clearRetainingCapacity();
}
@ -246,11 +246,11 @@ pub fn Create(options: type) type {
var path: []const u8 = undefined;
var file_name: []const u8 = undefined;
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&path), "DIR", tp.extract(&file_name) })) {
(try self.entries.addOne()).* = .{ .name = try self.a.dupe(u8, file_name), .type = .dir };
(try self.entries.addOne()).* = .{ .name = try self.allocator.dupe(u8, file_name), .type = .dir };
} else if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&path), "LINK", tp.extract(&file_name) })) {
(try self.entries.addOne()).* = .{ .name = try self.a.dupe(u8, file_name), .type = .link };
(try self.entries.addOne()).* = .{ .name = try self.allocator.dupe(u8, file_name), .type = .link };
} else if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&path), "FILE", tp.extract(&file_name) })) {
(try self.entries.addOne()).* = .{ .name = try self.a.dupe(u8, file_name), .type = .file };
(try self.entries.addOne()).* = .{ .name = try self.allocator.dupe(u8, file_name), .type = .file };
} else {
log.logger("file_browser").err("receive", tp.unexpected(m));
}

View file

@ -18,7 +18,7 @@ const ArrayList = @import("std").ArrayList;
const Self = @This();
a: Allocator,
allocator: Allocator,
input: ArrayList(u8),
last_input: ArrayList(u8),
start_view: ed.View,
@ -26,20 +26,20 @@ start_cursor: ed.Cursor,
editor: *ed.Editor,
history_pos: ?usize = null,
pub fn create(a: Allocator, _: command.Context) !*Self {
pub fn create(allocator: Allocator, _: command.Context) !*Self {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
const self: *Self = try a.create(Self);
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.input = ArrayList(u8).init(a),
.last_input = ArrayList(u8).init(a),
.allocator = allocator,
.input = ArrayList(u8).init(allocator),
.last_input = ArrayList(u8).init(allocator),
.start_view = editor.view,
.start_cursor = editor.get_primary().cursor,
.editor = editor,
};
if (editor.get_primary().selection) |sel| ret: {
const text = editor.get_selection(sel, self.a) catch break :ret;
defer self.a.free(text);
const text = editor.get_selection(sel, self.allocator) catch break :ret;
defer self.allocator.free(text);
try self.input.appendSlice(text);
}
return self;
@ -50,7 +50,7 @@ pub fn create(a: Allocator, _: command.Context) !*Self {
pub fn deinit(self: *Self) void {
self.input.deinit();
self.last_input.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {
@ -210,7 +210,7 @@ fn find_history_prev(self: *Self) void {
} else {
self.history_pos = history.items.len - 1;
if (self.input.items.len > 0)
self.editor.push_find_history(self.editor.a.dupe(u8, self.input.items) catch return);
self.editor.push_find_history(self.editor.allocator.dupe(u8, self.input.items) catch return);
if (eql(u8, history.items[self.history_pos.?], self.input.items) and self.history_pos.? > 0)
self.history_pos = self.history_pos.? - 1;
}

View file

@ -17,23 +17,23 @@ const eql = @import("std").mem.eql;
const Self = @This();
a: Allocator,
allocator: Allocator,
buf: [1024]u8 = undefined,
input: []u8 = "",
last_buf: [1024]u8 = undefined,
last_input: []u8 = "",
mainview: *mainview,
pub fn create(a: Allocator, _: command.Context) !*Self {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator, _: command.Context) !*Self {
const self: *Self = try allocator.create(Self);
if (tui.current().mainview.dynamic_cast(mainview)) |mv| {
self.* = .{
.a = a,
.allocator = allocator,
.mainview = mv,
};
if (mv.get_editor()) |editor| if (editor.get_primary().selection) |sel| ret: {
const text = editor.get_selection(sel, self.a) catch break :ret;
defer self.a.free(text);
const text = editor.get_selection(sel, self.allocator) catch break :ret;
defer self.allocator.free(text);
@memcpy(self.buf[0..text.len], text);
self.input = self.buf[0..text.len];
};
@ -43,7 +43,7 @@ pub fn create(a: Allocator, _: command.Context) !*Self {
}
pub fn deinit(self: *Self) void {
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {

View file

@ -16,16 +16,16 @@ const fmt = @import("std").fmt;
const Self = @This();
a: Allocator,
allocator: Allocator,
buf: [30]u8 = undefined,
input: ?usize = null,
start: usize,
pub fn create(a: Allocator, _: command.Context) !*Self {
const self: *Self = try a.create(Self);
pub fn create(allocator: Allocator, _: command.Context) !*Self {
const self: *Self = try allocator.create(Self);
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
self.* = .{
.a = a,
.allocator = allocator,
.start = editor.get_primary().cursor.row + 1,
};
return self;
@ -34,7 +34,7 @@ pub fn create(a: Allocator, _: command.Context) !*Self {
}
pub fn deinit(self: *Self) void {
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {

View file

@ -17,7 +17,7 @@ const fmt = @import("std").fmt;
const Self = @This();
a: Allocator,
allocator: Allocator,
key: [6]u8 = undefined,
direction: Direction,
operation: Operation,
@ -32,13 +32,13 @@ const Operation = enum {
select,
};
pub fn create(a: Allocator, ctx: command.Context) !*Self {
pub fn create(allocator: Allocator, ctx: command.Context) !*Self {
var right: bool = true;
const select = if (tui.current().mainview.dynamic_cast(mainview)) |mv| if (mv.get_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false else false;
_ = ctx.args.match(.{tp.extract(&right)}) catch return error.NotFound;
const self: *Self = try a.create(Self);
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.allocator = allocator,
.direction = if (right) .right else .left,
.operation = if (select) .select else .move,
};
@ -46,7 +46,7 @@ pub fn create(a: Allocator, ctx: command.Context) !*Self {
}
pub fn deinit(self: *Self) void {
self.a.destroy(self);
self.allocator.destroy(self);
}
pub fn handler(self: *Self) EventHandler {

View file

@ -26,8 +26,8 @@ pub fn load_entries(self: *Type) !void {
if (std.mem.lastIndexOf(u8, old_path, "/")) |pos|
try self.file_path.appendSlice(old_path[0 .. pos + 1]);
if (editor.get_primary().selection) |sel| ret: {
const text = editor.get_selection(sel, self.a) catch break :ret;
defer self.a.free(text);
const text = editor.get_selection(sel, self.allocator) catch break :ret;
defer self.allocator.free(text);
if (!(text.len > 2 and std.mem.eql(u8, text[0..2], "..")))
self.file_path.clearRetainingCapacity();
try self.file_path.appendSlice(text);

View file

@ -23,8 +23,8 @@ pub fn load_entries(self: *Type) !void {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
try self.file_path.appendSlice(editor.file_path orelse "");
if (editor.get_primary().selection) |sel| ret: {
const text = editor.get_selection(sel, self.a) catch break :ret;
defer self.a.free(text);
const text = editor.get_selection(sel, self.allocator) catch break :ret;
defer self.allocator.free(text);
if (!(text.len > 2 and std.mem.eql(u8, text[0..2], "..")))
self.file_path.clearRetainingCapacity();
try self.file_path.appendSlice(text);

View file

@ -24,7 +24,7 @@ pub fn load_entries(palette: *Type) !void {
}
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {
var value = std.ArrayList(u8).init(palette.a);
var value = std.ArrayList(u8).init(palette.allocator);
defer value.deinit();
const writer = value.writer();
try cbor.writeValue(writer, entry.name);

View file

@ -25,7 +25,7 @@ const mainview = @import("../../mainview.zig");
const Self = @This();
const max_recent_files: usize = 25;
a: std.mem.Allocator,
allocator: std.mem.Allocator,
f: usize = 0,
menu: *Menu.State(*Self),
inputbox: *InputBox.State(*Self),
@ -36,18 +36,18 @@ need_select_first: bool = true,
longest: usize = 0,
commands: Commands = undefined,
pub fn create(a: std.mem.Allocator) !tui.Mode {
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
const mv = tui.current().mainview.dynamic_cast(mainview) orelse return error.NotFound;
const self: *Self = try a.create(Self);
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.menu = try Menu.create(*Self, a, tui.current().mainview, .{
.allocator = allocator,
.menu = try Menu.create(*Self, allocator, tui.current().mainview, .{
.ctx = self,
.on_render = on_render_menu,
.on_resize = on_resize_menu,
}),
.logger = log.logger(@typeName(Self)),
.inputbox = (try self.menu.add_header(try InputBox.create(*Self, self.a, self.menu.menu.parent, .{
.inputbox = (try self.menu.add_header(try InputBox.create(*Self, self.allocator, self.menu.menu.parent, .{
.ctx = self,
.label = "Search files by name",
}))).dynamic_cast(InputBox.State(*Self)) orelse unreachable,
@ -71,7 +71,7 @@ pub fn deinit(self: *Self) void {
if (tui.current().mainview.dynamic_cast(mainview)) |mv|
mv.floating_views.remove(self.menu.container_widget);
self.logger.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
inline fn menu_width(self: *Self) usize {
@ -141,7 +141,7 @@ fn menu_action_open_file(menu: **Menu.State(*Self), button: *Button.State(*Menu.
}
fn add_item(self: *Self, file_name: []const u8, matches: ?[]const u8) !void {
var label = std.ArrayList(u8).init(self.a);
var label = std.ArrayList(u8).init(self.allocator);
defer label.deinit();
const writer = label.writer();
try cbor.writeValue(writer, file_name);

View file

@ -24,24 +24,24 @@ pub const Match = struct {
pub fn deinit(palette: *Type) void {
for (palette.entries.items) |entry|
palette.a.free(entry.name);
palette.allocator.free(entry.name);
}
pub fn load_entries(palette: *Type) !void {
const rsp = try project_manager.request_recent_projects(palette.a);
defer palette.a.free(rsp.buf);
const rsp = try project_manager.request_recent_projects(palette.allocator);
defer palette.allocator.free(rsp.buf);
var iter: []const u8 = rsp.buf;
var len = try cbor.decodeArrayHeader(&iter);
while (len > 0) : (len -= 1) {
var name_: []const u8 = undefined;
if (try cbor.matchValue(&iter, cbor.extract(&name_))) {
(try palette.entries.addOne()).* = .{ .name = try palette.a.dupe(u8, name_) };
(try palette.entries.addOne()).* = .{ .name = try palette.allocator.dupe(u8, name_) };
} else return error.InvalidMessageField;
}
}
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {
var value = std.ArrayList(u8).init(palette.a);
var value = std.ArrayList(u8).init(palette.allocator);
defer value.deinit();
const writer = value.writer();
try cbor.writeValue(writer, entry.name);

View file

@ -26,7 +26,7 @@ const max_menu_width = 80;
pub fn Create(options: type) type {
return struct {
a: std.mem.Allocator,
allocator: std.mem.Allocator,
menu: *Menu.State(*Self),
inputbox: *InputBox.State(*Self),
logger: log.Logger,
@ -47,12 +47,12 @@ pub fn Create(options: type) type {
pub const MenuState = Menu.State(*Self);
pub const ButtonState = Button.State(*Menu.State(*Self));
pub fn create(a: std.mem.Allocator) !tui.Mode {
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
const mv = tui.current().mainview.dynamic_cast(mainview) orelse return error.NotFound;
const self: *Self = try a.create(Self);
const self: *Self = try allocator.create(Self);
self.* = .{
.a = a,
.menu = try Menu.create(*Self, a, tui.current().mainview, .{
.allocator = allocator,
.menu = try Menu.create(*Self, allocator, tui.current().mainview, .{
.ctx = self,
.on_render = on_render_menu,
.on_resize = on_resize_menu,
@ -61,13 +61,13 @@ pub fn Create(options: type) type {
.on_click5 = mouse_click_button5,
}),
.logger = log.logger(@typeName(Self)),
.inputbox = (try self.menu.add_header(try InputBox.create(*Self, self.a, self.menu.menu.parent, .{
.inputbox = (try self.menu.add_header(try InputBox.create(*Self, self.allocator, self.menu.menu.parent, .{
.ctx = self,
.label = options.label,
}))).dynamic_cast(InputBox.State(*Self)) orelse unreachable,
.hints = if (tui.current().input_mode) |m| m.keybind_hints else null,
.view_rows = get_view_rows(tui.current().screen()),
.entries = std.ArrayList(Entry).init(a),
.entries = std.ArrayList(Entry).init(allocator),
};
self.menu.scrollbar.?.style_factory = scrollbar_style;
if (self.hints) |hints| {
@ -96,7 +96,7 @@ pub fn Create(options: type) type {
if (tui.current().mainview.dynamic_cast(mainview)) |mv|
mv.floating_views.remove(self.menu.container_widget);
self.logger.deinit();
self.a.destroy(self);
self.allocator.destroy(self);
}
fn scrollbar_style(sb: *scrollbar_v, theme: *const Widget.Theme) Widget.Theme.Style {
@ -325,7 +325,7 @@ pub fn Create(options: type) type {
fn query_entries(self: *Self, query: []const u8) error{OutOfMemory}!usize {
var searcher = try fuzzig.Ascii.init(
self.a,
self.allocator,
self.longest, // haystack max size
self.longest, // needle max size
.{ .case_sensitive = false },
@ -338,7 +338,7 @@ pub fn Create(options: type) type {
matches: []const usize,
};
var matches = std.ArrayList(Match).init(self.a);
var matches = std.ArrayList(Match).init(self.allocator);
for (self.entries.items) |*entry| {
const match = searcher.scoreMatches(entry.name, query);
@ -346,7 +346,7 @@ pub fn Create(options: type) type {
(try matches.addOne()).* = .{
.entry = entry,
.score = score,
.matches = try self.a.dupe(usize, match.matches),
.matches = try self.allocator.dupe(usize, match.matches),
};
}
if (matches.items.len == 0) return 0;

View file

@ -29,7 +29,7 @@ pub fn load_entries(palette: *Type) !void {
}
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {
var value = std.ArrayList(u8).init(palette.a);
var value = std.ArrayList(u8).init(palette.allocator);
defer value.deinit();
const writer = value.writer();
try cbor.writeValue(writer, entry.name);