mirror of
https://github.com/MezzalunaWM/Whetstone.git
synced 2026-03-08 04:57:32 -04:00
cleaning up some messiness
This commit is contained in:
parent
82a2601e6c
commit
10c48188ad
2 changed files with 10 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {};
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue