From de4de1adb652fb6507b0fa63f6ce2a4c56817c89 Mon Sep 17 00:00:00 2001 From: Zachary Sunberg Date: Mon, 17 Dec 2018 22:19:07 -0800 Subject: [PATCH] added mac-specific commands to inbrowser --- src/displays.jl | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/displays.jl b/src/displays.jl index 4559b0b..22e2315 100644 --- a/src/displays.jl +++ b/src/displays.jl @@ -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