chmhelp: fixes to show correct message about missing prog.chm

git-svn-id: trunk@32337 -
This commit is contained in:
mattias 2011-09-14 17:30:11 +00:00
parent 9c341414d9
commit a5310c119f
2 changed files with 40 additions and 43 deletions

View File

@ -68,51 +68,41 @@ var
begin
ADirective := UpperCase(ADirective);
Result := False;
if FDocsDir = '' then
begin
FDocsDir := '$(LazarusDir)';
IDEMacros.SubstituteMacros(FDocsDir);
FDocsDir := AppendPathDelim(FDocsDir) + 'docs' + PathDelim + 'html';
end;
FDocsDir := AppendPathDelim(FDocsDir);
if FileExistsUTF8(FDocsDir + 'prog.chm') then
begin
chm := TChmFileList.Create(Utf8ToSys(FDocsDir + 'prog.chm'));
try
if chm.Count = 0 then Exit;
fchm := chm.Chm[0];
chm := TChmFileList.Create(Utf8ToSys(FDocsDir + 'prog.chm'));
try
if chm.Count = 0 then Exit;
fchm := chm.Chm[0];
if fchm.SearchReader = nil then
begin
ms := fchm.GetObject('/$FIftiMain');
if ms = nil then Exit;
SearchReader := TChmSearchReader.Create(ms, True); //frees the stream when done
fchm.SearchReader := SearchReader;
end
else
SearchReader := fchm.SearchReader;
SearchReader.LookupWord(Copy(ADirective, 2, MaxInt), TitleResults);
for k := 0 to High(TitleResults) do
begin
URL := fchm.LookupTopicByID(TitleResults[k].TopicIndex, DocTitle);
i := Pos(ADirective, DocTitle);
if (i = 0) or (Length(DocTitle) >= i + Length(ADirective))
and (upCase(DocTitle[i + Length(ADirective)]) in ['A'..'Z','0'..'9']) then Continue;
if (Length(URL) > 0) and (URL[1] = '/') then
Delete(URL, 1, 1);
if URL = '' then Continue;
DirectiveNode := THelpNode.CreateURL(Self, ADirective, 'prog.chm://' + URL);
DirectiveNode.Title := 'FPC directives: ' + DocTitle;
CreateNodeQueryListAndAdd(DirectiveNode, nil, ListOfNodes, True);
FDirectiveNodes.Add(DirectiveNode);
Result := True;
end;
fchm.Free;
finally
chm.Free;
if fchm.SearchReader = nil then
begin
ms := fchm.GetObject('/$FIftiMain');
if ms = nil then Exit;
SearchReader := TChmSearchReader.Create(ms, True); //frees the stream when done
fchm.SearchReader := SearchReader;
end
else
SearchReader := fchm.SearchReader;
SearchReader.LookupWord(Copy(ADirective, 2, MaxInt), TitleResults);
for k := 0 to High(TitleResults) do
begin
URL := fchm.LookupTopicByID(TitleResults[k].TopicIndex, DocTitle);
i := Pos(ADirective, DocTitle);
if (i = 0) or (Length(DocTitle) >= i + Length(ADirective))
and (upCase(DocTitle[i + Length(ADirective)]) in ['A'..'Z','0'..'9']) then Continue;
if (Length(URL) > 0) and (URL[1] = '/') then
Delete(URL, 1, 1);
if URL = '' then Continue;
DirectiveNode := THelpNode.CreateURL(Self, ADirective, 'prog.chm://' + URL);
DirectiveNode.Title := 'FPC directives: ' + DocTitle;
CreateNodeQueryListAndAdd(DirectiveNode, nil, ListOfNodes, True);
FDirectiveNodes.Add(DirectiveNode);
Result := True;
end;
fchm.Free;
finally
chm.Free;
end;
end;
@ -148,6 +138,13 @@ begin
if (FPCDirectiveHelpPrefix<>'')
and (LeftStr(HelpDirective, Length(FPCDirectiveHelpPrefix)) = FPCDirectiveHelpPrefix) then
begin
if FDocsDir = '' then
begin
FDocsDir := '$(LazarusDir)';
IDEMacros.SubstituteMacros(FDocsDir);
FDocsDir := AppendPathDelim(FDocsDir) + 'docs' + PathDelim + 'html';
end;
FDocsDir := AppendPathDelim(FDocsDir);
if not FileExistsUTF8(FDocsDir + 'prog.chm') then
begin
Result := shrDatabaseNotFound;

View File

@ -1491,7 +1491,7 @@ end;
constructor TExternHelpFileSelector.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
inherited CreateNew(TheOwner);
FileListBox:=TListBox.Create(Self);
with FileListBox do begin