diff --git a/.zwanzig.json b/.zwanzig.json new file mode 100644 index 0000000..cd4f33c --- /dev/null +++ b/.zwanzig.json @@ -0,0 +1,31 @@ +{ + "resource_models": [ + { "kind": "free_owned", "method_name": "deinit" }, + + { "kind": "alloc", "method_name": "SDL_CreateWindow" }, + { "kind": "free", "method_name": "SDL_DestroyWindow" }, + + { "kind": "alloc", "method_name": "SDL_CreateRenderer" }, + { "kind": "free", "method_name": "SDL_DestroyRenderer" }, + + { "kind": "alloc", "method_name": "SDL_CreateTexture" }, + { "kind": "alloc", "method_name": "SDL_CreateTextureFromSurface" }, + { "kind": "free", "method_name": "SDL_DestroyTexture" }, + + { "kind": "alloc", "method_name": "SDL_CreateSurface" }, + { "kind": "free", "method_name": "SDL_DestroySurface" }, + + { "kind": "alloc", "method_name": "SDL_CreateSystemCursor" }, + { "kind": "free", "method_name": "SDL_DestroyCursor" }, + + { "kind": "alloc", "method_name": "SDL_IOFromConstMem" }, + { "kind": "free", "method_name": "SDL_CloseIO" }, + + { "kind": "open", "method_name": "TTF_OpenFont" }, + { "kind": "open", "method_name": "TTF_OpenFontIO" }, + { "kind": "close", "method_name": "TTF_CloseFont" }, + + { "kind": "alloc", "method_name": "CFRetain" }, + { "kind": "free", "method_name": "CFRelease" } + ] +} diff --git a/build.zig.zon b/build.zig.zon index 920711c..fe820ec 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -17,8 +17,8 @@ .hash = "toml-0.3.0-bV14Bd-EAQBKoXhpYft303BtA2vgLNlxntUCIWgRUl46", }, .zwanzig = .{ - .url = "https://github.com/forketyfork/zwanzig/archive/refs/tags/v0.6.0.tar.gz", - .hash = "zwanzig-0.6.0-oiXZlq5LFADerMou9MKY7lYwwzF53DSdeMowW7CO8vKk", + .url = "https://github.com/forketyfork/zwanzig/archive/refs/tags/v0.8.0.tar.gz", + .hash = "zwanzig-0.8.0-oiXZlms3FQDGrGJGFGOO-bMF7OkxG4nFhiK6-ajHsJTb", }, }, .paths = .{ diff --git a/src/app/terminal_actions.zig b/src/app/terminal_actions.zig index 421b4a6..40e2e06 100644 --- a/src/app/terminal_actions.zig +++ b/src/app/terminal_actions.zig @@ -71,11 +71,12 @@ pub fn copySelectionToClipboard( const text = try screen.selectionString(allocator, .{ .sel = sel, .trim = true }); defer allocator.free(text); - const clipboard_text = try allocator.allocSentinel(u8, text.len, 0); - defer allocator.free(clipboard_text); - @memcpy(clipboard_text[0..text.len], text); + const clipboard_buf = try allocator.alloc(u8, text.len + 1); + defer allocator.free(clipboard_buf); + @memcpy(clipboard_buf[0..text.len], text); + clipboard_buf[text.len] = 0; - if (!c.SDL_SetClipboardText(clipboard_text.ptr)) { + if (!c.SDL_SetClipboardText(clipboard_buf.ptr)) { ui.showToast("Failed to copy selection", now); return; }