degesch: work around a libedit attribute issue
This commit is contained in:
parent
ed7130a664
commit
444f97b357
19
degesch.c
19
degesch.c
@ -1089,7 +1089,6 @@ input_el_show (void *input)
|
||||
return;
|
||||
|
||||
input_el__restore (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);
|
||||
input_el__redisplay (self);
|
||||
@ -5939,18 +5938,32 @@ on_refresh_prompt (struct app_context *ctx)
|
||||
|
||||
struct str prompt = str_make ();
|
||||
make_prompt (ctx, &prompt);
|
||||
|
||||
// libedit has a weird bug where it misapplies ignores when they're not
|
||||
// followed by anything else, so let's try to move a trailing space,
|
||||
// which will at least fix the default prompt.
|
||||
const char *attributed_suffix = "";
|
||||
#ifdef HAVE_EDITLINE
|
||||
if (have_attributes && prompt.len && prompt.str[prompt.len - 1] == ' ')
|
||||
{
|
||||
prompt.str[--prompt.len] = 0;
|
||||
attributed_suffix = " ";
|
||||
}
|
||||
#endif // HAVE_EDITLINE
|
||||
|
||||
char *localized = iconv_xstrdup (ctx->term_from_utf8, prompt.str, -1, NULL);
|
||||
str_free (&prompt);
|
||||
|
||||
if (have_attributes)
|
||||
{
|
||||
// XXX: to be completely correct, we should use tputs, but we cannot
|
||||
input_maybe_set_prompt (ctx->input, xstrdup_printf ("%c%s%c%s%c%s%c",
|
||||
input_maybe_set_prompt (ctx->input, xstrdup_printf ("%c%s%c%s%c%s%c%s",
|
||||
INPUT_START_IGNORE, ctx->attrs[ATTR_PROMPT],
|
||||
INPUT_END_IGNORE,
|
||||
localized,
|
||||
INPUT_START_IGNORE, ctx->attrs[ATTR_RESET],
|
||||
INPUT_END_IGNORE));
|
||||
INPUT_END_IGNORE,
|
||||
attributed_suffix));
|
||||
free (localized);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user