@@ -468,13 +468,17 @@ styledstrings_color(color::ColorType) =
468
468
StyledStrings. Legacy. legacy_color (Int (color - THRESHOLD))
469
469
end
470
470
471
- print_color (io:: IO , face:: StyledStrings.Face , args... ) = print (io, StyledStrings. face! (Base. annotatedstring (args... ), face))
471
+ print_color (io:: IO , face:: StyledStrings.Face , args... ) =
472
+ print (io, StyledStrings. face! (Base. annotatedstring (args... ), face))
472
473
print_color (io:: IO , color:: UserColorType , args... ) =
473
474
print_color (io, ansi_color (color), args... )
474
475
475
476
function print_color (io:: IO , color:: ColorType , args... ; bgcol = missing )
476
477
if get (io, :color , false )
477
- face = StyledStrings. Face (foreground = styledstrings_color (color), background = styledstrings_color (bgcol))
478
+ face = StyledStrings. Face (
479
+ foreground = styledstrings_color (color),
480
+ background = styledstrings_color (bgcol),
481
+ )
478
482
print_color (io, face, args... )
479
483
else
480
484
print (io, args... )
@@ -524,7 +528,8 @@ c256(c::Integer) = c
524
528
# `ColorType` conversion - colormaps
525
529
ansi_color (rgb:: AbstractRGB ) = ansi_color ((c256 (rgb. r), c256 (rgb. g), c256 (rgb. b)))
526
530
ansi_color (rgb:: NTuple{3,AbstractFloat} ) = ansi_color (c256 .(rgb))
527
- ansi_color (color:: NTuple{3,Integer} ):: ColorType = r32 (color[1 ]) + g32 (color[2 ]) + b32 (color[3 ])
531
+ ansi_color (color:: NTuple{3,Integer} ):: ColorType =
532
+ r32 (color[1 ]) + g32 (color[2 ]) + b32 (color[3 ])
528
533
529
534
ansi_color (color:: ColorType ):: ColorType = color # no-op
530
535
ansi_color (face:: StyledStrings.Face ) = ansi_color (face. foreground) # ignore bg & styles
@@ -548,24 +553,25 @@ function to_256_colors(color)
548
553
UInt8 (ansi)
549
554
end
550
555
551
- ansi_color (color:: StyledStrings.SimpleColor ):: ColorType = let c = color. value
552
- if COLORMODE[] ≡ COLORMODE_24BIT
553
- if c isa Symbol
554
- c4 = StyledStrings. ANSI_4BIT_COLORS[c]
555
- c8 = ansi_4bit_to_8bit (UInt8 (c4))
556
- return USE_LUT[] ? LUT_8BIT[c8 + 1 ] : THRESHOLD + c8
557
- elseif c isa StyledStrings. RGBTuple
558
- return r32 (c. r) + g32 (c. g) + b32 (c. b)
559
- end :: ColorType
560
- else # 0-255 ansi stored in a UInt32
561
- return THRESHOLD + if c isa Symbol
562
- c4 = StyledStrings. ANSI_4BIT_COLORS[c]
563
- ansi_4bit_to_8bit (UInt8 (c4))
564
- elseif c isa StyledStrings. RGBTuple
565
- to_256_colors (c)
566
- end :: UInt8
556
+ ansi_color (color:: StyledStrings.SimpleColor ):: ColorType =
557
+ let c = color. value
558
+ if COLORMODE[] ≡ COLORMODE_24BIT
559
+ if c isa Symbol
560
+ c4 = StyledStrings. ANSI_4BIT_COLORS[c]
561
+ c8 = ansi_4bit_to_8bit (UInt8 (c4))
562
+ return USE_LUT[] ? LUT_8BIT[c8 + 1 ] : THRESHOLD + c8
563
+ elseif c isa StyledStrings. RGBTuple
564
+ return r32 (c. r) + g32 (c. g) + b32 (c. b)
565
+ end :: ColorType
566
+ else # 0-255 ansi stored in a UInt32
567
+ return THRESHOLD + if c isa Symbol
568
+ c4 = StyledStrings. ANSI_4BIT_COLORS[c]
569
+ ansi_4bit_to_8bit (UInt8 (c4))
570
+ elseif c isa StyledStrings. RGBTuple
571
+ to_256_colors (c)
572
+ end :: UInt8
573
+ end
567
574
end
568
- end
569
575
570
576
complement (color:: UserColorType ):: ColorType = complement (ansi_color (color))
571
577
complement (color:: ColorType ):: ColorType = if color ≡ INVALID_COLOR
0 commit comments