gr: replaced withenv calls with _gr_wstype and gr_set_output
This commit is contained in:
parent
14fd3c94b5
commit
2877cb7160
@ -1035,22 +1035,28 @@ const _gr_mimeformats = Dict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const _gr_wstype_default = @static if is_linux()
|
const _gr_wstype_default = @static if is_linux()
|
||||||
"cairox11"
|
"x11"
|
||||||
|
# "cairox11"
|
||||||
elseif is_apple()
|
elseif is_apple()
|
||||||
"quartz"
|
"quartz"
|
||||||
else
|
else
|
||||||
"windows"
|
"windows"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
const _gr_wstype = Ref(get(ENV, "GKS_WSTYPE", _gr_wstype_default))
|
||||||
|
gr_set_output(wstype::String) = (_gr_wstype[] = wstype)
|
||||||
|
|
||||||
for (mime, fmt) in _gr_mimeformats
|
for (mime, fmt) in _gr_mimeformats
|
||||||
@eval function _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GRBackend})
|
@eval function _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GRBackend})
|
||||||
GR.emergencyclosegks()
|
GR.emergencyclosegks()
|
||||||
filepath = tempname() * "." * $fmt
|
filepath = tempname() * "." * $fmt
|
||||||
withenv("GKS_WSTYPE" => $fmt, # $fmt == "png" ? "cairopng" : $fmt,
|
ENV["GKS_WSTYPE"] = $fmt
|
||||||
"GKS_FILEPATH" => filepath) do
|
ENV["GKS_FILEPATH"] = filepath
|
||||||
|
# withenv("GKS_WSTYPE" => $fmt, # $fmt == "png" ? "cairopng" : $fmt,
|
||||||
|
# "GKS_FILEPATH" => filepath) do
|
||||||
gr_display(plt)
|
gr_display(plt)
|
||||||
GR.emergencyclosegks()
|
GR.emergencyclosegks()
|
||||||
end
|
# end
|
||||||
write(io, readstring(filepath))
|
write(io, readstring(filepath))
|
||||||
rm(filepath)
|
rm(filepath)
|
||||||
end
|
end
|
||||||
@ -1060,18 +1066,22 @@ function _display(plt::Plot{GRBackend})
|
|||||||
if plt[:display_type] == :inline
|
if plt[:display_type] == :inline
|
||||||
GR.emergencyclosegks()
|
GR.emergencyclosegks()
|
||||||
filepath = tempname() * ".pdf"
|
filepath = tempname() * ".pdf"
|
||||||
withenv("GKS_WSTYPE" => "pdf",
|
ENV["GKS_WSTYPE"] = "pdf"
|
||||||
"GKS_FILEPATH" => filepath) do
|
ENV["GKS_FILEPATH"] = filepath
|
||||||
|
# withenv("GKS_WSTYPE" => "pdf",
|
||||||
|
# "GKS_FILEPATH" => filepath) do
|
||||||
gr_display(plt)
|
gr_display(plt)
|
||||||
GR.emergencyclosegks()
|
GR.emergencyclosegks()
|
||||||
end
|
# end
|
||||||
content = string("\033]1337;File=inline=1;preserveAspectRatio=0:", base64encode(open(readbytes, filepath)), "\a")
|
content = string("\033]1337;File=inline=1;preserveAspectRatio=0:", base64encode(open(readbytes, filepath)), "\a")
|
||||||
println(content)
|
println(content)
|
||||||
rm(filepath)
|
rm(filepath)
|
||||||
else
|
else
|
||||||
withenv("GKS_WSTYPE" => get(ENV, "GKS_WSTYPE", _gr_wstype_default),
|
ENV["GKS_DOUBLE_BUF"] = true
|
||||||
"GKS_DOUBLE_BUF" => get(ENV ,"GKS_DOUBLE_BUF", "true")) do
|
ENV["GKS_WSTYPE"] = _gr_wstype[]
|
||||||
|
# withenv("GKS_WSTYPE" => get(ENV, "GKS_WSTYPE", _gr_wstype_default),
|
||||||
|
# "GKS_DOUBLE_BUF" => get(ENV ,"GKS_DOUBLE_BUF", "true")) do
|
||||||
gr_display(plt)
|
gr_display(plt)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user