diff options
Diffstat (limited to 'core/Kind.zig')
| -rw-r--r-- | core/Kind.zig | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/Kind.zig b/core/Kind.zig index 49076f78..5d2dcdb0 100644 --- a/core/Kind.zig +++ b/core/Kind.zig @@ -17,6 +17,7 @@ const std = @import("std"); const builtin = @import("builtin"); pub const c = @import("pardes_addon"); +const cSlice = @import("addon").cSlice; const pardes = @import("root.zig"); const walk = @import("walk.zig"); const surface = @import("surface.zig"); @@ -1130,7 +1131,7 @@ pub const api: c.pa_api = .{ .look = struct { fn f(text: [*c]const u8, n: u32) callconv(.c) void { const cl = current orelse return; - if (!cl.quiet and text != null) cl.look.set(text[0..n]); + if (!cl.quiet and text != null) cl.look.set(cSlice(text, n)); } }.f, .say = struct { @@ -1138,8 +1139,8 @@ pub const api: c.pa_api = .{ const cl = current orelse return; if (cl.quiet or text == null) return; // Refusing its open: the opener says why. - if (err != 0 and cl.opening) return cl.refused.set(text[0..n]); - cl.said.set(text[0..n]); + if (err != 0 and cl.opening) return cl.refused.set(cSlice(text, n)); + cl.said.set(cSlice(text, n)); cl.err = err != 0; } }.f, @@ -1149,8 +1150,8 @@ pub const api: c.pa_api = .{ const cl = current orelse return 0; const p = cl.p orelse return 0; if (cl.quiet or name == null or cl.pane_name.len > 0) return 0; - cl.pane_name.set(name[0..name_len]); - cl.pane_text = p.scratch.allocator().dupe(u8, if (bytes == null) "" else bytes[0..n]) catch ""; + cl.pane_name.set(cSlice(name, name_len)); + cl.pane_text = p.scratch.allocator().dupe(u8, cSlice(bytes, n)) catch ""; return p.next_serial + 1; } }.f, @@ -1181,7 +1182,7 @@ pub const api: c.pa_api = .{ .exec = struct { fn f(text: [*c]const u8, n: u32) callconv(.c) void { const cl = current orelse return; - if (!cl.quiet and text != null) cl.exec.set(text[0..n]); + if (!cl.quiet and text != null) cl.exec.set(cSlice(text, n)); } }.f, .select = struct { @@ -1189,7 +1190,7 @@ pub const api: c.pa_api = .{ const cl = current orelse return; if (cl.quiet) return; const p = cl.p orelse return; - cl.selected = p.scratch.allocator().dupe(u8, if (text == null) "" else text[0..n]) catch return; + cl.selected = p.scratch.allocator().dupe(u8, cSlice(text, n)) catch return; } }.f, .cancel = struct { @@ -1234,7 +1235,7 @@ pub const api: c.pa_api = .{ const cl = current orelse return; const p = cl.p orelse return; if (cl.quiet or rows == null) return; - cl.rows = std.mem.concat(p.scratch.allocator(), u8, &.{ cl.rows, rows[0..n] }) catch return; + cl.rows = std.mem.concat(p.scratch.allocator(), u8, &.{ cl.rows, cSlice(rows, n) }) catch return; } }.f, }; |
