cleaning up some messiness

This commit is contained in:
Squibid 2025-12-10 20:14:49 -05:00
parent 82a2601e6c
commit 10c48188ad
Signed by: squibid
GPG key ID: BECE5684D3C4005D
2 changed files with 10 additions and 3 deletions

View file

@ -7,6 +7,7 @@ const Remote = @import("remote.zig");
const gpa = std.heap.c_allocator;
pub const prompt = "> ";
var remote: Remote = undefined;
const usage =
@ -26,8 +27,8 @@ fn inputThreadRun() !void {
defer ln.deinit();
while (true) {
const in = ln.linenoise("> ") catch |err| switch (err) {
error.CtrlC => std.process.exit(130),
const in = ln.linenoise(prompt) catch |err| switch (err) {
error.CtrlC => std.process.exit(0),
else => return err,
} orelse continue;
defer gpa.free(in);

View file

@ -7,6 +7,7 @@ const wl = wayland.client.wl;
const mez = wayland.client.zmez;
const util = @import("util.zig");
const prompt = @import("main.zig").prompt;
display: *wl.Display,
registry: *wl.Registry,
@ -89,7 +90,12 @@ fn registry_event(registry: *wl.Registry, event: wl.Registry.Event, remote: *Rem
fn handleRemote(_: *mez.RemoteLuaV1, event: mez.RemoteLuaV1.Event, _: *Remote) void {
switch (event) {
.new_log_entry => |e| {
std.debug.print("\r{s}\r\n", .{e.text});
const buffer: [1024]u8 = undefined;
const stdout = @constCast(&std.fs.File.stdout().writer(@constCast(&buffer)).interface);
// HACK: to make the prompt look correct we just redraw it after logging
// an entry.
stdout.print("\r{s}\r\n" ++ prompt, .{e.text}) catch {};
stdout.flush() catch {};
},
}
}