From 12efa0e3b429675047cb2900d49e1f38afeb650b Mon Sep 17 00:00:00 2001 From: Arthur Williams Date: Sat, 18 Sep 2021 12:27:12 -0700 Subject: Add ability to bind arbitrary functions. Before all the predated commands where kept in an array and their indexes were used in bindings. This meant that users couldn't add their own functions from the config file. Now key/mouse bindings have been changed to to store the function ptr (wrapped in a cmd_t struct to also store the mode) directly instead. General cleanup done in this commit: Defined `MODE_ALL` instead of using magic number. For example, suppose one had bindings like: { 0, XK_q, g_quit, None }, { ShitMask, XK_q, {quit_err}, None } { ControlMask, XK_q, {quit_err, .mode=MODE_IMAGE}, None } The existing binding `q` has been left unchanged and is defined the same way. However, the new hypothetical binding `Shift-q` can be used to call the custom function quit_err in any mode (default). `Ctrl-q` on the other hand will be called only on image mode. Closes #50 --- commands.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index 3981f0f..e52b381 100644 --- a/commands.c +++ b/commands.c @@ -436,15 +436,3 @@ bool ct_reload_all(arg_t _) tns.dirty = true; return true; } - - -#undef G_CMD -#define G_CMD(c) { -1, cg_##c }, -#undef I_CMD -#define I_CMD(c) { MODE_IMAGE, ci_##c }, -#undef T_CMD -#define T_CMD(c) { MODE_THUMB, ct_##c }, - -const cmd_t cmds[CMD_COUNT] = { -#include "commands.lst" -}; -- cgit v1.2.3-54-g00ecf