bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Issue with multibyte and non-visible characters in pr


From: Chet Ramey
Subject: Re: [Bug-readline] Issue with multibyte and non-visible characters in prompt
Date: Thu, 20 Apr 2017 11:24:53 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 4/19/17 9:47 PM, Brian wrote:
> Hi,
> 
> I am running into an issue while trying the following program with
> readline 7.0.003-1:
> 
> #include <stdio.h>
> #include <readline/readline.h>
> 
> int main(int argc, char **argv) {
>     char prompt[] = "\x1B[36;1m> \x1B[0m";
> 
>     printf("prompt length: %i\n", sizeof prompt);
> 
>     while (readline(prompt)) { }
> 
>     return 0;
> }
> 
> 
> If I type a long word and then try to delete it with ctrl-w like this:
> 
>> aaaaaaaaaaaaaaaaaaaaaaa^W
> 
> The result would be (being unable to clean the rest):
> 
>> aaaaaaaaaaa
> 
> Note that this have a length of 13 characters, the same size of PROMPT
> (without \0). The actual content of the returned buffer is just an empty
> string.

You need to bracket sequences of non-printing characters in the prompt
with RL_PROMPT_START_IGNORE (0x01) and RL_PROMPT_END_IGNORE (0x02) so
readline knows those characters don't consume screen space when it
performs redisplay.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]