mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 21:59:14 +02:00
lhelp: resolve macros in HelpEXE on the demand
git-svn-id: trunk@37713 -
This commit is contained in:
parent
c019b71631
commit
147019bc32
@ -57,8 +57,9 @@ unit LazChmHelp;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LazHelpIntf, HelpIntfs, LazConfigStorage,
|
Classes, SysUtils, FileUtil, LazLogger, LazHelpIntf, HelpIntfs,
|
||||||
PropEdits, LHelpControl, Controls, ChmLangRef, ChmLcl, ChmProg;
|
LazConfigStorage, PropEdits, LHelpControl, Controls, ChmLangRef, ChmLcl,
|
||||||
|
ChmProg;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -71,14 +72,13 @@ type
|
|||||||
fHelpConnection: TLHelpConnection;
|
fHelpConnection: TLHelpConnection;
|
||||||
fChmsFilePath: String;
|
fChmsFilePath: String;
|
||||||
fHelpExeParams: String;
|
fHelpExeParams: String;
|
||||||
function GetHelpEXE: String;
|
|
||||||
function DBFindViewer({%H-}HelpDB: THelpDatabase; {%H-}const MimeType: string;
|
function DBFindViewer({%H-}HelpDB: THelpDatabase; {%H-}const MimeType: string;
|
||||||
var {%H-}ErrMsg: string; out Viewer: THelpViewer): TShowHelpResult;
|
var {%H-}ErrMsg: string; out Viewer: THelpViewer): TShowHelpResult;
|
||||||
function GetHelpLabel: String;
|
function GetHelpLabel: String;
|
||||||
procedure SetChmsFilePath(const AValue: String);
|
procedure SetChmsFilePath(const AValue: String);
|
||||||
|
procedure SetHelpEXE(AValue: String);
|
||||||
protected
|
protected
|
||||||
function GetFileNameAndURL(RawUrl: String; out FileName: String; out URL: String): Boolean;
|
function GetFileNameAndURL(RawUrl: String; out FileName: String; out URL: String): Boolean;
|
||||||
procedure SetHelpEXE(AValue: String);
|
|
||||||
procedure SetHelpLabel(AValue: String);
|
procedure SetHelpLabel(AValue: String);
|
||||||
function CheckBuildLHelp: Integer; // modal result
|
function CheckBuildLHelp: Integer; // modal result
|
||||||
function GetLazBuildEXE(out ALazBuild: String): Boolean;
|
function GetLazBuildEXE(out ALazBuild: String): Boolean;
|
||||||
@ -95,8 +95,9 @@ type
|
|||||||
procedure Load(Storage: TConfigStorage); override;
|
procedure Load(Storage: TConfigStorage); override;
|
||||||
procedure Save(Storage: TConfigStorage); override;
|
procedure Save(Storage: TConfigStorage); override;
|
||||||
function GetLocalizedName: string; override;
|
function GetLocalizedName: string; override;
|
||||||
|
function GetHelpEXE: String; // macros resolved, see property HelpEXE
|
||||||
published
|
published
|
||||||
property HelpEXE: String read GetHelpEXE write SetHelpEXE;
|
property HelpEXE: String read fHelpEXE write SetHelpEXE; // with macros, see GetHelpEXE
|
||||||
property HelpLabel: String read GetHelpLabel write SetHelpLabel;
|
property HelpLabel: String read GetHelpLabel write SetHelpLabel;
|
||||||
property HelpFilesPath: String read fChmsFilePath write SetChmsFilePath;
|
property HelpFilesPath: String read fChmsFilePath write SetChmsFilePath;
|
||||||
property HelpExeParams: String read fHelpExeParams write fHelpExeParams;
|
property HelpExeParams: String read fHelpExeParams write fHelpExeParams;
|
||||||
@ -159,14 +160,19 @@ begin
|
|||||||
FPCDirectivesHelpDatabase.DocsDir := fChmsFilePath;
|
FPCDirectivesHelpDatabase.DocsDir := fChmsFilePath;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChmHelpViewer.SetHelpEXE(AValue: String);
|
||||||
|
begin
|
||||||
|
if fHelpEXE=AValue then Exit;
|
||||||
|
fHelpEXE:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
function TChmHelpViewer.GetHelpEXE: String;
|
function TChmHelpViewer.GetHelpEXE: String;
|
||||||
begin
|
begin
|
||||||
if fHelpExe <> '' then
|
Result:=fHelpExe;
|
||||||
Exit(fHelpExe);
|
if Result='' then
|
||||||
Result := '$(LazarusDir)/components/chmhelp/lhelp/lhelp$(ExeExt)';
|
Result := SetDirSeparators('$(LazarusDir)/components/chmhelp/lhelp/lhelp$(ExeExt)');
|
||||||
if not IDEMacros.SubstituteMacros(Result) then
|
if not IDEMacros.SubstituteMacros(Result) then
|
||||||
Exit('');
|
Exit('');
|
||||||
Result := FixSlash(Result);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChmHelpViewer.GetFileNameAndURL(RawUrl:String; out FileName: String; out URL: String
|
function TChmHelpViewer.GetFileNameAndURL(RawUrl:String; out FileName: String; out URL: String
|
||||||
@ -183,11 +189,6 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChmHelpViewer.SetHelpEXE(AValue: String);
|
|
||||||
begin
|
|
||||||
fHelpExe := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChmHelpViewer.SetHelpLabel(AValue: String);
|
procedure TChmHelpViewer.SetHelpLabel(AValue: String);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -211,7 +212,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := mrCancel;
|
Result := mrCancel;
|
||||||
|
|
||||||
if FileExistsUTF8(HelpExe) = True then
|
if FileExistsUTF8(GetHelpExe) then
|
||||||
Exit(mrOK);
|
Exit(mrOK);
|
||||||
|
|
||||||
if not GetLazBuildEXE(Lazbuild) then
|
if not GetLazBuildEXE(Lazbuild) then
|
||||||
@ -390,8 +391,8 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
Result:=shrNone;
|
Result:=shrNone;
|
||||||
if (ExtractFileNameOnly(HelpEXE) = 'lhelp') and (CheckBuildLHelp <> mrOK) then begin
|
if (ExtractFileNameOnly(GetHelpEXE) = 'lhelp') and (CheckBuildLHelp <> mrOK) then begin
|
||||||
ErrMsg := 'The program "' + HelpEXE + '" doesn''t seem to exist'+LineEnding+
|
ErrMsg := 'The program "' + GetHelpEXE + '" doesn''t seem to exist'+LineEnding+
|
||||||
'or could not be built!';
|
'or could not be built!';
|
||||||
Exit(shrViewerNotFound);
|
Exit(shrViewerNotFound);
|
||||||
end;
|
end;
|
||||||
@ -421,8 +422,8 @@ begin
|
|||||||
|
|
||||||
FileName := IncludeTrailingPathDelimiter(DocsDir)+FileName;
|
FileName := IncludeTrailingPathDelimiter(DocsDir)+FileName;
|
||||||
|
|
||||||
if ExtractFileNameOnly(HelpExe) = 'lhelp' then begin
|
if ExtractFileNameOnly(GetHelpExe) = 'lhelp' then begin
|
||||||
fHelpConnection.StartHelpServer(HelpLabel, HelpExe);
|
fHelpConnection.StartHelpServer(HelpLabel, GetHelpExe);
|
||||||
Res := fHelpConnection.OpenURL(FileName, Url);
|
Res := fHelpConnection.OpenURL(FileName, Url);
|
||||||
end else begin
|
end else begin
|
||||||
if Trim(fHelpExeParams) = '' then
|
if Trim(fHelpExeParams) = '' then
|
||||||
@ -430,7 +431,7 @@ begin
|
|||||||
Result := shrViewerError;
|
Result := shrViewerError;
|
||||||
ErrMsg := 'If you do not use "lhelp" as viewer you have to setup '
|
ErrMsg := 'If you do not use "lhelp" as viewer you have to setup '
|
||||||
+ 'HelpExeParams correctly in' + sLineBreak
|
+ 'HelpExeParams correctly in' + sLineBreak
|
||||||
+ 'Environment Options -> Help -> Help Options -> '
|
+ 'Tools -> Options -> Help -> Help Options -> '
|
||||||
+ 'under HelpViewers - CHM Help Viewer' + sLineBreak
|
+ 'under HelpViewers - CHM Help Viewer' + sLineBreak
|
||||||
+ 'e.g. for HH.EXE (HTML Help in Windows) it must be' + sLineBreak
|
+ 'e.g. for HH.EXE (HTML Help in Windows) it must be' + sLineBreak
|
||||||
+ ' "%s::%s"' + sLineBreak
|
+ ' "%s::%s"' + sLineBreak
|
||||||
@ -441,9 +442,9 @@ begin
|
|||||||
Proc := TProcess.Create(nil);
|
Proc := TProcess.Create(nil);
|
||||||
try
|
try
|
||||||
{$if (fpc_version=2) and (fpc_release<5)}
|
{$if (fpc_version=2) and (fpc_release<5)}
|
||||||
Proc.CommandLine := Utf8ToSys(fHelpExe + ' ' + Format(fHelpExeParams, [FileName, Url]));
|
Proc.CommandLine := Utf8ToSys(GetHelpExe + ' ' + Format(fHelpExeParams, [FileName, Url]));
|
||||||
{$else}
|
{$else}
|
||||||
Proc.Executable := Utf8ToSys(fHelpExe);
|
Proc.Executable := Utf8ToSys(GetHelpExe);
|
||||||
Proc.Parameters.Add(Utf8ToSys(Format(fHelpExeParams, [FileName, Url])));
|
Proc.Parameters.Add(Utf8ToSys(Format(fHelpExeParams, [FileName, Url])));
|
||||||
{$endif}
|
{$endif}
|
||||||
Proc.Execute;
|
Proc.Execute;
|
||||||
|
Loading…
Reference in New Issue
Block a user