From 054cd1e9c8298c8802ebff767aa37dd5fcf86d3e Mon Sep 17 00:00:00 2001 From: t-bltg Date: Thu, 1 Sep 2022 17:49:37 +0200 Subject: [PATCH] rework `display` --- src/init.jl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/init.jl b/src/init.jl index 292bec176..0b36d7a9f 100644 --- a/src/init.jl +++ b/src/init.jl @@ -119,20 +119,15 @@ function __init__() InspectDRBackend, GastonBackend, ) - # showable(MIME("image/png"), Plot{be}) || continue # will only work for currently loaded backends - @eval function _display(plt::Plot{$be}) - I = findfirst( - d -> d isa ImageInTerminal.TerminalGraphicDisplay, - Base.Multimedia.displays, - ) - dsp = if I === nothing - ImageInTerminal.TerminalGraphicDisplay(stdout) - else - Base.Multimedia.displays[I] - end - buf = IOBuffer() + @eval function Base.display(::PlotsDisplay, plt::Plot{$be}) + prepare_output(plt) + buf = PipeBuffer() show(buf, MIME("image/png"), plt) - display(dsp, MIME("image/png"), take!(buf)) + display( + ImageInTerminal.TerminalGraphicDisplay(stdout), + MIME("image/png"), + read(buf), + ) end end end