@@ -454,31 +454,44 @@ crayon_color(color::ColorType) =
454
454
Crayons. ANSIColor (color - THRESHOLD, Crayons. COLORS_256)
455
455
end
456
456
457
- function print_crayons (io, c, args... )
458
- if CRAYONS_FAST[]
459
- if Crayons. anyactive (c) # bypass crayons checks (_have_color, _force_color)
460
- print (io, Crayons. CSI)
461
- Crayons. _print (io, c)
462
- print (io, Crayons. END_ANSI, args... , CRAYONS_RESET)
463
- else
464
- print (io, args... )
465
- end
466
- else
467
- print (io, c, args... , CRAYONS_RESET)
457
+
458
+ ss_color (:: Union{Missing,Nothing} ) = nothing
459
+ ss_color (color:: ColorType ) =
460
+ if color ≡ INVALID_COLOR
461
+ nothing
462
+ elseif color < THRESHOLD # 24bit
463
+ StyledStrings. SimpleColor (red (color), grn (color), blu (color))
464
+ else # 8bit
465
+ StyledStrings. Legacy. legacy_color (Int (color - THRESHOLD))
468
466
end
469
- end
470
467
471
- print_color (io:: IO , color:: Crayon , args... ) = print_crayons (io, color, args... )
468
+ # function print_crayons(io, c, args...)
469
+ # if CRAYONS_FAST[]
470
+ # if Crayons.anyactive(c) # bypass crayons checks (_have_color, _force_color)
471
+ # print(io, Crayons.CSI)
472
+ # Crayons._print(io, c)
473
+ # print(io, Crayons.END_ANSI, args..., CRAYONS_RESET)
474
+ # else
475
+ # print(io, args...)
476
+ # end
477
+ # else
478
+ # print(io, c, args..., CRAYONS_RESET)
479
+ # end
480
+ # end
481
+
482
+ # print_color(io::IO, color::Crayon, args...) = print_crayons(io, color, args...)
472
483
print_color (io:: IO , color:: UserColorType , args... ) =
473
484
print_color (io, ansi_color (color), args... )
474
485
475
486
function print_color (io:: IO , color:: ColorType , args... ; bgcol = missing )
476
487
if get (io, :color , false )
477
- print_crayons (
478
- io,
479
- Crayon (crayon_color (color), crayon_color (bgcol), CRAYONS_EMPTY_STYLES... ),
480
- args... ,
481
- )
488
+ face = StyledStrings. Face (; foreground = ss_color (color), background = ss_color (bgcol))
489
+ print (io, StyledStrings. face! (Base. annotatedstring (args... ), face))
490
+ # print_crayons(
491
+ # io,
492
+ # Crayon(crayon_color(color), crayon_color(bgcol), CRAYONS_EMPTY_STYLES...),
493
+ # args...,
494
+ # )
482
495
else
483
496
print (io, args... )
484
497
end
0 commit comments