diff --git a/Project.toml b/Project.toml index 12699e9..6b1ed41 100644 --- a/Project.toml +++ b/Project.toml @@ -18,7 +18,7 @@ ColorSchemes = "^3.5" ColorTypes = "^0.10" Colors = "^0.12" DataStructures = "^0.17" -ReplMaker="^0.2" +ReplMaker = "^0.2" StatsBase = "^0.33" StructC14N = "^0.3" julia = "^1.2" diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 0abe55f..d30c93a 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -1267,9 +1267,9 @@ function driver(_args...; is3d=false) end end - (doDump) && (execall(gp)) + # (doDump) && (execall(gp)) - return nothing + return gp end @@ -1461,6 +1461,41 @@ save(sid::Symbol; kw...) = execall(getsession(sid); kw...) save( file::AbstractString; kw...) = savescript(getsession() , file, kw...) save(sid::Symbol, file::AbstractString; kw...) = savescript(getsession(sid), file, kw...) +# ╭───────────────────────────────────────────────────────────────────╮ +# │ Interfacing Julia's show │ +# ╰───────────────────────────────────────────────────────────────────╯ +# -------------------------------------------------------------------- + +# Define a display that will be used when Gnuplot.jl is used +# in the Julia REPL (see PGFPlotsX.jl). +struct GnuplotDisplay <: AbstractDisplay end +function __init__() + pushdisplay(GnuplotDisplay()) + atreplinit(i -> begin + if PlotDisplay() in Base.Multimedia.displays + popdisplay(GnuplotDisplay()) + end + pushdisplay(GnuplotDisplay()) + end) +end +function Base.display(d::GnuplotDisplay, gp::Session) + execall(gp) + return +end +function Base.show(io::IO, ::MIME"image/svg+xml", gp::Session) + tmpfile = tempname()*".svg" + execall(gp; output=tmpfile, term="svg") + write(io, read(tmpfile)) + rm(tmpfile; force=true) + return +end +function Base.show(io::IO, ::MIME"image/png", gp::Session) + tmpfile = tempname()*".png" + execall(gp; output=tmpfile, term="png") + write(io, read(tmpfile)) + rm(tmpfile; force=true) + return +end # ╭───────────────────────────────────────────────────────────────────╮ # │ HIGH LEVEL FACILITIES │