chmhelp: under darwin use open -n so that lhelp is in front

git-svn-id: trunk@38057 -
This commit is contained in:
mattias 2012-07-27 12:26:48 +00:00
parent c899962a43
commit 5f012e16ba
2 changed files with 22 additions and 9 deletions

View File

@ -162,11 +162,15 @@ begin
end;
SplitURL(Node.URL,URLScheme,URLPath,URLParams);
CHMFilename:=SetDirSeparators(URLPath);
CHMFilename:=CleanAndExpandFilename(URLPath);
if not FileExistsUTF8(CHMFilename) then begin
ErrMsg:='chm file "'+CHMFilename+'" not found';
exit;
end;
if DirPathExists(CHMFilename) then begin
ErrMsg:='invalid chm file "'+CHMFilename+'"';
exit;
end;
SubPath:='';
if (URLParams<>'') and (URLParams[1]='?') then
@ -205,12 +209,6 @@ begin
if s<>'' then Path:=s;
end;
{$IFDEF darwin}
// search exe in application bundle
if DirectoryExistsUTF8(Path+'.app') then
Path:=Path+'.app/Contents/MacOS/'+ExtractFileName(Path);
{$ENDIF}
if not FileExistsUTF8(Path) then begin
ErrMsg:='The chm viewer program lhelp was not found at "'+Path+'"';
exit;
@ -231,6 +229,7 @@ begin
else
ErrMsg:='Something is wrong with lhelp';
end;
debugln(['TLHelpConnector.ShowNode error: ',ErrMsg]);
end;
procedure TLHelpConnector.Assign(Source: TPersistent);

View File

@ -23,7 +23,7 @@ uses
{$IFDEF STALE_PIPE_WORKAROUND}
BaseUnix,
{$ENDIF}
Classes, SysUtils, FileUtil, SimpleIPC, UTF8Process;
Classes, SysUtils, FileUtil, LazLogger, SimpleIPC, process, UTF8Process;
type
TRequestType = (rtFile, rtUrl, rtContext);
@ -172,6 +172,7 @@ function TLHelpConnection.StartHelpServer(NameForServer: String;
ServerEXE: String): Boolean;
var
X: Integer;
Cmd: String;
begin
Result := False;
@ -183,8 +184,21 @@ begin
fServerOut.Active := False;
fServerOut.ServerID := NameForServer;
if not ServerRunning then begin
Cmd:= ServerExe + ' --ipcname ' + NameForServer;
{$IFDEF darwin}
if DirectoryExistsUTF8(ServerEXE+'.app') then
ServerEXE+='.app';
debugln(['TLHelpConnection.StartHelpServer ',ServerEXE]);
if DirectoryExistsUTF8(ServerEXE) then begin
// application bundle
// to put lhelp into the foreground, use "open -n"
Cmd:='/usr/bin/open -n '+ServerEXE+' --args --ipcname ' + NameForServer
end;
DebugLn(['TLHelpConnection.StartHelpServer ',cmd]);
{$ENDIF}
with TProcessUTF8.Create(nil) do begin
CommandLine := ServerExe + ' --ipcname ' + NameForServer;
ShowWindow:=swoShowNormal;
CommandLine := Cmd;
Execute;
Free;
end;