diff --git a/examples/image.zig b/examples/image.zig index 3a4abfd..acce241 100644 --- a/examples/image.zig +++ b/examples/image.zig @@ -18,11 +18,13 @@ pub fn main() !void { } const alloc = gpa.allocator(); - var vx = try vaxis.init(Event, .{}); + var vx = try vaxis.init(alloc, .{}); defer vx.deinit(alloc); - try vx.startReadThread(); - defer vx.stopReadThread(); + var loop: vaxis.Loop(Event) = .{ .vaxis = &vx }; + + try loop.run(); + defer loop.stop(); try vx.enterAltScreen(); @@ -38,7 +40,7 @@ pub fn main() !void { var n: usize = 0; while (true) { - const event = vx.nextEvent(); + const event = loop.nextEvent(); switch (event) { .key_press => |key| { if (key.matches('c', .{ .ctrl = true })) { diff --git a/src/Vaxis.zig b/src/Vaxis.zig index 6623416..56296f6 100644 --- a/src/Vaxis.zig +++ b/src/Vaxis.zig @@ -1,6 +1,6 @@ const std = @import("std"); const atomic = std.atomic; -const base64 = std.base64; +const base64Encoder = std.base64.standard.Encoder; const zigimg = @import("zigimg"); const Cell = @import("Cell.zig"); @@ -580,8 +580,8 @@ pub fn loadImage( const png_buf = try alloc.alloc(u8, img.imageByteSize()); defer alloc.free(png_buf); const png = try img.writeToMemory(png_buf, .{ .png = .{} }); - const b64_buf = try alloc.alloc(u8, base64.calcSize(png.len)); - const encoded = base64.encode(b64_buf, png); + const b64_buf = try alloc.alloc(u8, base64Encoder.calcSize(png.len)); + const encoded = base64Encoder.encode(b64_buf, png); defer alloc.free(b64_buf); const id = self.next_img_id;