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

Turning display attributes on / off in prompt strings



Reviving another old discussion ...

On Tue, May 11, 2021 at 3:18 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On 5/9/21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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?




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