Skip to content

Commit

Permalink
Merge pull request #4996 from luismarques/use_osx_user_browser
Browse files Browse the repository at this point in the history
man.d: use the configured browser, don't hardcode Safari
  • Loading branch information
WalterBright committed Aug 31, 2015
2 parents 2ba1045 + 0d6eff4 commit f13f044
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/root/man.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,34 @@

module ddmd.root.man;

import core.stdc.stdio, core.stdc.stdlib, core.stdc.string, core.sys.posix.sys.types, core.sys.posix.sys.wait, core.sys.posix.unistd, core.sys.windows.windows;
import core.stdc.stdio;
import core.stdc.stdlib;
import core.stdc.string;
import core.sys.posix.sys.types;
import core.sys.posix.sys.wait;
import core.sys.posix.unistd;
import core.sys.windows.windows;

version (Windows)
{
extern (C++) void browse(const(char)* url)
in
{
assert(strncmp(url, "http://", 7) == 0 || strncmp(url, "https://", 8) == 0);
}
body
{
ShellExecuteA(null, "open", url, null, null, SW_SHOWNORMAL);
}
}
else version (OSX)
{
extern (C++) void browse(const(char)* url)
in
{
assert(strncmp(url, "http://", 7) == 0 || strncmp(url, "https://", 8) == 0);
}
body
{
pid_t childpid;
const(char)*[5] args;
Expand All @@ -33,12 +49,9 @@ else version (OSX)
}
else
{
//browser = "/Applications/Safari.app/Contents/MacOS/Safari";
args[0] = "open";
args[1] = "-a";
args[2] = "/Applications/Safari.app";
args[3] = url;
args[4] = null;
args[1] = url;
args[2] = null;
}
childpid = fork();
if (childpid == 0)
Expand All @@ -52,6 +65,11 @@ else version (OSX)
else version (Posix)
{
extern (C++) void browse(const(char)* url)
in
{
assert(strncmp(url, "http://", 7) == 0 || strncmp(url, "https://", 8) == 0);
}
body
{
pid_t childpid;
const(char)*[3] args;
Expand Down

0 comments on commit f13f044

Please sign in to comment.