diff options
author | Dominik Heidler <dominik@heidler.eu> | 2016-04-13 10:36:10 +0200 |
---|---|---|
committer | Dominik Heidler <dominik@heidler.eu> | 2016-04-13 10:47:53 +0200 |
commit | 02bad7af28a419c0985f45e8c0eabeae2ec8f743 (patch) | |
tree | 11415249e383e4874548f6884532658b5760c9bf /src/command | |
parent | eeb0f71cbf365dfee627a03766a62fb99e02b97e (diff) | |
download | profani-tty-02bad7af28a419c0985f45e8c0eabeae2ec8f743.tar.gz |
Add /command? shortcut to view /help command
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/command/command.c b/src/command/command.c index 67bd8d43..990e211a 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -32,6 +32,8 @@ * */ +#define _GNU_SOURCE 1 + #include "config.h" #include <assert.h> @@ -2972,7 +2974,17 @@ cmd_process_input(ProfWin *window, char *inp) } else if (inp[0] == '/') { char *inp_cpy = strdup(inp); char *command = strtok(inp_cpy, " "); - result = _cmd_execute(window, command, inp); + char *question_mark = strchr(command, '?'); + if (question_mark) { + *question_mark = '\0'; + char *fakeinp; + if (asprintf(&fakeinp, "/help %s", command+1)) { + result = _cmd_execute(window, "/help", fakeinp); + free(fakeinp); + } + } else { + result = _cmd_execute(window, command, inp); + } free(inp_cpy); // call a default handler if input didn't start with '/' |