diff --git a/ext/FreeTypeExt.jl b/ext/FreeTypeExt.jl index 7dba8cd9..edbcace5 100644 --- a/ext/FreeTypeExt.jl +++ b/ext/FreeTypeExt.jl @@ -103,7 +103,7 @@ function UnicodePlots.get_font_face(font = nothing, fallback = fallback_fonts()) face end -UnicodePlots.save_png(args...; kw...) = FileIO.save(args...; kw...) +UnicodePlots.save_image(args...; kw...) = FileIO.save(args...; kw...) """ Match a font using the user-specified search string. Each part of the search string diff --git a/ext/ImageInTerminalExt.jl b/ext/ImageInTerminalExt.jl index a0c6c1e6..01f72755 100644 --- a/ext/ImageInTerminalExt.jl +++ b/ext/ImageInTerminalExt.jl @@ -8,18 +8,20 @@ else end using ColorTypes -UnicodePlots.sixel_encode(args...; kw...) = ImageInTerminal.sixel_encode(args...; kw...) +UnicodePlots.sixel_encode(args...; kw...) = ImageInTerminal.sixel_encode(args...; kw...) # COV_EXCL_LINE UnicodePlots.imshow(args...; kw...) = ImageInTerminal.imshow(args...; kw...) function UnicodePlots.terminal_specs(img) + char_h = char_w = nothing + # COV_EXCL_START if ImageInTerminal.choose_sixel(img) ans = ImageInTerminal.Sixel.TerminalTools.query_terminal("\e[16t", stdout) if ans isa String && (m = match(r"\e\[6;(\d+);(\d+)t", ans)) ≢ nothing char_h, char_w = tryparse.(Int, m.captures) - return char_h ≢ nothing && char_w ≢ nothing, char_h, char_w end end - false, nothing, nothing + # COV_EXCL_STOP + char_h ≢ nothing && char_w ≢ nothing, char_h, char_w end UnicodePlots.imageplot(img::AbstractArray{<:Colorant}; kw...) = diff --git a/src/UnicodePlots.jl b/src/UnicodePlots.jl index 5f363d99..0d2533c6 100644 --- a/src/UnicodePlots.jl +++ b/src/UnicodePlots.jl @@ -122,7 +122,7 @@ function __init__() colors256!() faintcolors!() end - @static if !isdefined(Base, :get_extension) + @static if !isdefined(Base, :get_extension) # COV_EXCL_LINE Requires.@require ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" include( "../ext/ImageInTerminalExt.jl", ) diff --git a/src/graphics/imagegraphics.jl b/src/graphics/imagegraphics.jl index ff905375..c4d68d80 100644 --- a/src/graphics/imagegraphics.jl +++ b/src/graphics/imagegraphics.jl @@ -24,7 +24,7 @@ end @inline nrows(c::ImageGraphics) = first(c.encoded_size) @inline ncols(c::ImageGraphics) = last(c.encoded_size) -# `ImageInTerminalExt` placeholders +# # generic functions for `ImageInTerminalExt` function terminal_specs end function sixel_encode end function imshow end diff --git a/src/show.jl b/src/show.jl index cfbf7972..b38b6ac3 100644 --- a/src/show.jl +++ b/src/show.jl @@ -398,10 +398,10 @@ function _show(end_io::IO, print_nocol, print_color, p::Plot) ) end -# `FreeTypeExt` placeholders +# generic functions for `FreeTypeExt` function get_font_face end function render_string! end -function save_png end +function save_image end """ png_image(p::Plot, font = nothing, pixelsize = 32, transparent = true, foreground = nothing, background = nothing, bounding_box = nothing, bounding_box_glyph = nothing) @@ -597,7 +597,7 @@ function savefig(p::Plot, filename::AbstractString; color::Bool = false, kw...) elseif ext == ".png" # `png_image` can fail if fonts are not found: a warning has already been # thrown there, so just bail out at this stage - (img = png_image(p; kw...)) ≢ nothing && save_png(filename, img) + (img = png_image(p; kw...)) ≢ nothing && save_image(filename, img) else "extension \"$ext\" is unsupported: `savefig` only supports writing to `txt` or `png` files" |> ArgumentError |>