xC: improve Readline completion

The autocomplete for /set used to be extremely annoying,
and menu-complete-display-prefix also prevents mistaken highlights.

One downside is that using plain Tab in channels no longer
just inserts the last-talking nickname, one needs to press it twice.
This commit is contained in:
Přemysl Eric Janouch 2022-09-18 02:40:53 +02:00
parent ff243c1d11
commit 21e5d80ab1
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 15 additions and 0 deletions

3
NEWS
View File

@ -18,6 +18,9 @@
* xC: unsolicited JOINs will no longer automatically activate the buffer * xC: unsolicited JOINs will no longer automatically activate the buffer
* xC: made Readline insert the longest common completion prefix first,
and prevented the possible-completions command from duplicating the prompt
* xC: normalized editline's history behaviour, making it a viable frontend * xC: normalized editline's history behaviour, making it a viable frontend
* xC: various bugfixes * xC: various bugfixes

12
xC.c
View File

@ -14434,6 +14434,15 @@ app_readline_completion (const char *text, int start, int end)
return make_input_completions (g_ctx, rl_line_buffer, start, end); return make_input_completions (g_ctx, rl_line_buffer, start, end);
} }
static void
app_readline_display_matches (char **matches, int len, int longest)
{
struct app_context *ctx = g_ctx;
CALL (ctx->input, hide);
rl_display_match_list (matches, len, longest);
CALL (ctx->input, show);
}
static int static int
app_readline_init (void) app_readline_init (void)
{ {
@ -14458,7 +14467,10 @@ app_readline_init (void)
rl_bind_key (RETURN, rl_named_function ("send-line")); rl_bind_key (RETURN, rl_named_function ("send-line"));
CALL_ (self, bind_control, 'j', "send-line"); CALL_ (self, bind_control, 'j', "send-line");
rl_completion_display_matches_hook = app_readline_display_matches;
rl_variable_bind ("completion-ignore-case", "on"); rl_variable_bind ("completion-ignore-case", "on");
rl_variable_bind ("menu-complete-display-prefix", "on");
rl_bind_key (TAB, rl_named_function ("menu-complete")); rl_bind_key (TAB, rl_named_function ("menu-complete"));
if (key_btab) if (key_btab)
CALL_ (self, bind, key_btab, "menu-complete-backward"); CALL_ (self, bind, key_btab, "menu-complete-backward");