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

What appears to be inconsistent results from ${(%):-%F{${subscript}}



Hi all,

Output for the  following function will help visualize what I believe to be
inconsistencies of the output of ${(%):-%F{${subscript}}.
I would assume %B (background) would yield similar results.

Note the function outputs a solid block character in color.
Hopefully the block charcter will cut and paste correctly.

color_conversion_check () {  
  local subscript colorconversion
  local subscripts
  subscripts=(black blue cyan default gray green grey magenta red white yellow
  bright-blue bright-cyan bright-gray bright-green bright-grey bright-magenta
  bright-red bright-white bright-yellow
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  16 17 18 229 230 231
  232 233 234 253 254 255
  '#000000' '#007fff' '#ff0080' '#abcdef' '#007FFF' '#FF0080' '#ABCDEF'
  )
  print -- "Output of fg associative array"
  print --  "${fg[gray]}${(r.24..█.)}\e[0m  ${(V)fg[gray]}  fg[gray]"
  print --  "${fg[grey]}${(r.24..█.)}\e[0m  ${(V)fg[grey]}  fg[grey]"
  print --
  for subscript ($subscripts) {
    colorconversion="${(%):-%F{${subscript}}"
    print -- "${(%)colorconversion}${(r.24..█.)}\e[0m  ${(V)colorconversion}  ${subscript}"
  }
}

First, '${(%):-%F{${subscript}}' has unbalanced curly brackets({}), but still works.
Adding a closing bracket(}) results in '}' being added to the output. So instead of
getting ',,,m' you get '...m}'.  I'm confused. What am I missing?

To my original point

1)  the color names grey and gray do not output black but output the default
 
2) bright color names are not converted but output the default color
    Should bright color names be added to the code?
  As you can see in 3) the code for bright colors is there

3) using decimal numbers(0-255)
    0 - 15  uses 30-27 and 90-97(bright) instead of using the colors defined
   by the terminal
  NOTE: 0-15 are defined even for TERM=linux
  16-255 uses the colors defined by the terminal
  Is there a reason why it doesn't use the terminal colors for 0-15?

Hex codes appear to work as expected.

Regards,

Jim Murphy




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