bug-readline
[Top][All Lists]
Advanced

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

Re: bracketed-paste-mode and gdb


From: Andrew Burgess
Subject: Re: bracketed-paste-mode and gdb
Date: Thu, 17 Feb 2022 19:46:44 +0000

Chet Ramey <chet.ramey@case.edu> writes:

> On 2/16/22 12:03 PM, Andrew Burgess wrote:
>> Chet Ramey <chet.ramey@case.edu> writes:
>> 
>>> On 2/15/22 12:21 PM, Andrew Burgess wrote:
>>>
>>>> I've tried two things, neither seem to quite work, as I don't think I
>>>> quite have all the information that I need.  I have a rough readline
>>>> patch below which I think solves the issue, but I'd like to explain
>>>> what I've tried so far, I'm hoping there might be a solution that
>>>> doesn't involve changing readline.
>
> I think that this requires readline to expose more internal information.
> The abstractions aren't quite there enough to allow a substitute deprep
> term function to have all the info available to the default one.
>
>>>>
>>>> My first thought was that I could use rl_deprep_term_function,
>>>> something like:
>>>>
>>>>     rl_deprep_term_function = gdb_rl_deprep_term_function;
>>>>
>>>>     void
>>>>     gdb_rl_deprep_term_function ()
>>>>     {
>>>>       if (/* Did we just receive eof? */)
>>>>         printf ("quit\n");
>>>>       rl_deprep_terminal ();
>>>>     }
>>>>
>>>> Obviously, I'm struggling with what the if condition should be.
>>>
>>> You can test your hypothesis by temporarily using _rl_eof_found as the
>>> `if' condition.
>> 
>> Interestingly, I notice that rl_deprep_terminal already contains this:
>> 
>>    if (terminal_prepped & TPX_BRACKPASTE)
>>      {
>>        fprintf (rl_outstream, BRACK_PASTE_FINI);
>>        if (_rl_eof_found)
>>      fprintf (rl_outstream, "\n");
>>      }
>> 
>> Notice the "\n" - this should have prevented the prompt corruption I'm
>> seeing, but this doesn't trigger.
>
> Right, that's what I'm driving at. There is already code in the existing
> terminal deprep function to deal with this case. Obviously, the code path
> in rl_callback_read_char needs to be dealt with.
>
> You can do it with two lines of code: one to initialize eof to 0, and one
> to set _rl_eof_found = eof before calling readline_internal_teardown,
> similar to the original RL_STATE_EOF proposal.
>
>
>> Anyway, with this patch applied you can take the example project from my
>> first email, and change cb_deprep_terminal like this:
>> 
>>    void
>>    cb_deprep_terminal (void)
>>    {
>>      extern int _rl_eof_found;
>>    
>>      if (_rl_eof_found)
>>        printf ("quit");
>>    
>>      rl_deprep_terminal ();
>>    }
>> 
>> And this works just as well as my original suggestion using a new
>> RL_STATE_EOF.
>> 
>> I guess, if your suggestion is to go with use _rl_eof_found, then this
>> would be made part of the public API, and renamed rl_eof_found, right?
>
> Right. I agree that this information is something that callback interface
> users would like to know, so let's figure out the best way to do it. Either
> way, it's an addition to the current readline API.

Thanks for the feedback.  I guess the next step to move this forward is
for me to draft an actual patch, with doc changes and all.  I'm happy to
work with either approach, the origina RL_STATE_EOF, or the rl_eof_found
strategy.  I guess I'd defer to your judgement for which you'd prefer.

Thanks,
Andrew




reply via email to

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