diff --git a/src/keybind/dynamic/KeyEvent.zig b/src/keybind/dynamic/KeyEvent.zig deleted file mode 100644 index dbbc04d..0000000 --- a/src/keybind/dynamic/KeyEvent.zig +++ /dev/null @@ -1,14 +0,0 @@ -const std = @import("std"); -const input = @import("input"); - -event: input.Event = input.event.press, -key: input.Key = 0, -modifiers: input.Mods = 0, - -pub fn eql(self: @This(), other: @This()) bool { - return std.meta.eql(self, other); -} - -pub fn format(self: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - try writer.print("{}:{}{}", .{ input.event_fmt(self.event), input.mod_fmt(self.modifiers), input.key_fmt(self.key) }); -} diff --git a/src/keybind/dynamic/keybind.zig b/src/keybind/dynamic/keybind.zig index 78fe9c3..ec42d47 100644 --- a/src/keybind/dynamic/keybind.zig +++ b/src/keybind/dynamic/keybind.zig @@ -11,8 +11,8 @@ const log = @import("log"); const input = @import("input"); const command = @import("command"); const EventHandler = @import("EventHandler"); +const KeyEvent = input.KeyEvent; -const KeyEvent = @import("KeyEvent.zig"); const parse_flow = @import("parse_flow.zig"); const parse_vim = @import("parse_vim.zig"); diff --git a/src/keybind/dynamic/parse_flow.zig b/src/keybind/dynamic/parse_flow.zig index 8b31938..be73d9a 100644 --- a/src/keybind/dynamic/parse_flow.zig +++ b/src/keybind/dynamic/parse_flow.zig @@ -1,6 +1,5 @@ const std = @import("std"); const input = @import("input"); -const KeyEvent = @import("KeyEvent.zig"); pub const ParseError = error{ OutOfMemory, diff --git a/src/keybind/dynamic/parse_vim.zig b/src/keybind/dynamic/parse_vim.zig index a05cba3..edd4efd 100644 --- a/src/keybind/dynamic/parse_vim.zig +++ b/src/keybind/dynamic/parse_vim.zig @@ -1,6 +1,5 @@ const std = @import("std"); const input = @import("input"); -const KeyEvent = @import("KeyEvent.zig"); fn peek(str: []const u8, i: usize) error{OutOfBounds}!u8 { if (i + 1 < str.len) { diff --git a/src/renderer/vaxis/input.zig b/src/renderer/vaxis/input.zig index 55422f9..3656e81 100644 --- a/src/renderer/vaxis/input.zig +++ b/src/renderer/vaxis/input.zig @@ -1,5 +1,6 @@ const vaxis = @import("vaxis"); +const meta = @import("std").meta; const utf8Encode = @import("std").unicode.utf8Encode; const FormatOptions = @import("std").fmt.FormatOptions; @@ -55,6 +56,20 @@ pub const event = struct { pub const release: Event = 3; }; +pub const KeyEvent = struct { + event: Event = event.press, + key: Key = 0, + modifiers: Mods = 0, + + pub fn eql(self: @This(), other: @This()) bool { + return meta.eql(self, other); + } + + pub fn format(self: @This(), comptime _: []const u8, _: FormatOptions, writer: anytype) !void { + try writer.print("{}:{}{}", .{ event_fmt(self.event), mod_fmt(self.modifiers), key_fmt(self.key) }); + } +}; + pub fn ucs32_to_utf8(ucs32: []const u32, utf8: []u8) !usize { return @intCast(try utf8Encode(@intCast(ucs32[0]), utf8)); }