Skip to content

Commit

Permalink
Merge pull request #21 from sisl/inchrome_mac
Browse files Browse the repository at this point in the history
added mac-specific commands to inbrowser
  • Loading branch information
zsunberg authored Dec 19, 2018
2 parents 9c2ff59 + de4de1a commit 4782632
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 4782632

Please sign in to comment.