diff options
-rw-r--r-- | degesch.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -6028,6 +6028,14 @@ make_prompt (struct app_context *ctx, struct str *output) static void input_maybe_set_prompt (struct input *self, char *new_prompt) { + // Fix libedit's expectations to see a non-control character following + // the end mark (see prompt.c and literal.c) by cleaning this up + for (char *p = new_prompt; *p; ) + if (p[0] == INPUT_END_IGNORE && p[1] == INPUT_START_IGNORE) + memmove (p, p + 2, strlen (p + 2) + 1); + else + p++; + // Redisplay can be an expensive operation const char *prompt = CALL (self, get_prompt); if (prompt && !strcmp (new_prompt, prompt)) @@ -6055,6 +6063,12 @@ on_refresh_prompt (struct app_context *ctx) prompt.str[--prompt.len] = 0; attributed_suffix = " "; } + + // Also enable a uniform interface for prompt hooks by assuming it uses + // GNU Readline escapes: turn this into libedit's almost-flip-flop + for (size_t i = 0; i < prompt.len; i++) + if (prompt.str[i] == '\x01' || prompt.str[i] == '\x02') + prompt.str[i] = INPUT_START_IGNORE /* == INPUT_END_IGNORE */; #endif // HAVE_EDITLINE char *localized = iconv_xstrdup (ctx->term_from_utf8, prompt.str, -1, NULL); |