From a1ed75252f0e14282ba53d4c96f9406403360d90 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 12 Feb 2015 10:34:43 +0100 Subject: [PATCH] Correct autocompletion (list not shown, files shown instead of commands) --- src/parse.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/parse.h b/src/parse.h index 60edf0d..c1a00b4 100644 --- a/src/parse.h +++ b/src/parse.h @@ -257,16 +257,6 @@ static bool _obj_from_string(const string& entry, object*& obj, unsigned int& ob return ret; } -static char** entry_completion(const char* text, int start, int end) -{ - char** matches = NULL; - - if (start == 0) - matches = rl_completion_matches((char*)text, &entry_completion_generator); - - return matches; -} - static char* entry_completion_generator(const char* text, int state) { static int list_index, len, too_far; @@ -296,7 +286,7 @@ static char* entry_completion_generator(const char* text, int state) } /* If no names matched, then return NULL. */ - return NULL; + return (char*)NULL; } @@ -342,17 +332,14 @@ static ret_value entry(program& prog) char *buf; ret_value ret; - // declare completion fn - rl_attempted_completion_function = entry_completion; + // declare completion fn (bound to '\t' by default) + rl_completion_entry_function = entry_completion_generator; // get user entry buf = readline(prompt); if (buf != NULL) { - string entry = buf; - - //enable auto-complete - rl_bind_key('\t', rl_complete); + string entry(buf); // parse it ret = parse(entry, prog);