mirror of
https://github.com/MezzalunaWM/Whetstone.git
synced 2026-03-07 19:49:53 -05: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;
|
const gpa = std.heap.c_allocator;
|
||||||
|
|
||||||
|
pub const prompt = "> ";
|
||||||
var remote: Remote = undefined;
|
var remote: Remote = undefined;
|
||||||
|
|
||||||
const usage =
|
const usage =
|
||||||
|
|
@ -26,8 +27,8 @@ fn inputThreadRun() !void {
|
||||||
defer ln.deinit();
|
defer ln.deinit();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const in = ln.linenoise("> ") catch |err| switch (err) {
|
const in = ln.linenoise(prompt) catch |err| switch (err) {
|
||||||
error.CtrlC => std.process.exit(130),
|
error.CtrlC => std.process.exit(0),
|
||||||
else => return err,
|
else => return err,
|
||||||
} orelse continue;
|
} orelse continue;
|
||||||
defer gpa.free(in);
|
defer gpa.free(in);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ const wl = wayland.client.wl;
|
||||||
const mez = wayland.client.zmez;
|
const mez = wayland.client.zmez;
|
||||||
|
|
||||||
const util = @import("util.zig");
|
const util = @import("util.zig");
|
||||||
|
const prompt = @import("main.zig").prompt;
|
||||||
|
|
||||||
display: *wl.Display,
|
display: *wl.Display,
|
||||||
registry: *wl.Registry,
|
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 {
|
fn handleRemote(_: *mez.RemoteLuaV1, event: mez.RemoteLuaV1.Event, _: *Remote) void {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
.new_log_entry => |e| {
|
.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