* ChmHelp: comments; harmonize code layout with other units in chmhelp

git-svn-id: trunk@46632 -
This commit is contained in:
reiniero 2014-10-21 12:10:55 +00:00
parent 874f3994ff
commit bb7231832e
4 changed files with 27 additions and 24 deletions

View File

@ -75,10 +75,12 @@ var
begin begin
if fStop^ then Exit; if fStop^ then Exit;
txt := AItem.KeyWord; txt := AItem.KeyWord;
// Fallback:
if txt = '' then txt := AItem.Text; if txt = '' then txt := AItem.Text;
txt := Trim(txt); txt := Trim(txt);
if not Assigned(fLastNode) or (fLastNode.Text <> txt) then if not Assigned(fLastNode) or (fLastNode.Text <> txt) then
begin begin
// Add new child node
fLastNode := AParentNode; fLastNode := AParentNode;
NewNode := TContentTreeNode(fTreeView.Items.AddChild(AParentNode, txt)); NewNode := TContentTreeNode(fTreeView.Items.AddChild(AParentNode, txt));
NewNode.Url := FixURL('/'+AItem.Local); NewNode.Url := FixURL('/'+AItem.Local);

View File

@ -31,11 +31,11 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure LoadKeywordList(const Path: string); procedure LoadKeywordList(const Path: string);
function GetNodesForKeyword(const HelpKeyword: string; function GetNodesForKeyword(const HelpKeyword: string;
var ListOfNodes: THelpNodeQueryList; var ErrMsg: string var ListOfNodes: THelpNodeQueryList; var ErrMsg: string
): TShowHelpResult; override; ): TShowHelpResult; override;
function ShowHelp(Query: THelpQuery; {%H-}BaseNode, NewNode: THelpNode; function ShowHelp(Query: THelpQuery; {%H-}BaseNode, NewNode: THelpNode;
{%H-}QueryItem: THelpQueryItem; {%H-}QueryItem: THelpQueryItem;
var ErrMsg: string): TShowHelpResult; override; var ErrMsg: string): TShowHelpResult; override;
property CHMSearchPath: string read FCHMSearchPath write FCHMSearchPath; property CHMSearchPath: string read FCHMSearchPath write FCHMSearchPath;
end; end;
@ -51,14 +51,14 @@ uses chmreader, chmsitemap;
procedure RegisterLangRefHelpDatabase; procedure RegisterLangRefHelpDatabase;
begin begin
if not Assigned(LangRefHelpDatabase) then if not Assigned(LangRefHelpDatabase) then
LangRefHelpDatabase := TLangRefHelpDatabase(HelpDatabases.CreateHelpDatabase(sFPCLangRef, LangRefHelpDatabase := TLangRefHelpDatabase(HelpDatabases.CreateHelpDatabase(sFPCLangRef, TLangRefHelpDatabase, true));
TLangRefHelpDatabase, true));
end; end;
{ TLangRefHelpDatabase } { TLangRefHelpDatabase }
procedure TLangRefHelpDatabase.ClearKeywordNodes; procedure TLangRefHelpDatabase.ClearKeywordNodes;
var i: Integer; var
i: Integer;
begin begin
for i := 0 to FKeywordNodes.Count - 1 do for i := 0 to FKeywordNodes.Count - 1 do
TObject(FKeywordNodes[i]).Free; TObject(FKeywordNodes[i]).Free;
@ -160,10 +160,10 @@ begin
begin begin
Result := shrDatabaseNotFound; Result := shrDatabaseNotFound;
ErrMsg := Format('ref.chm not found. Please put ref.chm help file in '+ LineEnding ErrMsg := Format('ref.chm not found. Please put ref.chm help file in '+ LineEnding
+ '%s' + LineEnding + '%s' + LineEnding
+'or set the path to it with "HelpFilesPath" in ' +'or set the path to it with "HelpFilesPath" in '
+' Environment Options -> Help -> Help Options ->' + LineEnding +' Environment Options -> Help -> Help Options ->' + LineEnding
+'under Viewers - CHM Help Viewer', [fCHMSearchPath]); +'under Viewers - CHM Help Viewer', [fCHMSearchPath]);
Exit; Exit;
end; end;
// HelpKeyword starts with KeywordPrefix // HelpKeyword starts with KeywordPrefix

View File

@ -40,11 +40,11 @@ begin
// FPDoc nodes for units in the LCL // FPDoc nodes for units in the LCL
FPDocNode := THelpNode.CreateURL(LCLHelpDatabase, FPDocNode := THelpNode.CreateURL(LCLHelpDatabase,
'LCL - Lazarus Component Library Units', 'LCL - Lazarus Component Library Units',
'file://index.html'); 'file://index.html');
LCLHelpDatabase.TOCNode := THelpNode.Create(LCLHelpDatabase, FPDocNode); LCLHelpDatabase.TOCNode := THelpNode.Create(LCLHelpDatabase, FPDocNode);
DirItem := THelpDBISourceDirectory.Create(FPDocNode, '$(LazarusDir)/lcl', DirItem := THelpDBISourceDirectory.Create(FPDocNode, '$(LazarusDir)/lcl',
'*.pp;*.pas;*.inc', True);// and once as normal page '*.pp;*.pas;*.inc', True);// and once as normal page
LCLHelpDatabase.RegisterItem(DirItem); LCLHelpDatabase.RegisterItem(DirItem);
end; end;

View File

@ -31,8 +31,8 @@ type
var ListOfNodes: THelpNodeQueryList; var ListOfNodes: THelpNodeQueryList;
var ErrMsg: string): TShowHelpResult; override; var ErrMsg: string): TShowHelpResult; override;
function ShowHelp(Query: THelpQuery; {%H-}BaseNode, NewNode: THelpNode; function ShowHelp(Query: THelpQuery; {%H-}BaseNode, NewNode: THelpNode;
{%H-}QueryItem: THelpQueryItem; {%H-}QueryItem: THelpQueryItem;
var ErrMsg: string): TShowHelpResult; override; var ErrMsg: string): TShowHelpResult; override;
function GetCHMSearchPath: string; function GetCHMSearchPath: string;
property CHMSearchPath: string read FCHMSearchPath write FCHMSearchPath; property CHMSearchPath: string read FCHMSearchPath write FCHMSearchPath;
function FindCHMFile: string; function FindCHMFile: string;
@ -52,7 +52,7 @@ begin
if not Assigned(FPCDirectivesHelpDatabase) then if not Assigned(FPCDirectivesHelpDatabase) then
FPCDirectivesHelpDatabase := FPCDirectivesHelpDatabase :=
TFPCDirectivesHelpDatabase(HelpDatabases.CreateHelpDatabase( TFPCDirectivesHelpDatabase(HelpDatabases.CreateHelpDatabase(
sFPCCompilerDirectives, TFPCDirectivesHelpDatabase, true)); sFPCCompilerDirectives, TFPCDirectivesHelpDatabase, true));
end; end;
{ TFPCDirectivesHelpDatabase } { TFPCDirectivesHelpDatabase }
@ -143,8 +143,8 @@ var
begin begin
Result := shrHelpNotFound; Result := shrHelpNotFound;
if (csDesigning in ComponentState) then Exit; if (csDesigning in ComponentState) then Exit;
if (FPCDirectiveHelpPrefix<>'') if (FPCDirectiveHelpPrefix<>'') and
and (LeftStr(HelpDirective, Length(FPCDirectiveHelpPrefix)) = FPCDirectiveHelpPrefix) then (LeftStr(HelpDirective, Length(FPCDirectiveHelpPrefix)) = FPCDirectiveHelpPrefix) then
begin begin
Filename:=FindCHMFile; Filename:=FindCHMFile;
debugln(['TFPCDirectivesHelpDatabase.GetNodesForDirective ',Filename]); debugln(['TFPCDirectivesHelpDatabase.GetNodesForDirective ',Filename]);
@ -152,10 +152,10 @@ begin
begin begin
Result := shrDatabaseNotFound; Result := shrDatabaseNotFound;
ErrMsg := Format('prog.chm not found. Please put prog.chm help file in '+ LineEnding ErrMsg := Format('prog.chm not found. Please put prog.chm help file in '+ LineEnding
+ '%s' + LineEnding + '%s' + LineEnding
+'or set the path to it with "HelpFilesPath" in ' +'or set the path to it with "HelpFilesPath" in '
+' Environment Options -> Help -> Help Options ->' + LineEnding +' Environment Options -> Help -> Help Options ->' + LineEnding
+'under Viewers - CHM Help Viewer', [FCHMSearchPath]); +'under Viewers - CHM Help Viewer', [FCHMSearchPath]);
Exit; Exit;
end; end;
// HelpDirective starts with DirectivePrefix // HelpDirective starts with DirectivePrefix
@ -182,7 +182,8 @@ end;
function TFPCDirectivesHelpDatabase.GetCHMSearchPath: string; function TFPCDirectivesHelpDatabase.GetCHMSearchPath: string;
begin begin
Result:=FCHMSearchPath; Result:=FCHMSearchPath;
if Result='' then begin if Result='' then
begin
Result := '$(LazarusDir)/docs/html;$(LazarusDir)/docs/chm'; Result := '$(LazarusDir)/docs/html;$(LazarusDir)/docs/chm';
IDEMacros.SubstituteMacros(Result); IDEMacros.SubstituteMacros(Result);
Result:=MinimizeSearchPath(SetDirSeparators(Result)); Result:=MinimizeSearchPath(SetDirSeparators(Result));