-/*
- * Copyright (C) 2011 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2011 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
/** \file interactive.c Readline abstraction for interactive sessions. */
* 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)
{
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
* 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;
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)