zsh-workers
 help / color / mirror / code / Atom feed
* What appears to be inconsistent results from ${(%):-%F{${subscript}}
@ 2024-03-04 14:56 Jim
  2024-03-04 15:07 ` Jim
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jim @ 2024-03-04 14:56 UTC (permalink / raw)
  To: devs

[-- Attachment #1: Type: text/plain, Size: 2073 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2750 bytes --]

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

end of thread, other threads:[~2024-03-04 22:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 14:56 What appears to be inconsistent results from ${(%):-%F{${subscript}} Jim
2024-03-04 15:07 ` Jim
2024-03-04 18:06 ` Mikael Magnusson
2024-03-04 22:28 ` Bart Schaefer
2024-03-04 22:50 ` Oliver Kiddle

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