Exemple #1
0
/* Completion, from vi's point of view. */
int
rl_vi_complete (int ignore, int key)
{
  if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
    {
      if (!whitespace (rl_line_buffer[rl_point + 1]))
	rl_vi_end_word (1, 'E');
      rl_point++;
    }

  if (key == '*')
    rl_complete_internal ('*');	/* Expansion and replacement. */
  else if (key == '=')
    rl_complete_internal ('?');	/* List possible completions. */
  else if (key == '\\')
    rl_complete_internal (TAB);	/* Standard Readline completion. */
  else
    rl_complete (0, key);

  if (key == '*' || key == '\\')
    {
      _rl_vi_set_last (key, 1, rl_arg_sign);
      rl_vi_insertion_mode (ignore, key);
    }
  return (0);
}
Exemple #2
0
static el_status_t c_complete(void)
{
    char        *p, *q;
    char        *word, *string;
    size_t      len;
    int         unique;
    el_status_t s = CSdone;

    if (rl_inhibit_complete)
	return CSdispatch;

    word = el_find_word();
    p = rl_complete(word, &unique);
    if (word)
        free(word);
    if (p) {
        len = strlen(p);
        word = p;

        string = q = malloc(sizeof(char) * (2 * len + 1));
	if (!string) {
	    free(word);
	    return CSstay;
	}

        while (*p) {
            if ((*p < ' ' || strchr(SEPS, *p) != NULL)
                                && (!unique || p[1] != 0)) {
                *q++ = '\\';
            }
            *q++ = *p++;
        }
        *q = '\0';
        free(word);

        if (len > 0) {
            s = insert_string(string);
#ifdef CONFIG_TERMINAL_BELL
            if (!unique)
                el_ring_bell();
#endif
        }
        free(string);

        if (len > 0)
	    return s;
    }

    return c_possible();
}
Exemple #3
0
//------------------------------------------------------------------------------
static int completion_shim(int count, int invoking_key)
{
    int ret;

    // rl_complete checks if it was called previously.
    if (rl_last_func == completion_shim)
    {
        rl_last_func = rl_complete;
    }

    rl_begin_undo_group();
    ret = rl_complete(count, invoking_key);
    suffix_translation();
    rl_end_undo_group();

    g_slash_translation = 0;

    return ret;
}
static int complete(lua_State *L)
{
  const char* line;
  char* out = NULL;
  line = lua_tostring(L, 1);
  rl_insert_text(line);
  lua_pop(L, 1);
  rl_complete(0, 0);
  if(rl_outstream == NULL)
    return 0;
  if (!lua_istable(L, -1)) {
    out = rl_copy_text(0, rl_end);
    /* Nothing found */
    if (out[0] == '\0')
      lua_pushfstring(L, line);
    else
      lua_pushfstring(L, out);
    free(out);
  }
  rl_delete_text(0, rl_end);
  rl_point = 0;
  return 1;
}
Exemple #5
0
//------------------------------------------------------------------------------
static int completion_shim(int count, int invoking_key)
{
    int ret;

    // rl_complete checks if it was called previously.
    if (rl_last_func == completion_shim)
    {
        rl_last_func = rl_complete;
    }

    rl_begin_undo_group();
    ret = rl_complete(count, invoking_key);

    // readline's path completion may have appended a '/'. If so; flip it.
    if ((rl_point > 0) && (rl_line_buffer[rl_point - 1] == '/'))
    {
        rl_delete_text(rl_point - 1, rl_point);
        --rl_point;
        rl_insert_text("\\");
    }

    rl_end_undo_group();
    return ret;
}