zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: End boldface also ends background color
Date: Wed, 23 Mar 2016 18:53:56 -0700	[thread overview]
Message-ID: <160323185356.ZM2458@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3S_837wMcu0VgFkuWmrFsmdGT6Tqg4euxvjky=8HOfuGA@mail.gmail.com>

On Mar 22, 10:00pm, Mikael Magnusson wrote:
}
} The code for ending bold sequences is usually ^[[22m but %b sends
} ^[[0m which resets most things. As far as I know, termcap
} unfortunately doesn't include the code that only ends bold, so there's
} no way for zsh to know what it is. Zsh doesn't hardcode any of these
} sequences because they can vary across terminals.

The code for this in prompt.c is interesting:

	    case 'b':
		txtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE);
		txtchangeset(txtchangep, TXTNOSTANDOUT, TXTSTANDOUT);
		txtchangeset(txtchangep, TXTNOUNDERLINE, TXTUNDERLINE);
		txtunset(TXTBOLDFACE);
		tsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY);
		break;

If you look at zsh.h where the TC* flags are defined:

#define TCBOLDFACEBEG  18
#define TCSTANDOUTBEG  19
#define TCUNDERLINEBEG 20
#define TCALLATTRSOFF  21
#define TCSTANDOUTEND  22
#define TCUNDERLINEEND 23

There's no TCBOLDFACEEND, which I presume is why %b resorts to turning
off everything.  But I don't know much about how the txt* macros work.

In any case this code pre-dates the ability to set colors with %F by
several years, and probably wasn't updated when %F was added.  Given
that the color attributes are stored in the txtchangep set, it should
be possible to turn them back on after TCALLATTRSOFF disables bold, if
somebody who *does* know how this works wants to dive in.

Aside:

The doc for %F references zle_highlight which implies that you should
be able to do %F{bold} but that doesn't work, and the numeric color
values supported are not the ANSI color attributes.  The doc should
probably be tightened up to reflect this.


  reply	other threads:[~2016-03-24  1:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 19:44 Dominik Ritter
2016-03-22 21:00 ` Mikael Magnusson
2016-03-24  1:53   ` Bart Schaefer [this message]
2016-03-24 10:38     ` Peter Stephenson
2016-03-24 14:53       ` Danek Duvall
2016-03-24 17:26         ` Bart Schaefer
2016-03-24 18:08           ` Danek Duvall
2016-03-24 17:21       ` Mikael Magnusson
2016-03-24 17:33       ` Bart Schaefer
2016-03-24 17:39         ` Peter Stephenson
2016-03-24 18:00           ` Bart Schaefer
     [not found]     ` <20160324103837.678f2f36__45846.6877033517$1458816008$gmane$org@pwslap01u.europe.root.pri>
2016-03-24 18:20       ` Stephane Chazelas
2016-03-24 21:34         ` Bart Schaefer
2016-03-24 22:43           ` Mikael Magnusson
2016-03-25  0:23             ` 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=160323185356.ZM2458@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).