diff --git a/xC.c b/xC.c index 37783b7..1f4ff0f 100644 --- a/xC.c +++ b/xC.c @@ -13698,19 +13698,33 @@ on_editline_complete (EditLine *editline, int key) // Insert the best match instead el_insertstr (editline, completions[0]); + + // I'm not sure if Readline's menu-complete can at all be implemented + // with Editline--we have no way of detecting what the last executed handler + // was. Employ the formatter's wrapping feature to spew all options. bool only_match = !completions[1]; + if (!only_match) + { + CALL (ctx->input, hide); + redraw_screen (ctx); + + struct formatter f = formatter_make (ctx, NULL); + for (char **p = completions; *++p; ) + formatter_add (&f, " #l", *p); + formatter_add (&f, "\n"); + formatter_flush (&f, stdout, 0); + formatter_free (&f); + + CALL (ctx->input, show); + } + for (char **p = completions; *p; p++) free (*p); free (completions); - - // I'm not sure if Readline's menu-complete can at all be implemented - // with Editline. Spamming the terminal with possible completions - // probably isn't what the user wants and we have no way of detecting - // what the last executed handler was. if (!only_match) return CC_REFRESH_BEEP; - // But if there actually is just one match, finish the word + // If there actually is just one match, finish the word el_insertstr (editline, " "); return CC_REFRESH; }