summaryrefslogtreecommitdiff
path: root/cmdtree.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 /cmdtree.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 'cmdtree.c')
-rw-r--r--cmdtree.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmdtree.c b/cmdtree.c
index ba8c514..1f507dd 100644
--- a/cmdtree.c
+++ b/cmdtree.c
@@ -186,6 +186,14 @@ setup(Drw *drw)
/* draw_tree(drw); */
}
+static const char *
+bind_name(const char *bind) {
+ switch (*bind) {
+ case ' ': return "SPC";
+ default: return bind;
+ }
+}
+
static int
draw_command(Drw *drw, int x, int y, struct command *cmd) {
char buf[256];
@@ -202,8 +210,10 @@ draw_command(Drw *drw, int x, int y, struct command *cmd) {
drw_setscheme(drw, &schemes[SchemeNorm].bind_clr,
&schemes[SchemeNorm].bg_clr);
- w = drw_fontset_getwidth(drw, cmd->bind);
- x = drw_text(drw, x+pad, y, w, bh, lpad, cmd->bind, invert);
+ const char *bindname = bind_name(cmd->bind);
+
+ w = drw_fontset_getwidth(drw, bindname);
+ x = drw_text(drw, x+pad, y, w, bh, lpad, bindname, invert);
w = sep_width;
drw_setscheme(drw, &schemes[SchemeNorm].arrow_clr,