diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-05-26 22:55:07 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-05-31 21:04:25 +0200 |
| commit | d9ca9db5a49f0af2f6bef6f198b28a8d29808e6d (patch) | |
| tree | ebeb7de70a63bfff951e9eaa069f7885aa34a2dc /src/Seat.zig | |
| parent | 9cd61f75903a83e56538ae3d69e7c2f3d2e6ca10 (diff) | |
| download | river-d9ca9db5a49f0af2f6bef6f198b28a8d29808e6d.tar.gz river-d9ca9db5a49f0af2f6bef6f198b28a8d29808e6d.tar.xz | |
Rework commands to be string based
This allows for significantly more flexibility and should make
implementing the bind command possible.
Diffstat (limited to 'src/Seat.zig')
| -rw-r--r-- | src/Seat.zig | 9 |
1 files changed, 8 insertions, 1 deletions
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; } } |
