Setup: Readline 6.3, gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Identical behaviour with xterm and gnome-terminal.
When I call readline with a prompt string containing CSI sequences and try to enter multiline input, and I get close before the end of the first line, the cursor is reset to the beginning of the line. Any more input then overwrites the prompt message, and then the previous input. After that, it is possible to fill the whole line with characters and get to the next line. Readline simply doesn't consider that not all of the prompt string's characters are printable.
Example source:
#define HANDLE_MULTIBYTE // not sure if this should help, doesn't work without it, either
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
char *input;
while((input = readline("\033[1;31mEnter input:\033[0m")) != NULL)
printf("You entered: %s\n", input);
}
After a quick skim through the sources, it seems that such prompt strings are not supported. Or are they? If not, is there a workaround?