fix formatting in interactive mode

This commit is contained in:
Squibid 2025-12-10 21:28:39 -05:00
parent 4682db9cfd
commit 61591a044e
Signed by: squibid
GPG key ID: BECE5684D3C4005D

View file

@ -9,6 +9,8 @@ const mez = wayland.client.zmez;
const util = @import("util.zig"); const util = @import("util.zig");
const prompt = @import("main.zig").prompt; const prompt = @import("main.zig").prompt;
const gpa = std.heap.c_allocator;
display: *wl.Display, display: *wl.Display,
registry: *wl.Registry, registry: *wl.Registry,
compositor: ?*wl.Compositor, compositor: ?*wl.Compositor,
@ -92,9 +94,11 @@ fn handleRemote(_: *mez.RemoteLuaV1, event: mez.RemoteLuaV1.Event, _: *Remote) v
.new_log_entry => |e| { .new_log_entry => |e| {
const buffer: [1024]u8 = undefined; const buffer: [1024]u8 = undefined;
const stdout = @constCast(&std.fs.File.stdout().writer(@constCast(&buffer)).interface); const stdout = @constCast(&std.fs.File.stdout().writer(@constCast(&buffer)).interface);
const str = std.mem.replaceOwned(u8, gpa, std.mem.span(e.text), "\n", "\r\n") catch util.oom();
defer gpa.free(str);
// HACK: to make the prompt look correct we just redraw it after logging // HACK: to make the prompt look correct we just redraw it after logging
// an entry. // an entry.
stdout.print("\r{s}\r\n" ++ prompt, .{e.text}) catch {}; stdout.print("\r{s}\r\n" ++ prompt, .{str}) catch {};
stdout.flush() catch {}; stdout.flush() catch {};
}, },
} }