Richard Hartmann | 19 Jul 01:10

Problem with color codes

Hi all,

I switched from old, hardcoded color variables over to the colors function.
For some reason, this confuses zsh when calculating the width of my
prompt. It is worth nothing that RPS1 is also affected even though

  echo $((${COLUMNS} - 1))

shows the correct width. I am attaching a screenshot with 7 kiB. I
really do hope that is OK, if not, please feel free to cuss at me. My
$PS1 and $RPS1 defintion files are attached, as well.
ZSH 4.3.4 & 4.3.6 show the same behaviour, I could not find any
other versions to test with.

Thanks for all input,
Richard
Attachment (buildPS1): application/octet-stream, 497 bytes
Attachment (buildRPS1): application/octet-stream, 1446 bytes
Mikael Magnusson | 19 Jul 01:26
Gravatar

Re: Problem with color codes

2008/7/19 Richard Hartmann <richih.mailinglist <at> gmail.com>:
> Hi all,
>
> I switched from old, hardcoded color variables over to the colors function.
> For some reason, this confuses zsh when calculating the width of my
> prompt. It is worth nothing that RPS1 is also affected even though
>
>  echo $((${COLUMNS} - 1))
>
> shows the correct width. I am attaching a screenshot with 7 kiB. I
> really do hope that is OK, if not, please feel free to cuss at me. My
> $PS1 and $RPS1 defintion files are attached, as well.
> ZSH 4.3.4 & 4.3.6 show the same behaviour, I could not find any
> other versions to test with.

do the colors variables have the %{%} sequences in them? Otherwise
you have to write those out explicitly.

--

-- 
Mikael Magnusson

Richard Hartmann | 19 Jul 02:13

Re: Problem with color codes

On Sat, Jul 19, 2008 at 01:26, Mikael Magnusson <mikachu <at> gmail.com> wrote:

> do the colors variables have the %{%} sequences in them? Otherwise
> you have to write those out explicitly.

To be honest, I had assumed they _must_ be escaped properly as they
are from a ZSH function.

I will try & find out why they are not and provide a patch which does
things 'better' depending on the answer I get.

Thanks,
Richard

PS: My locally modified colors() works just fine. I really should have
looked in there. Sorry for the noise..

Michal Politowski | 19 Jul 11:29

Re: Problem with color codes

On Sat, 19 Jul 2008 02:13:51 +0200, Richard Hartmann wrote:
> On Sat, Jul 19, 2008 at 01:26, Mikael Magnusson <mikachu <at> gmail.com> wrote:
> 
> > do the colors variables have the %{%} sequences in them? Otherwise
> > you have to write those out explicitly.
> 
> To be honest, I had assumed they _must_ be escaped properly as they
> are from a ZSH function.
> 
> I will try & find out why they are not and provide a patch which does
> things 'better' depending on the answer I get.

The answer is, I suppose: so that they may be used in other places too,
not only in prompts.

--

-- 
MichaƂ Politowski
Talking has been known to lead to communication if practiced carelessly.

sergio | 19 Jul 01:28

Re: Problem with color codes

Richard Hartmann wrote:
> Hi all,
> 
> I switched from old, hardcoded color variables over to the colors function.
> For some reason, this confuses zsh when calculating the width of my
> prompt. It is worth nothing that RPS1 is also affected even though
> 

SIMPLE PROMPT ESCAPES

%{...%}
Include a string as a literal escape sequence. The string within the
braces should not change the cursor position. Brace pairs can nest.

--

-- 
sergio

Bart Schaefer | 19 Jul 03:06

Re: Problem with color codes

On Jul 19,  1:12am, Richard Hartmann wrote:
}
} I switched from old, hardcoded color variables over to the colors function.

Even the colors function is now somewhat out of date for prompts.  The
latest versions of zsh (possibly only the dev version from CVS, I don't
recall and am short of time at the moment to go looking) support color
sequences directly so you don't need the %{ and %} wrappers.  E.g.

PS1='%K{blue}%F{red}RED ON BLUE%f%k%# '


Gmane