From ae3afea63f4d0c88b788d6cf3556945c7339a7f1 Mon Sep 17 00:00:00 2001 From: namedkitten Date: Sun, 12 Jul 2020 16:29:30 +0100 Subject: [PATCH] Work on mouse event parsing. --- build.zig | 2 +- src/bar/bar.zig | 11 ++++++++++- src/types/mouseevent.zig | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/types/mouseevent.zig diff --git a/build.zig b/build.zig index cd22ac9..2b8d6d3 100644 --- a/build.zig +++ b/build.zig @@ -17,7 +17,7 @@ pub fn build(b: *Builder) void { exe.addBuildOption(bool, "terminal_version", terminal_version); exe.addBuildOption(bool, "disable_colour", disable_colour); - exe.strip = true; + //exe.strip = true; exe.addPackage(.{ .name = "interfaces", .path = "deps/interfaces/interface.zig", diff --git a/src/bar/bar.zig b/src/bar/bar.zig index a3e6183..8b5403f 100644 --- a/src/bar/bar.zig +++ b/src/bar/bar.zig @@ -61,8 +61,17 @@ pub const Bar = struct { } fn process(self: *Bar) !void { + var line_buffer: [512]u8 = undefined; while (self.running) { - std.time.sleep(5000 * std.time.ns_per_ms); + const line_opt = try std.io.getStdIn().inStream().readUntilDelimiterOrEof(&line_buffer, '\n'); + if (line_opt) |l| { + var line = l; + if (std.mem.eql(u8, line, "[")) continue; + if (line[0] == ',') line = line[1..line.len]; + std.debug.print("{}\n", .{line}); + } + + //std.time.sleep(5000 * std.time.ns_per_ms); //return; } } diff --git a/src/types/mouseevent.zig b/src/types/mouseevent.zig new file mode 100644 index 0000000..4a4f259 --- /dev/null +++ b/src/types/mouseevent.zig @@ -0,0 +1,17 @@ +pub const MouseEvent = struct { + name: []const u8, + button: enum(u3) { + LeftClick = 1, + MiddleClick = 2, + RightClick = 3, + ScrollUp = 4, + ScrollDown = 5, + }, + event: u16, + x: u16, + y: u16, + relative_x: u16, + relative_y: u16, + height: u16, + width: u16, +};