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: 林宏雄
Subject: Re: [Bug-readline] Issue with multibyte and non-visible characters in prompt
Date: Sat, 22 Apr 2017 17:43:52 +0900

Dear Chet Ramey,

This is a FAQ.

As Brian wrote, RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE are described at only rl_expand_promt()  in the Section 2.4.6 Redisplay as follows;

> Applications may indicate that the prompt contains characters that take up no physical screen space when displayed by bracketing
>  a sequence of such characters with the special markers RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE
> (declared in `readline.h'). This may be used to embed terminal-specific escape sequences in prompts.

I think most programmers who try to use the GNU Readline Library only see the section 2.1 Basic Behavior where rl_readline() is described.
I suggest you to move the sentences above to the Section 2.1 (or to every function which has "char *prompt" argument, but this may be too much...).

Regards,

2017-04-21 1:09 GMT+09:00 Brian <address@hidden>:
Ah, thank you very much Chet. I couldn't find this the first time I
checked the documentation, but now I see it (rl_expand_prompt).

Thanks again,

 Brian


On 04/20/2017 08:24 AM, Chet Ramey wrote:
> 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.
>


_______________________________________________
Bug-readline mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-readline



--
Hiroo Hayashi

reply via email to

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