From d9ca9db5a49f0af2f6bef6f198b28a8d29808e6d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 26 May 2020 22:55:07 +0200 Subject: Rework commands to be string based This allows for significantly more flexibility and should make implementing the bind command possible. --- src/Seat.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Seat.zig') diff --git a/src/Seat.zig b/src/Seat.zig index 3ff3667..7e0b06b 100644 --- a/src/Seat.zig +++ b/src/Seat.zig @@ -20,6 +20,7 @@ const Self = @This(); const std = @import("std"); const c = @import("c.zig"); +const command = @import("command.zig"); const Cursor = @import("Cursor.zig"); const InputManager = @import("InputManager.zig"); @@ -252,7 +253,13 @@ pub fn handleKeybinding(self: *Self, keysym: c.xkb_keysym_t, modifiers: u32) boo for (self.mode.keybinds.items) |keybind| { if (modifiers == keybind.modifiers and keysym == keybind.keysym) { // Execute the bound command - keybind.command.run(self); + const allocator = self.input_manager.server.allocator; + var failure_message: []const u8 = undefined; + command.run(allocator, self, keybind.command_args, &failure_message) catch |err| { + // TODO: log the error + if (err == command.Error.CommandFailed) + allocator.free(failure_message); + }; return true; } } -- cgit v1.2.3