mirror of
https://github.com/louisrubet/rpn
synced 2025-01-19 10:26:22 +01:00
Correct autocompletion (list not shown, files shown instead of commands)
This commit is contained in:
parent
5a334040eb
commit
2ae7516252
1 changed files with 4 additions and 17 deletions
21
src/parse.h
21
src/parse.h
|
@ -257,16 +257,6 @@ static bool _obj_from_string(const string& entry, object*& obj, unsigned int& ob
|
||||||
return ret;
|
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 char* entry_completion_generator(const char* text, int state)
|
||||||
{
|
{
|
||||||
static int list_index, len, too_far;
|
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. */
|
/* If no names matched, then return NULL. */
|
||||||
return NULL;
|
return (char*)NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,17 +332,14 @@ static ret_value entry(program& prog)
|
||||||
char *buf;
|
char *buf;
|
||||||
ret_value ret;
|
ret_value ret;
|
||||||
|
|
||||||
// declare completion fn
|
// declare completion fn (bound to '\t' by default)
|
||||||
rl_attempted_completion_function = entry_completion;
|
rl_completion_entry_function = entry_completion_generator;
|
||||||
|
|
||||||
// get user entry
|
// get user entry
|
||||||
buf = readline(prompt);
|
buf = readline(prompt);
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
{
|
{
|
||||||
string entry = buf;
|
string entry(buf);
|
||||||
|
|
||||||
//enable auto-complete
|
|
||||||
rl_bind_key('\t', rl_complete);
|
|
||||||
|
|
||||||
// parse it
|
// parse it
|
||||||
ret = parse(entry, prog);
|
ret = parse(entry, prog);
|
||||||
|
|
Loading…
Reference in a new issue