Skip to content

Commit

Permalink
added mac-specific commands to inbrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Dec 18, 2018
1 parent 9c2ff59 commit de4de1a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/displays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,37 @@ function inchrome(t::D3Tree)
end
if Sys.iswindows()
run(`cmd /C start chrome "$fname"`)
elseif Sys.isapple()
run(`open -a "Google Chrome" $fname`)
else
run(`google-chrome $fname`)
end
end

"""
inbrowser(t::D3Tree, browsername::String)
Open an html document with the D3Tree in a browser with a platform-specific command.
"""
function inbrowser(t::D3Tree, browsername::String)
if Sys.iswindows()
inbrowser(t, `cmd /C start $browsername`)
elseif Sys.isapple()
inbrowser(t, `open -a $browsername`)
else
inbrowser(t, `$browsername`)
end
end

"""
inbrowser(t::D3Tree, command::Cmd)
Open an html document with the D3Tree in a program launched with the specified command.
"""
function inbrowser(t::D3Tree, command::Cmd)
fname = joinpath(mktempdir(), "tree.html")
open(fname, "w") do f
show(f, MIME("text/html"), t)
end
if Sys.iswindows()
run(`cmd /C start $browsername "$fname"`)
else
run(`$browsername $fname`)
end
run(`$command $fname`)
end

0 comments on commit de4de1a

Please sign in to comment.