X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=interactive.c;h=8c4545b476e8f792ea7bba6f88b4e83fb952e540;hp=190cdf295130a2d711074e7c5f5927174b312076;hb=8181748ed84ac1e7d48ede7c00c9559263683791;hpb=767a4a54c967bc4b80bd14d02e89fe91acd848dd diff --git a/interactive.c b/interactive.c index 190cdf29..8c4545b4 100644 --- a/interactive.c +++ b/interactive.c @@ -45,7 +45,7 @@ static struct i9e_private i9e_private, *i9ep = &i9e_private; * running. * * \return A negative return value of zero means the i9e task terminated. Only - * in this case it is safe to call ie9_close(). + * in this case it is safe to call i9e_close(). */ int i9e_get_error(void) { @@ -556,7 +556,7 @@ __printf_2_3 void i9e_log(int ll, const char* fmt,...) * the given text. If the length of this text exceeds the width of the * terminal, the text is shortened by leaving out a part in the middle. */ -void ie9_print_status_bar(char *buf, unsigned len) +void i9e_print_status_bar(char *buf, unsigned len) { size_t x = i9ep->num_columns, y = (x - 4) / 2; @@ -762,17 +762,25 @@ int i9e_print_completions(struct i9e_completer *completers) ci.argc = create_argv(ci.buffer, " ", &ci.argv); ci.word_num = compute_word_num(ci.buffer, " ", ci.point); + /* determine the current word to complete */ end = ci.buffer + ci.point; + + if (*end == ' ') { + if (ci.point == 0 || ci.buffer[ci.point - 1] == ' ') { + ci.word = para_strdup(NULL); + goto create_matches; + } else /* The cursor is positioned right after a word */ + end--; + } for (p = end; p > ci.buffer && *p != ' '; p--) ; /* nothing */ if (*p == ' ') p++; - n = end - p + 1; ci.word = para_malloc(n + 1); strncpy(ci.word, p, n); ci.word[n] = '\0'; - +create_matches: PARA_DEBUG_LOG("line: %s, point: %d (%c), wordnum: %d, word: %s\n", ci.buffer, ci.point, ci.buffer[ci.point], ci.word_num, ci.word); if (ci.word_num == 0)