Compare commits

...

3 Commits

Author SHA1 Message Date
897a263ee7 Readline: make M-Enter insert a newline
Before, it was only possible with C-v C-j but it's too useful
to require such an awkward method.

There is a precedent in, e.g., zsh and fish for the new binding.
2020-10-09 20:41:37 +02:00
84702fa47d Fix handling terminal resizes while the terminal is suspended
GNU Readline has a misfeature.
2020-10-09 20:21:52 +02:00
b315892249 Readline: fix a dormant bug in prompt changes
For details, see a similar change in degesch from uirc3.
2020-10-09 20:17:17 +02:00

View File

@@ -246,11 +246,23 @@ input_rl_on_run_editor (int count, int key)
return 0;
}
static int
input_rl_newline_insert (int count, int key)
{
(void) count;
(void) key;
rl_insert_text ("\n");
return 0;
}
static int
input_rl_on_startup (void)
{
rl_add_defun ("run-editor", input_rl_on_run_editor, -1);
rl_bind_keyseq ("\\ee", rl_named_function ("run-editor"));
rl_add_defun ("newline-insert", input_rl_newline_insert, -1);
rl_bind_keyseq ("\\e\\r", rl_named_function ("newline-insert"));
return 0;
}
@@ -268,6 +280,7 @@ input_rl_start (struct input *input, const char *program_name)
rl_readline_name = slash ? ++slash : program_name;
rl_startup_hook = input_rl_on_startup;
rl_catch_sigwinch = false;
rl_change_environment = false;
hard_assert (self->prompt != NULL);
rl_callback_handler_install (self->prompt, input_rl_on_input);
@@ -360,17 +373,15 @@ input_rl_set_prompt (struct input *input, char *prompt)
free (self->prompt);
self->prompt = prompt;
if (!self->active)
if (!self->active || self->prompt_shown <= 0)
return;
// First reset the prompt to work around a bug in readline
rl_set_prompt ("");
if (self->prompt_shown > 0)
rl_redisplay ();
rl_redisplay ();
rl_set_prompt (self->prompt);
if (self->prompt_shown > 0)
rl_redisplay ();
rl_redisplay ();
}
static bool
@@ -2716,6 +2727,7 @@ static void
resume_terminal (struct app_context *ctx)
{
ctx->input->vtable->prepare (ctx->input, true);
ctx->input->vtable->on_terminal_resized (ctx->input);
ev_io_start (EV_DEFAULT_ &ctx->tty_watcher);
ctx->input->vtable->show (ctx->input);
}