Restore former terminal after save()

This commit is contained in:
Giorgio Calderone 2019-01-16 21:51:37 +01:00
parent f03981640d
commit 663598910b

View File

@ -250,7 +250,7 @@ function reset(gp::DrySession)
gp.plots = [SinglePlot()] gp.plots = [SinglePlot()]
gp.curmid = 1 gp.curmid = 1
println(gp, "reset session") println(gp, "reset session")
setWindowTitle(gp) # setWindowTitle(gp)
return nothing return nothing
end end
@ -525,7 +525,11 @@ end
# -------------------------------------------------------------------- # --------------------------------------------------------------------
internal_save(gp::DrySession; kw...) = internal_save(gp, gp; kw...) internal_save(gp::DrySession; kw...) = internal_save(gp, gp; kw...)
function internal_save(gp::DrySession, stream; term::AbstractString="", output::AbstractString="") function internal_save(gp::DrySession, stream; term::AbstractString="", output::AbstractString="")
(term != "") && println(stream, "set term $term") if term != ""
former_term = writeread(gp, "print GPVAL_TERM")[1]
former_opts = writeread(gp, "print GPVAL_TERMOPTIONS")[1]
println(stream, "set term $term")
end
(output != "") && println(stream, "set output '$output'") (output != "") && println(stream, "set output '$output'")
i = (!(typeof(stream) <: DrySession), 1, 1) # Skip data sources ? i = (!(typeof(stream) <: DrySession), 1, 1) # Skip data sources ?
while (next = iterate(gp, i)) != nothing while (next = iterate(gp, i)) != nothing
@ -533,6 +537,9 @@ function internal_save(gp::DrySession, stream; term::AbstractString="", output::
println(stream, s) println(stream, s)
end end
(output != "") && println(stream, "set output") (output != "") && println(stream, "set output")
if term != ""
println(stream, "set term $former_term $former_opts")
end
output output
end end
@ -572,7 +579,6 @@ function driver(args...; flag3d=false)
end end
gp = nothing gp = nothing
term = ("", "")
doDump = true doDump = true
doReset = true doReset = true