X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=interactive.c;h=a8197308e8323c8fe78546117cc2e9479df0fbfd;hp=c34a0f6eb3c5ff3fd6fcb0e85546a180d21fd880;hb=ba83a291cd486e8ab53ac64d81b17d8f5705d715;hpb=dda88dcb390a44e1f1f68f6248ed513c75dce4bf diff --git a/interactive.c b/interactive.c index c34a0f6e..a8197308 100644 --- a/interactive.c +++ b/interactive.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2011 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2011 Andre Noll , see file COPYING. */ /** \file interactive.c Readline abstraction for interactive sessions. */ @@ -206,26 +202,7 @@ void i9e_attach_to_stdout(struct btr_node *producer) static void wipe_bottom_line(void) { - char x[] = " "; - int n = i9ep->num_columns; - - /* - * For reasons beyond my understanding, writing more than 68 characters - * here causes MacOS to mess up the terminal. Writing a line of spaces - * in smaller chunks works fine though. Weird. - */ - fprintf(i9ep->stderr_stream, "\r"); - while (n > 0) { - if (n >= sizeof(x)) { - fprintf(i9ep->stderr_stream, "%s", x); - n -= sizeof(x); - continue; - } - x[n] = '\0'; - fprintf(i9ep->stderr_stream, "%s", x); - break; - } - fprintf(i9ep->stderr_stream, "\r"); + fprintf(i9ep->stderr_stream, "\r%s\r", i9ep->empty_line); } #ifndef RL_FREE_KEYMAP_DECLARED @@ -785,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)