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

Re: End boldface also ends background color



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.



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