diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-09-02 19:35:38 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-09-02 20:00:10 +0200 |
commit | 444f97b35757f31890a3a62b0b2caa84d750f2a1 (patch) | |
tree | 347997b6886a4d0738939b750204fcd9261ada23 /degesch.c | |
parent | ed7130a66455bdea1fff02099ef5ed62fa695c34 (diff) | |
download | xK-444f97b35757f31890a3a62b0b2caa84d750f2a1.tar.gz xK-444f97b35757f31890a3a62b0b2caa84d750f2a1.tar.xz xK-444f97b35757f31890a3a62b0b2caa84d750f2a1.zip |
degesch: work around a libedit attribute issue
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -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 |