this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

image: implement deleting images from memory

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+15
+2
examples/image.zig
··· 32 32 try vx.loadImage(alloc, .{ .path = "examples/zig.png" }), 33 33 try vx.loadImage(alloc, .{ .path = "examples/vaxis.png" }), 34 34 }; 35 + defer vx.freeImage(imgs[0].id); 36 + defer vx.freeImage(imgs[1].id); 35 37 36 38 var n: usize = 0; 37 39
+13
src/vaxis.zig
··· 646 646 .height = img.height, 647 647 }; 648 648 } 649 + 650 + /// deletes an image from the terminal's memory 651 + pub fn freeImage(self: Self, id: u32) void { 652 + var tty = self.tty orelse return; 653 + const writer = tty.buffered_writer.writer(); 654 + std.fmt.format(writer, "\x1b_Ga=d,d=I,i={d};\x1b\\", .{id}) catch |err| { 655 + log.err("couldn't delete image {d}: {}", .{ id, err }); 656 + return; 657 + }; 658 + tty.buffered_writer.flush() catch |err| { 659 + log.err("couldn't flush writer: {}", .{err}); 660 + }; 661 + } 649 662 }; 650 663 } 651 664