Skip to content

Commit 2182598

Browse files
committed
update
1 parent 0313a66 commit 2182598

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

src/common.jl

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,17 @@ styledstrings_color(color::ColorType) =
468468
StyledStrings.Legacy.legacy_color(Int(color - THRESHOLD))
469469
end
470470

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))
472473
print_color(io::IO, color::UserColorType, args...) =
473474
print_color(io, ansi_color(color), args...)
474475

475476
function print_color(io::IO, color::ColorType, args...; bgcol = missing)
476477
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+
)
478482
print_color(io, face, args...)
479483
else
480484
print(io, args...)
@@ -524,7 +528,8 @@ c256(c::Integer) = c
524528
# `ColorType` conversion - colormaps
525529
ansi_color(rgb::AbstractRGB) = ansi_color((c256(rgb.r), c256(rgb.g), c256(rgb.b)))
526530
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])
528533

529534
ansi_color(color::ColorType)::ColorType = color # no-op
530535
ansi_color(face::StyledStrings.Face) = ansi_color(face.foreground) # ignore bg & styles
@@ -548,24 +553,25 @@ function to_256_colors(color)
548553
UInt8(ansi)
549554
end
550555

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
567574
end
568-
end
569575

570576
complement(color::UserColorType)::ColorType = complement(ansi_color(color))
571577
complement(color::ColorType)::ColorType = if color INVALID_COLOR

src/show.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ function _show(end_io::IO, print_nocol, print_color, p::Plot)
228228
border_right_cbar_pad * '\n',
229229
🗹;
230230
p_width = p_width,
231-
color = io_color ? StyledStrings.Face(foreground = :white, weight = :bold) : nothing,
231+
color = io_color ? StyledStrings.Face(foreground = :white, weight = :bold) :
232+
nothing,
232233
)
233234
h_lbl = print_labels(
234235
io,

0 commit comments

Comments
 (0)