srctree

Gregory Mullen parent 1c9726ce 7ea55eb9
deleting code assuming an arena

src/completion.zig added: 11, removed: 39, total 0
@@ -2,10 +2,6 @@ const Completion = @This();
 
pub const CompList = ArrayList(CompOption);
 
const Error = error{
search_empty,
};
 
pub const FSKind = enum {
file,
dir,
@@ -60,6 +56,7 @@ pub const CompOption = struct {
str: []const u8,
/// the original user text has kind == null
kind: ?Kind = Kind{ .any = {} },
 
pub fn format(self: CompOption, comptime fmt: []const u8, _: std.fmt.FormatOptions, out: anytype) !void {
if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self);
try std.fmt.format(out, "CompOption{{{s}, {s}}}", .{ self.str, @tagName(self.kind) });
@@ -400,30 +397,12 @@ pub const CompSet = struct {
 
pub fn searchPop(self: *CompSet) !void {
if (self.search.items.len == 0) {
return Error.search_empty;
return error.SearchEmpty;
}
_ = self.search.pop();
self.searchMove();
}
 
fn razeDrawing(self: *CompSet) void {
for (&self.draw_cache) |*dcache| {
if (dcache.*) |*row| {
var real_size: usize = 0;
for (row.*) |col| {
for (col) |lex| {
self.alloc.free(lex.char);
real_size += 1;
}
}
row.*[0].len = real_size;
self.alloc.free(row.*);
dcache.* = null;
}
}
self.err = false;
}
 
pub fn raze(self: *CompSet) void {
for (&self.groups) |*group| {
for (group.items) |opt| {
@@ -435,7 +414,6 @@ pub const CompSet = struct {
self.alloc.free(o.str);
self.original = null;
}
self.razeDrawing();
self.search.clearAndFree();
}
};
 
src/line.zig added: 11, removed: 39, total 0
@@ -16,13 +16,6 @@ usr_line: [1024]u8 = undefined,
 
const Line = @This();
 
const Mode = enum {
TYPING,
COMPLETING,
COMPENDING, // Just completed a token, may or may not need more
EXEDIT,
};
 
pub const Options = struct {
interactive: bool = true,
};
@@ -251,9 +244,7 @@ fn complete(line: *Line) !void {
try line.hsh.draw.render();
 
switch (c) {
0x09 => unreachable,
0x0A => unreachable,
0x7f => unreachable,
0x00...0x1f => unreachable,
' ' => {
try line.tkn.maybeCommit(null);
cmplt.raze();
@@ -283,6 +274,7 @@ fn complete(line: *Line) !void {
 
continue :sw .{ .redraw = {} };
},
0x7f...0xff => unreachable,
}
},
.control => |k| {
 
src/tokenizer.zig added: 11, removed: 39, total 0
@@ -30,7 +30,7 @@ pub const CursorMotion = enum(u8) {
pub fn init(a: Allocator) Tokenizer {
return Tokenizer{
.alloc = a,
.raw = ArrayList(u8).init(a),
.raw = ArrayList(u8).initCapacity(a, 512) catch ArrayList(u8).init(a), // lol
};
}
 
@@ -443,7 +443,8 @@ test "quotes tokened" {
}
 
test "alloc" {
const t = Tokenizer.init(std.testing.allocator);
var t = Tokenizer.init(std.testing.allocator);
defer t.raze();
try expect(std.mem.eql(u8, t.raw.items, ""));
}
 
@@ -1109,6 +1110,7 @@ test "subp" {
test "make safe" {
var a = std.testing.allocator;
var tk = Tokenizer.init(a);
defer tk.raze();
 
try std.testing.expect(null == try tk.makeSafe("string"));