zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Turning display attributes on / off in prompt strings
Date: Wed, 21 Dec 2022 13:28:54 -0800	[thread overview]
Message-ID: <CAH+w=7ZiHj7y4a3hGU=da3ncyX4=So3vSkEYScMGQ2wSiOSDyQ@mail.gmail.com> (raw)
In-Reply-To: <33684-1671641189.906535@VXy1.awnj.CFc3>

On Wed, Dec 21, 2022 at 8:46 AM Oliver Kiddle <opk@zsh.org> 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.


  reply	other threads:[~2022-12-21 21:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 19:45 Bart Schaefer
2022-12-17  0:43 ` Oliver Kiddle
2022-12-17  7:50   ` Bart Schaefer
2022-12-17  9:47     ` Oliver Kiddle
2022-12-17 19:45       ` Bart Schaefer
2022-12-21 16:46         ` Oliver Kiddle
2022-12-21 21:28           ` Bart Schaefer [this message]
2022-12-21 17:12 ` Oliver Kiddle
2022-12-21 21:03   ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZiHj7y4a3hGU=da3ncyX4=So3vSkEYScMGQ2wSiOSDyQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=opk@zsh.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).