summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-13 10:21:56 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-13 10:21:56 -0700
commit4f0b9cf334f0a763ff1fcfaabb61796f412a6452 (patch)
treec8323598574ae4ab1760b71bdaf210d342d50f91 /command.c
parentee15cfcfddbcc521dc8492c0299fcb8203acbb05 (diff)
bind name aliases
this supports SPC as a bind alias. You could also use ' ' but now SPC is supported and rendered properly.
Diffstat (limited to 'command.c')
-rw-r--r--command.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/command.c b/command.c
index f3b0e91..1703f99 100644
--- a/command.c
+++ b/command.c
@@ -8,6 +8,13 @@
#include "util.h"
+static const char *
+bind_name_to_bind(const char *bind) {
+ if (strcmp(bind, "STR") == 0)
+ return " ";
+ return bind;
+}
+
int
command_is_prefix(struct command *cmd) {
return cmd->nchildren > 0;
@@ -28,7 +35,7 @@ command_num_children(struct command *cmd) {
struct command *
command_lookup(struct command *cmd, int ncmds, const char *binding) {
for (int i = 0; i < ncmds; ++i) {
- if (strcmp(binding, cmd[i].bind) == 0)
+ if (strcmp(binding, bind_name_to_bind(cmd[i].bind)) == 0)
return &cmd[i];
}