Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Turning display attributes on / off in prompt strings



On Wed, Dec 21, 2022 at 8:46 AM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> The original problem was due to mixing raw sequences with prompt
> sequences, right? Any time we produce \e[0m we lose everything from
> the raw sequences.

Sure, but the idea is that we'd stop producing \e[0m and instead
output \e[24m to specifically turn off underlining.  However, if
suppose the prompt code has seen %S%U and then standout (reverse) was
disabled by a raw \e[27m, but for %u we output \e[24m\e[07m because we
chose not to re-optimize the current code, then we've broken things in
the other direction.

Ultimately there's no way to keep track of what any raw sequences have
done so the best outcome is to do as little as necessary to maintain
the state implied by the %-codes encountered so far while also making
the state change requested by the next %-code we find.

> Something like %u in a prompt will always send the
> off sequence regardless of whether underline was previously on. If
> we optimise that, we actually make the situation worse for mixtures

Right, we always need to send something.  We can't optimize (e.g.) %u
to less than \e[24m.

> underline on might have been done as a raw sequence. The only way to
> really solve that would be to parse the raw sequences.

Yeah, I'm not suggesting that.  It still doesn't work for e.g. using
${(%)%u} to find the underline-off code.

> The zle code does things differently.  [...]
> It'd be good to use the same interface for prompts, preferably also
> dropping the "NO" forms of the flags to free up some bits to add more
> attributes.

Zle has the advantage of always being in control of the entire state,
it never has to worry about attributes being toggled "behind it's
back" or to figure out what to do with ${(%)...}.

> The glitch handling using the "sg" and "ug" termcap sequences also seems
> to only be done for prompts but not ZLE. Do you know more about this?

I do not know anything about it other than that it's for slow
terminals that might not be able to keep up with the control
sequences.  Wayne would be the expert, I think.




Messages sorted by: Reverse Date, Date, Thread, Author