zsh-workers
 help / Atom feed
* Small zle_highlight regression in 5.7
@ 2019-01-31 23:31 Jan Larres
  2019-02-01  1:46 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Larres @ 2019-01-31 23:31 UTC (permalink / raw)
  To: zsh-workers

Hi,

In 5.6.2 I was able to use the special 'reset' foreground attribute to 
only reset the foreground colour in the prompt:

   $ print -P "%{%F{red}%}foo%{%F{reset}%}bar" | cat -v
   ^[[31mfoo^[[39mbar

This doesn't work any more in 5.7:

   $ print -P "%{%F{red}%}foo%{%F{reset}%}bar" | cat -v
   ^[[31mfoobar

I also can't find any mention of this attribute in the documentation any 
more. Is this intentional?

Thanks,
Jan

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

* Re: Small zle_highlight regression in 5.7
  2019-01-31 23:31 Small zle_highlight regression in 5.7 Jan Larres
@ 2019-02-01  1:46 ` dana
  2019-02-01  3:40   ` Jan Larres
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2019-02-01  1:46 UTC (permalink / raw)
  To: Jan Larres; +Cc: zsh-workers

On 31 Jan 2019, at 17:31, Jan Larres <jan@majutsushi.net> wrote:
>In 5.6.2 I was able to use the special 'reset' foreground attribute ...
>This doesn't work any more in 5.7: ...
>I also can't find any mention of this attribute in the documentation any more.

I don't think it was ever there — the documented way to do this is %F{default}
or simply %f. %F{reset} only worked because unrecognised colour names would
just fall back to the default sequence (which doesn't seem to be mentioned
explicitly anywhere?).

5.7 did change that, though, and i'm not sure it was intended.

This seems to fix it

dana


diff --git a/Src/prompt.c b/Src/prompt.c
index 4603ffba6..f2b3f161e 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1661,10 +1661,12 @@ match_colour(const char **teststrp, int is_fg, int colour)
 	    colour = match_named_colour(teststrp);
 	    if (colour == 8) {
 		/* default */
 		return is_fg ? TXTNOFGCOLOUR : TXTNOBGCOLOUR;
 	    }
+	    if (colour < 0)
+		return TXT_ERROR;
 	}
 	else {
 	    colour = (int)zstrtol(*teststrp, (char **)teststrp, 10);
 	    if (colour < 0 || colour >= 256)
 		return TXT_ERROR;

diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 56b7c294a..7ff478e68 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -221,3 +221,11 @@
   print ${(%U)Y-%(v}
 0:Regression test for test on empty psvar
 >
+
+# Unrecognised colour strings should produce the default sequence
+  f=${(%):-'%f'} # Recognised
+  Fdefault=${(%):-'%F{default}'} # Recognised
+  Freset=${(%):-'%F{reset}'} # Unrecognised
+  Ffoo=${(%):-'%F{foo}'} # Unrecognised
+  [[ $f == $Fdefault && $Fdefault == $Freset && $Freset == $Ffoo ]]
+0:Regression test for workers/44029


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

* Re: Small zle_highlight regression in 5.7
  2019-02-01  1:46 ` dana
@ 2019-02-01  3:40   ` Jan Larres
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Larres @ 2019-02-01  3:40 UTC (permalink / raw)
  To: zsh-workers

Odd, I wonder where I got the idea that 'reset' was the correct thing to 
use then. I think that's some old relic that I haven't really looked at 
in years. I also missed the mention of 'default' somehow. Using 
'default' does make it work for me though, so thanks!

-Jan


On 01/02/2019 14:46, dana wrote:
> On 31 Jan 2019, at 17:31, Jan Larres <jan@majutsushi.net> wrote:
>> In 5.6.2 I was able to use the special 'reset' foreground attribute ...
>> This doesn't work any more in 5.7: ...
>> I also can't find any mention of this attribute in the documentation any more.
> 
> I don't think it was ever there — the documented way to do this is %F{default}
> or simply %f. %F{reset} only worked because unrecognised colour names would
> just fall back to the default sequence (which doesn't seem to be mentioned
> explicitly anywhere?).
> 
> 5.7 did change that, though, and i'm not sure it was intended.
> 
> This seems to fix it
> 
> dana
> 
> 
> diff --git a/Src/prompt.c b/Src/prompt.c
> index 4603ffba6..f2b3f161e 100644
> --- a/Src/prompt.c
> +++ b/Src/prompt.c
> @@ -1661,10 +1661,12 @@ match_colour(const char **teststrp, int is_fg, int colour)
>   	    colour = match_named_colour(teststrp);
>   	    if (colour == 8) {
>   		/* default */
>   		return is_fg ? TXTNOFGCOLOUR : TXTNOBGCOLOUR;
>   	    }
> +	    if (colour < 0)
> +		return TXT_ERROR;
>   	}
>   	else {
>   	    colour = (int)zstrtol(*teststrp, (char **)teststrp, 10);
>   	    if (colour < 0 || colour >= 256)
>   		return TXT_ERROR;
> 
> diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
> index 56b7c294a..7ff478e68 100644
> --- a/Test/D01prompt.ztst
> +++ b/Test/D01prompt.ztst
> @@ -221,3 +221,11 @@
>     print ${(%U)Y-%(v}
>   0:Regression test for test on empty psvar
>   >
> +
> +# Unrecognised colour strings should produce the default sequence
> +  f=${(%):-'%f'} # Recognised
> +  Fdefault=${(%):-'%F{default}'} # Recognised
> +  Freset=${(%):-'%F{reset}'} # Unrecognised
> +  Ffoo=${(%):-'%F{foo}'} # Unrecognised
> +  [[ $f == $Fdefault && $Fdefault == $Freset && $Freset == $Ffoo ]]
> +0:Regression test for workers/44029
> 

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-31 23:31 Small zle_highlight regression in 5.7 Jan Larres
2019-02-01  1:46 ` dana
2019-02-01  3:40   ` Jan Larres

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox