summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-27 07:56:26 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-27 10:17:07 +0200
commit7856a20be8065cadae1fce0c7b33a95a8df8e98e (patch)
treefa5ba4b5bc6807f23e54273a6835220b6747528b /src
parent6467f92d78b694c6c5ddcead24629ba8be4b93ee (diff)
downloadcmumble-7856a20be8065cadae1fce0c7b33a95a8df8e98e.tar.gz
cmumble-7856a20be8065cadae1fce0c7b33a95a8df8e98e.tar.bz2
cmumble-7856a20be8065cadae1fce0c7b33a95a8df8e98e.zip
Add readline command completionautocompletion
Diffstat (limited to 'src')
-rw-r--r--src/commands.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/commands.c b/src/commands.c
index 3e4e7aa..d6c12a9 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -86,8 +86,30 @@ cmumble_command_complete(const char *text)
return found_index >= 0 ? commands[found_index].name : text;
}
+static char *
+complete(const char *in, int n)
+{
+ static int index = 0, len;
+ const char *name;
+
+ if (n == 0) {
+ index = 0;
+ len = strlen(in);
+ }
+
+ while (commands[index].name) {
+ name = commands[index++].name;
+ if (strncmp(name, in, len) == 0)
+ return g_strdup(name);
+ }
+
+ return NULL;
+}
+
void
cmumble_commands_init(struct cmumble_context *ctx)
{
ctx->commands = commands;
+
+ rl_completion_entry_function = complete;
}