aboutsummaryrefslogtreecommitdiff
path: root/client/rl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/rl.cpp')
-rw-r--r--client/rl.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/client/rl.cpp b/client/rl.cpp
index 2fdd356..b8113aa 100644
--- a/client/rl.cpp
+++ b/client/rl.cpp
@@ -82,7 +82,7 @@ static char** rl_attempted_completion(const char * text, int start, int end) {
cmd_t cmd = cmds[i];
if (cmd.complete == NULL) continue;
if (strncmp(cmd.name, rl_line_buffer + cmd_start, cmd_len) != 0) continue;
- return cmd.complete(rl_line_buffer, start, end);
+ return cmd.complete(text, start, end);
}
// else, no completion available
@@ -107,3 +107,15 @@ int cli_main() {
return EXIT_SUCCESS;
}
+int rl_word(const char * line, int cursor) {
+ int word = -1;
+ for (int i = 0; line[i] != '\0';) {
+ i += strspn(line + i, IFS);
+ int len = strcspn(line + i, IFS);
+ word++;
+ i += len;
+ if (i > cursor) break;
+ }
+ return word;
+}
+