refactor: lots and lots of writergate changes

This commit is contained in:
CJ van den Berg 2025-09-24 22:30:18 +02:00
parent 96e8100373
commit e6b39c274c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
19 changed files with 437 additions and 382 deletions

View file

@ -21,7 +21,7 @@ fn parse_error(comptime format: anytype, args: anytype) ParseError {
pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseError![]input.KeyEvent {
parse_error_reset();
if (str.len == 0) return parse_error("empty", .{});
var result_events = std.ArrayList(input.KeyEvent).init(allocator);
var result_events: std.ArrayList(input.KeyEvent) = .empty;
var iter_sequence = std.mem.tokenizeScalar(u8, str, ' ');
while (iter_sequence.next()) |item| {
var key: ?input.Key = null;
@ -65,11 +65,11 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
if (key == null) return parse_error("unknown key '{s}' in '{s}'", .{ part, str });
}
if (key) |k|
try result_events.append(input.KeyEvent.from_key_modset(k, mods))
try result_events.append(allocator, input.KeyEvent.from_key_modset(k, mods))
else
return parse_error("no key defined in '{s}'", .{str});
}
return result_events.toOwnedSlice();
return result_events.toOwnedSlice(allocator);
}
pub const name_map = blk: {