zsh-workers
 help / color / mirror / code / Atom feed
* Turning display attributes on / off in prompt strings
@ 2022-12-16 19:45 Bart Schaefer
  2022-12-17  0:43 ` Oliver Kiddle
  2022-12-21 17:12 ` Oliver Kiddle
  0 siblings, 2 replies; 9+ messages in thread
From: Bart Schaefer @ 2022-12-16 19:45 UTC (permalink / raw)
  To: Zsh hackers list

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?


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-21 21:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 19:45 Turning display attributes on / off in prompt strings 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
2022-12-21 17:12 ` Oliver Kiddle
2022-12-21 21:03   ` Bart Schaefer

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).