Skip to content

Commit

Permalink
Merge pull request #18 from davidanthoff/display-instead-of-show
Browse files Browse the repository at this point in the history
Use display instead of show function for REPL display
  • Loading branch information
fredo-dedup authored Jun 3, 2017
2 parents a6e436d + 943616b commit cd110cb
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions src/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,27 @@ function writehtml(io::IO, v::VegaLiteVis; title="VegaLite plot")
""")
end

import Base.display, Base.REPL.REPLDisplay

function show(io::IO, v::VegaLiteVis)
if displayable("text/html")
v
else
# create a temporary file
tmppath = string(tempname(), ".vegalite.html")
io = open(tmppath, "w")
writehtml(io, v)
close(io)

# println("show :")
# Base.show_backtrace(STDOUT, backtrace())
# println()
function display(d::REPLDisplay, v::VegaLiteVis)
# create a temporary file
tmppath = string(tempname(), ".vegalite.html")
open(tmppath, "w") do io
writehtml(io, v)
end

# Open the browser
@static if VERSION < v"0.5.0-"
@osx_only run(`open $tmppath`)
@windows_only run(`cmd /c start $tmppath`)
@linux_only run(`xdg-open $tmppath`)
else
if is_apple()
# Open the browser
@static if VERSION < v"0.5.0-"
@osx_only run(`open $tmppath`)
@windows_only run(`cmd /c start $tmppath`)
@linux_only run(`xdg-open $tmppath`)
else
if is_apple()
run(`open $tmppath`)
elseif is_windows()
elseif is_windows()
run(`cmd /c start $tmppath`)
elseif is_linux()
elseif is_linux()
run(`xdg-open $tmppath`)
end
end

end

return
end

0 comments on commit cd110cb

Please sign in to comment.