zsh-workers
 help / color / mirror / code / Atom feed
* Colors showing when TERM=dumb.
@ 2012-03-05  6:35 John Gregorski
  2012-03-05 10:27 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: John Gregorski @ 2012-03-05  6:35 UTC (permalink / raw)
  To: zsh-workers

While playing around with my prompt I noticed that when TERM=dumb,
stuff like %B %U %S have no effect, but %F %K still print out terminal
escapes. Is this a bug? To work around it, I hacked putpromptchar in
prompt.c like this:

@@ -501,7 +501,7 @@
                        bv->fm--;
                } else
                    arg = match_colour(NULL, 1, arg);
-               if (arg >= 0 && !(arg & TXTNOFGCOLOUR)) {
+               if (arg >= 0 && !(arg & TXTNOFGCOLOUR) && tccan (TCFGCOLOUR)) {
                    txtchangeset(txtchangep, arg & TXT_ATTR_FG_ON_MASK,
                                 TXTNOFGCOLOUR);
                    txtset(arg & TXT_ATTR_FG_ON_MASK);
@@ -510,9 +510,11 @@
                }
                /* else FALLTHROUGH */
            case 'f':
+               if (tccan (TCFGCOLOUR)) {
                txtchangeset(txtchangep, TXTNOFGCOLOUR, TXT_ATTR_FG_ON_MASK);
                txtunset(TXT_ATTR_FG_ON_MASK);
                set_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, TSC_PROMPT);
+               }
                break;
            case 'K':
                if (bv->fm[1] == '{') {
@@ -522,7 +524,7 @@
                        bv->fm--;
                } else
                    arg = match_colour(NULL, 0, arg);
-               if (arg >= 0 && !(arg & TXTNOBGCOLOUR)) {
+               if (arg >= 0 && !(arg & TXTNOBGCOLOUR) && tccan (TCBGCOLOUR)) {
                    txtchangeset(txtchangep, arg & TXT_ATTR_BG_ON_MASK,
                                 TXTNOBGCOLOUR);
                    txtset(arg & TXT_ATTR_BG_ON_MASK);
@@ -531,9 +533,11 @@
                }
                /* else FALLTHROUGH */
            case 'k':
+               if (tccan (TCBGCOLOUR)) {
                txtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);
                txtunset(TXT_ATTR_BG_ON_MASK);
                set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, TSC_PROMPT);
+               }
                break;
            case '[':
                if (idigit(*++bv->fm))


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

* Re: Colors showing when TERM=dumb.
  2012-03-05  6:35 Colors showing when TERM=dumb John Gregorski
@ 2012-03-05 10:27 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2012-03-05 10:27 UTC (permalink / raw)
  To: zsh-workers

On Sun, 4 Mar 2012 22:35:42 -0800
John Gregorski <jfgorski@gmail.com> wrote:
> While playing around with my prompt I noticed that when TERM=dumb,
> stuff like %B %U %S have no effect, but %F %K still print out terminal
> escapes. Is this a bug? To work around it, I hacked putpromptchar in
> prompt.c like this:

It's not quite that simple, since actually for named colours we just
output the ANSI sequences as the best guess for what's likely to produce
those, since the mapping from names to numbers isn't defined by termcap.
That will happen regardless of termcap.  So turning them off works, too.

Howver, obviously if you're not outputting termcap, then there's no
point outputting anything resetting it.  I'm not sure what a general fix
is.  Hmm... we keep track of what we've changed, maybe we could keep
track of termcap and ANSI colour handling separately; then your change
would apply with an additional check that we didn't have the bit for
ANSI colour handling set.

I don't think you could take that there's a guarantee that any kind of
terminal, even dumb, doesn't output terminal sequences, however, even
though I can see that could be useful.  That would need a special case
we don't have at the moment.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


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

end of thread, other threads:[~2012-03-05 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05  6:35 Colors showing when TERM=dumb John Gregorski
2012-03-05 10:27 ` Peter Stephenson

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