handle ijulia with requires

and properly check if juno/ijulia are actually used and not just loaded
This commit is contained in:
Sebastian Pfitzner 2017-07-12 10:38:15 +02:00
parent 5e5f23b5e5
commit c385035ac5
2 changed files with 50 additions and 51 deletions

View File

@ -245,8 +245,6 @@ function __init__()
# for compatibility with Requires.jl: # for compatibility with Requires.jl:
@init @init
setup_ijulia()
if isdefined(Main, :PLOTS_DEFAULTS) if isdefined(Main, :PLOTS_DEFAULTS)
for (k,v) in Main.PLOTS_DEFAULTS for (k,v) in Main.PLOTS_DEFAULTS
default(k, v) default(k, v)

View File

@ -250,12 +250,11 @@ end
const _ijulia_output = String["text/html"] const _ijulia_output = String["text/html"]
function setup_ijulia() using Requires
# override IJulia inline display @require IJulia begin
if isijulia() if IJulia.inited
@eval begin
import IJulia
export set_ijulia_output export set_ijulia_output
function set_ijulia_output(mimestr::AbstractString) function set_ijulia_output(mimestr::AbstractString)
# info("Setting IJulia output format to $mimestr") # info("Setting IJulia output format to $mimestr")
global _ijulia_output global _ijulia_output
@ -270,17 +269,18 @@ function setup_ijulia()
function Base.show(io::IO, m::MIME"text/plain", plt::Plot) function Base.show(io::IO, m::MIME"text/plain", plt::Plot)
show(io, MIME("text/html"), plt) show(io, MIME("text/html"), plt)
end end
end
@eval set_ijulia_output("text/html") set_ijulia_output("text/html")
end end
end end
# --------------------------------------------------------- # ---------------------------------------------------------
# Atom PlotPane # Atom PlotPane
# --------------------------------------------------------- # ---------------------------------------------------------
using Requires
@require Juno begin @require Juno begin
import Hiccup, Media import Hiccup, Media
if Juno.isactive()
Media.media(Plot, Media.Plot) Media.media(Plot, Media.Plot)
function Juno.render(e::Juno.Editor, plt::Plot) function Juno.render(e::Juno.Editor, plt::Plot)
@ -318,3 +318,4 @@ using Requires
Juno.render(pane, HTML(s)) Juno.render(pane, HTML(s))
end end
end end
end