]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - interactive.c
Merge topic branch t/sf_float into pu
[paraslash.git] / interactive.c
index 812a7d5bef8a37bd3ebdbd5a2484b735827a3395..4d48742f686862bb8d5fe8871116925309dbc978 100644 (file)
@@ -189,8 +189,6 @@ static char **i9e_completer(const char *text, int start, __a_unused int end)
  *
  * This function attaches the i9e input queue to an output queue of \a
  * producer.
- *
- * \return Standard.
  */
 void i9e_attach_to_stdout(struct btr_node *producer)
 {
@@ -231,6 +229,7 @@ void i9e_close(void)
        rl_callback_handler_remove();
        if (hf)
                write_history(hf);
+       clear_history();
        wipe_bottom_line();
        fcntl(i9ep->ici->fds[0], F_SETFL, i9ep->fd_flags[0]);
        fcntl(i9ep->ici->fds[1], F_SETFL, i9ep->fd_flags[1]);
@@ -289,7 +288,7 @@ static int i9e_post_monitor(__a_unused struct sched *s, __a_unused void *context
        char *buf;
        size_t sz, consumed = 0;
 
-       ret = -E_I9E_EOF;
+       ret = -E_EOF;
        if (i9ep->input_eof)
                goto rm_btrn;
        ret = -E_I9E_TERM_RQ;
@@ -308,7 +307,7 @@ static int i9e_post_monitor(__a_unused struct sched *s, __a_unused void *context
                                        goto rm_btrn;
                                }
                                if (ret == 0) {
-                                       ret = -E_I9E_EOF;
+                                       ret = -E_EOF;
                                        goto rm_btrn;
                                }
                                buf[1] = '\0';
@@ -636,7 +635,7 @@ int i9e_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 int i9e_extract_completions(const char *word, char **string_list,
                char ***result)
 {
-       char **matches = para_malloc(sizeof(char *));
+       char **matches = alloc(sizeof(char *));
        int match_count = 0, matches_len = 1;
        char **p;
        int len = strlen(word);
@@ -647,8 +646,8 @@ int i9e_extract_completions(const char *word, char **string_list,
                match_count++;
                if (match_count >= matches_len) {
                        matches_len *= 2;
-                       matches = para_realloc(matches,
-                               matches_len * sizeof(char *));
+                       matches = arr_realloc(matches, matches_len,
+                               sizeof(char *));
                }
                matches[match_count - 1] = para_strdup(*p);
        }
@@ -684,7 +683,7 @@ char **i9e_complete_commands(const char *word, struct i9e_completer *completers)
                if (is_prefix(word, cmd, len))
                        match_count++;
        }
-       matches = para_malloc((match_count + 1) * sizeof(*matches));
+       matches = arr_alloc(match_count + 1, sizeof(*matches));
        for (i = 0, match_count = 0; (cmd = completers[i].name); i++)
                if (is_prefix(word, cmd, len))
                        matches[match_count++] = para_strdup(cmd);
@@ -768,7 +767,7 @@ int i9e_print_completions(struct i9e_completer *completers)
        if (*p == ' ')
                p++;
        n = end - p + 1;
-       ci.word = para_malloc(n + 1);
+       ci.word = alloc(n + 1);
        strncpy(ci.word, p, n);
        ci.word[n] = '\0';
 create_matches:
@@ -796,3 +795,25 @@ create_matches:
        free(ci.word);
        return ret;
 }
+
+/**
+ * Complete on severity strings.
+ *
+ * \param ci See struct \ref i9e_completer.
+ * \param cr See struct \ref i9e_completer.
+ *
+ * This is used by para_client and para_audioc which need the same completion
+ * primitive for the ll server/audiod command. Both define their own completer
+ * which is implemented as a trivial wrapper that calls this function.
+ */
+void i9e_ll_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr)
+{
+       char *sev[] = {SEVERITIES, NULL};
+
+       if (ci->word_num != 1) {
+               cr->matches = NULL;
+               return;
+       }
+       i9e_extract_completions(ci->word, sev, &cr->matches);
+}