diff options
author | Steve Bennett <steveb@workware.net.au> | 2017-09-15 11:53:03 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2017-09-15 12:11:33 +1000 |
commit | 93af9c4cfbf383f5cf146a95711008dcb052b278 (patch) | |
tree | dd85e44cbbc1f46b29b20e1fcd29e0a058b68ab0 /jim-history.c | |
parent | 0d3a4d11d6242e482df3896f0b28ca9bbc8f538a (diff) | |
download | jimtcl-93af9c4cfbf383f5cf146a95711008dcb052b278.zip jimtcl-93af9c4cfbf383f5cf146a95711008dcb052b278.tar.gz jimtcl-93af9c4cfbf383f5cf146a95711008dcb052b278.tar.bz2 |
history: Add autocompletion support
With 'history completion <cmd>'
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-history.c')
-rw-r--r-- | jim-history.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/jim-history.c b/jim-history.c index 9a56e04..fe6e628 100644 --- a/jim-history.c +++ b/jim-history.c @@ -9,7 +9,7 @@ static int history_cmd_getline(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { Jim_Obj *objPtr; - char *line = Jim_HistoryGetline(Jim_String(argv[0])); + char *line = Jim_HistoryGetline(interp, Jim_String(argv[0])); /* On EOF returns -1 if varName was specified; otherwise the empty string. */ if (line == NULL) { @@ -35,6 +35,12 @@ static int history_cmd_getline(Jim_Interp *interp, int argc, Jim_Obj *const *arg return JIM_OK; } +static int history_cmd_setcompletion(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +{ + Jim_HistorySetCompletion(interp, Jim_Length(argv[0]) ? argv[0] : NULL); + return JIM_OK; +} + static int history_cmd_load(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { Jim_HistoryLoad(Jim_String(argv[0])); @@ -67,6 +73,13 @@ static const jim_subcmd_type history_command_table[] = { 2, /* Description: Reads one line from the user. Similar to gets. */ }, + { "completion", + "command", + history_cmd_setcompletion, + 1, + 1, + /* Description: Sets an autocompletion callback command, or none if "" */ + }, { "load", "filename", history_cmd_load, |