Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] prompt: support generic non-visible regions
- X-seq: zsh-workers 50466
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx, Oliver Kiddle <opk@xxxxxxx>, dana <dana@xxxxxxx>
- Subject: Re: [PATCH] prompt: support generic non-visible regions
- Date: Thu, 11 Aug 2022 14:44:20 -0500
- Archived-at: <https://zsh.org/workers/50466>
- In-reply-to: <CAN=4vMqsk7BjpKXdeg-L3ULssWcnH1uryy37mgXyakCCkJ0R=w@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <20220810115120.182853-1-felipe.contreras@gmail.com> <CAN=4vMqHNZJ7BvCCNbD7-0nPr1CbN1ecHQVxSsaZQ1Ao13__jg@mail.gmail.com> <CAN=4vMqwjOtABPgDsXioP7NBxw=O3RRbDt7ZB7CLHtTR-omvPw@mail.gmail.com> <CAMP44s31Q75TcF4Wn9woPbKO8fcC=-WDqfQV8Z8G-55oz_HLvQ@mail.gmail.com> <CAN=4vMqsk7BjpKXdeg-L3ULssWcnH1uryy37mgXyakCCkJ0R=w@mail.gmail.com>
On Thu, Aug 11, 2022 at 2:35 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Thu, Aug 11, 2022 at 9:24 PM Felipe Contreras
> <felipe.contreras@xxxxxxxxx> wrote:
> >
> > On Thu, Aug 11, 2022 at 12:24 PM Roman Perepelitsa
> > <roman.perepelitsa@xxxxxxxxx> wrote:
> > >
> > > On Thu, Aug 11, 2022 at 4:37 PM Roman Perepelitsa
> > > <roman.perepelitsa@xxxxxxxxx> wrote:
> > > >
> > > > I like this patch [...]
> > >
> > > I should've said that I like the idea behind it. The patch implements
> > > one part of it. To complete the implementation percent expansion needs
> > > to output \001 and \002.
> >
> > That's easy. The current code in prompt.c uses Inpar and Outpar, which
> > are 0x88 and 0x8A respectively. If instead we do:
> >
> > #define invis_start ((char) 0x01)
> > #define invis_end ((char) 0x02)
> >
> > And replace Inpar/Outpar with invis_start/invis_end the code should
> > behave identically (since those characters are removed).
> >
> > Then in promptexpand() we simply not remove them.
>
> Let me clarify. Ideally we want (I think) for these two tests to pass:
>
> 1.
>
> [[ $(print -r -- ${(%):-'%{hello%}'}) == hello ]]
>
> 2.
>
> [[ $(print -r -- ${(m)#${(%):-'%F{1}❎%f'}}) == 2 ]]
>
> The first test currently passes, the second fails. In my previous
> comment I tried to say that making the second test pass will cause the
> first test to fail.
>
> Do you see how to make both of these tests pass?
We could add a mode to the % flag which is passed to promptexpand() in
order to tell it to not remove the invisible start/end markers.
However, in my tests this simply adds two characters to $((m)#...}. I
don't see how this would return the correct amount of visible
characters.
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author