From 5acf7eb8fd79ad390f1175bf3b3d23c76182f3ff Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 28 May 2023 10:20:59 -0700 Subject: [PATCH] apprt/embedded: clipboard value can be null --- src/apprt/embedded.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index c492f0037..b4c8577f3 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -45,8 +45,9 @@ pub const App = struct { set_title: *const fn (SurfaceUD, [*]const u8) callconv(.C) void, /// Read the clipboard value. The return value must be preserved - /// by the host until the next call. - read_clipboard: *const fn (SurfaceUD) callconv(.C) [*:0]const u8, + /// by the host until the next call. If there is no valid clipboard + /// value then this should return null. + read_clipboard: *const fn (SurfaceUD) callconv(.C) ?[*:0]const u8, /// Write the clipboard value. write_clipboard: *const fn (SurfaceUD, [*:0]const u8) callconv(.C) void, @@ -228,7 +229,7 @@ pub const Surface = struct { } pub fn getClipboardString(self: *const Surface) ![:0]const u8 { - const ptr = self.app.opts.read_clipboard(self.opts.userdata); + const ptr = self.app.opts.read_clipboard(self.opts.userdata) orelse return ""; return std.mem.sliceTo(ptr, 0); }