From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Turning display attributes on / off in prompt strings
Date: Fri, 16 Dec 2022 11:45:22 -0800 [thread overview]
Message-ID: <CAH+w=7Yt757b8erwTo5Y1+1fBSQbShV6XCaM8q6wnkGZHmQqeA@mail.gmail.com> (raw)
Reviving another old discussion ...
On Tue, May 11, 2021 at 3:18 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 5/9/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > Does anyone know why
> > putpromptchar() has this?
> > case 'b':
> > txtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE);
> > txtunset(TXTBOLDFACE);
> > tsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY);
> > break;
> > That is, why TCALLATTRSOFF ? That isn't done for %s or %u ... why is
> > there no TCBOLDFACEEND defined?
>
> I think that's a shortcoming in termcap and/or terminfo. In termcap
> there is md (1m) and me (0m) that should correspond to bold, but 0m
> turns off all attributes. Compare with us (4m) and ue (24m).
So ... I've been playing with this, and on my "xterm-color" terminal
se and ue are both $'\e[m' -- and yet "print -P" and ${(%)...} and so
on do "the right thing" and output extra control sequences depending
on what other attributes are active. For example
print -P %U%B%S...%u...
outputs $'\e[4m\e[1m\e[7m...\e[m\e[1m\e[7m...' -- it has recorded
(txtchangeset) the three attributes and then properly restores the
ones that are not intended to be turned off.
So the problem from the original thread (workers/48800 and refs) is
that you can't mix in "raw" sequences for attributes that prompt.c
doesn't "know about" lest those attributes become disabled every time
%s, %u, or definitely %b on any terminal, is used.
> https://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_4.html
> also implies that there is no specific termcap sequence to only turn
> off specific appearance modes.
[...]
> Since we already assume ANSI for things like colors, I don't think we
> would lose a lot of compatibility in practice if we just use 22
> instead of 0 for %b, but we could potentially put it behind a setopt?
In connection with Oliver's patch to eat CSI sequences ... perhaps we
should abandon looking up termcap strings for these attributes, or at
least have a fallback to the ANSI set when we encounter a termcap
result that's not specific enough?
next reply other threads:[~2022-12-16 19:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 19:45 Bart Schaefer [this message]
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
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=7Yt757b8erwTo5Y1+1fBSQbShV6XCaM8q6wnkGZHmQqeA@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--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).