Fix libedit a bit more and discourage from using it
This commit is contained in:
parent
633f7007d1
commit
b7b1198be7
|
@ -47,6 +47,9 @@ Build dependencies: CMake, pkg-config, help2man,
|
|||
Runtime dependencies: libev, Jansson, cURL, openssl,
|
||||
readline or libedit >= 2013-07-12,
|
||||
|
||||
Avoid libedit if you can, in general it works but at the moment history is
|
||||
acting up and I have no clue about fixing it.
|
||||
|
||||
$ git clone --recursive https://git.janouch.name/p/json-rpc-shell.git
|
||||
$ mkdir json-rpc-shell/build
|
||||
$ cd json-rpc-shell/build
|
||||
|
|
|
@ -619,7 +619,6 @@ input_el_on_run_editor (EditLine *editline, int key)
|
|||
static void
|
||||
input_el_install_prompt (struct input_el *self)
|
||||
{
|
||||
// XXX: the ignore doesn't quite work, see https://gnats.netbsd.org/47539
|
||||
el_set (self->editline, EL_PROMPT_ESC,
|
||||
input_el_make_prompt, INPUT_START_IGNORE);
|
||||
}
|
||||
|
@ -634,7 +633,7 @@ input_el_start (struct input *input, const char *program_name)
|
|||
el_set (self->editline, EL_CLIENTDATA, self);
|
||||
input_el_install_prompt (self);
|
||||
el_set (self->editline, EL_SIGNAL, false);
|
||||
el_set (self->editline, EL_UNBUFFERED, true);
|
||||
el_set (self->editline, EL_UNBUFFERED, isatty (fileno (stdin)));
|
||||
el_set (self->editline, EL_EDITOR, "emacs");
|
||||
el_wset (self->editline, EL_HIST, history_w, self->history);
|
||||
|
||||
|
@ -834,6 +833,17 @@ input_el_on_tty_readable (struct input *input)
|
|||
int count = 0;
|
||||
const wchar_t *buf = el_wgets (self->editline, &count);
|
||||
|
||||
// Editline works in a funny NO_TTY mode when the input is not a tty,
|
||||
// we cannot use EL_UNBUFFERED and expect sane results then
|
||||
int unbuffered = 0;
|
||||
if (!el_get (self->editline, EL_UNBUFFERED, &unbuffered) && !unbuffered)
|
||||
{
|
||||
char *entered_line = buf ? input_el_wcstombs (buf) : NULL;
|
||||
self->super.on_input (entered_line, self->super.user_data);
|
||||
free (entered_line);
|
||||
return;
|
||||
}
|
||||
|
||||
// Process data from our newline handler (async-friendly handling)
|
||||
if (self->entered_line)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue