+ Help debug infos added

git-svn-id: trunk@6045 -
This commit is contained in:
pierre 2007-01-18 13:56:49 +00:00
parent c31dab5ee5
commit d027efe65e
4 changed files with 150 additions and 15 deletions

View File

@ -120,6 +120,7 @@ type
function LoadIndex: boolean; virtual; function LoadIndex: boolean; virtual;
function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual; function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual;
function ReadTopic(T: PTopic): boolean; virtual; function ReadTopic(T: PTopic): boolean; virtual;
function GetTopicInfo(T: PTopic) : string; virtual;
private private
procedure MaintainTopicCache; procedure MaintainTopicCache;
end; end;
@ -134,6 +135,7 @@ type
function AddFile(const FileName, Param: string): PHelpFile; function AddFile(const FileName, Param: string): PHelpFile;
function AddHelpFile(H: PHelpFile): boolean; function AddHelpFile(H: PHelpFile): boolean;
function LoadTopic(SourceFileID: word; Context: THelpCtx): PTopic; virtual; function LoadTopic(SourceFileID: word; Context: THelpCtx): PTopic; virtual;
function GetTopicInfo(SourceFileID: word; Context: THelpCtx) : string; virtual;
function TopicSearch(Keyword: string; var FileID: word; var Context: THelpCtx): boolean; virtual; function TopicSearch(Keyword: string; var FileID: word; var Context: THelpCtx): boolean; virtual;
function BuildIndexTopic: PTopic; virtual; function BuildIndexTopic: PTopic; virtual;
destructor Done; virtual; destructor Done; virtual;
@ -702,6 +704,12 @@ begin
ReadTopic:=false; { remove warning } ReadTopic:=false; { remove warning }
end; end;
function THelpFile.GetTopicInfo(T: PTopic) : string;
begin
Abstract;
GetTopicInfo:=''; { remove warning }
end;
procedure THelpFile.MaintainTopicCache; procedure THelpFile.MaintainTopicCache;
var Count: sw_integer; var Count: sw_integer;
MinLRU: longint; MinLRU: longint;
@ -802,6 +810,28 @@ begin
LoadTopic:=P; LoadTopic:=P;
end; end;
function THelpFacility.GetTopicInfo(SourceFileID: word; Context: THelpCtx) : string;
var P: PTopic;
H: PHelpFile;
begin
if (SourceFileID=0) and (Context=0) then
begin
P:=BuildIndexTopic;
end
else
begin
H:=SearchTopicOwner(SourceFileID,Context);
if (H=nil) then P:=nil else
P:=H^.SearchTopic(Context);
end;
If not assigned(P) then
GetTopicInfo:='Not found'
else
GetTopicInfo:=H^.GetTopicInfo(P);
end;
function THelpFacility.TopicSearch(Keyword: string; var FileID: word; var Context: THelpCtx): boolean; function THelpFacility.TopicSearch(Keyword: string; var FileID: word; var Context: THelpCtx): boolean;
function ScanHelpFile(H: PHelpFile): boolean; {$ifndef FPC}far;{$endif} function ScanHelpFile(H: PHelpFile): boolean; {$ifndef FPC}far;{$endif}
function Search(P: PIndexEntry): boolean; {$ifndef FPC}far;{$endif} function Search(P: PIndexEntry): boolean; {$ifndef FPC}far;{$endif}

View File

@ -207,6 +207,7 @@ type
procedure InitScrollBars; virtual; procedure InitScrollBars; virtual;
procedure InitHelpView; virtual; procedure InitHelpView; virtual;
procedure ShowIndex; virtual; procedure ShowIndex; virtual;
procedure ShowDebugInfos; virtual;
procedure ShowTopic(SourceFileID: word; Context: THelpCtx); virtual; procedure ShowTopic(SourceFileID: word; Context: THelpCtx); virtual;
procedure HandleEvent(var Event: TEvent); virtual; procedure HandleEvent(var Event: TEvent); virtual;
procedure Close; virtual; procedure Close; virtual;
@ -861,8 +862,17 @@ begin
end; end;
function THelpViewer.GetLinkTarget(Index: sw_integer): string; function THelpViewer.GetLinkTarget(Index: sw_integer): string;
var
Ctx : THelpCtx;
ID : sw_integer;
begin begin
GetLinkTarget:=''; GetLinkTarget:='';
if HelpTopic=nil then begin ID:=0; Ctx:=0; end else
begin
ID:=GetLinkFileID(Index);
Ctx:=GetLinkContext(Index);
end;
GetLinkTarget:=HelpFacility^.GetTopicInfo(ID,CTx);
end; end;
function THelpViewer.GetLinkText(Index: sw_integer): string; function THelpViewer.GetLinkText(Index: sw_integer): string;
@ -1356,6 +1366,18 @@ begin
end; end;
end; end;
procedure THelpWindow.ShowDebugInfos;
begin
{$ifdef DEBUG}
DebugMessage(GetTitle(255),'Generic Help window',1,1);
if HelpView^.CurLink<>-1 then
begin
DebugMessage('','Curlink is '+IntToStr(HelpView^.CurLink),1,1);
DebugMessage('',HelpView^.GetLinkTarget(HelpView^.CurLink),1,1);
end;
{$endif DEBUG}
end;
procedure THelpWindow.InitScrollBars; procedure THelpWindow.InitScrollBars;
var R: TRect; var R: TRect;
begin begin

View File

@ -86,6 +86,7 @@ type
procedure DocTITLE(Entered: boolean); virtual; procedure DocTITLE(Entered: boolean); virtual;
procedure DocBODY(Entered: boolean); virtual; procedure DocBODY(Entered: boolean); virtual;
procedure DocAnchor(Entered: boolean); virtual; procedure DocAnchor(Entered: boolean); virtual;
procedure DocUnknownTag; virtual;
procedure DocHeading(Level: integer; Entered: boolean); virtual; procedure DocHeading(Level: integer; Entered: boolean); virtual;
procedure DocParagraph(Entered: boolean); virtual; procedure DocParagraph(Entered: boolean); virtual;
procedure DocBreak; virtual; procedure DocBreak; virtual;
@ -148,6 +149,7 @@ type
constructor Init(AID: word); constructor Init(AID: word);
destructor Done; virtual; destructor Done; virtual;
public public
function GetTopicInfo(T: PTopic) : string; virtual;
function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual; function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual;
function ReadTopic(T: PTopic): boolean; virtual; function ReadTopic(T: PTopic): boolean; virtual;
private private
@ -642,23 +644,29 @@ begin
begin begin
if DocGetTagParam('HREF',HRef)=false then HRef:=''; if DocGetTagParam('HREF',HRef)=false then HRef:='';
if DocGetTagParam('NAME',Name)=false then Name:=''; if DocGetTagParam('NAME',Name)=false then Name:='';
if (HRef='') and (Name='') then if {(HRef='') and} (Name='') then
if DocGetTagParam('ID',Name)=false then if DocGetTagParam('ID',Name)=false then
Name:=''; Name:='';
if Name<>'' then if Name<>'' then
begin begin
Topic^.NamedMarks^.InsertStr(Name); Topic^.NamedMarks^.InsertStr(Name);
{$ifdef DEBUG}
DebugMessage('',' Adding Name '+Name,1,1);
{$endif DEBUG}
AddChar(hscNamedMark); AddChar(hscNamedMark);
end; end;
if (HRef<>'')then if (HRef<>'')then
begin begin
InAnchor:=true; if (LinkPtr<MaxTopicLinks){ and
AddChar(hscLink);
if (LinkPtr<MaxTopicLinks){and
not DisableCrossIndexing} then not DisableCrossIndexing} then
begin begin
InAnchor:=true;
AddChar(hscLink);
HRef:=CompleteURL(URL,HRef); HRef:=CompleteURL(URL,HRef);
LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef); LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
{$ifdef DEBUG}
DebugMessage('',' Adding Link '+HRef,1,1);
{$endif DEBUG}
Inc(LinkPtr); Inc(LinkPtr);
end; end;
end; end;
@ -670,6 +678,14 @@ begin
end; end;
end; end;
procedure THTMLTopicRenderer.DocUnknownTag;
begin
{$ifdef DEBUG}
DebugMessage('',' Unknown tag "'+TagName+'" params "'+
TagParams+'"',1,1);
{$endif DEBUG}
end;
procedure DecodeAlign(Align: string; var PAlign: TParagraphAlign); procedure DecodeAlign(Align: string; var PAlign: TParagraphAlign);
begin begin
Align:=UpcaseStr(Align); Align:=UpcaseStr(Align);
@ -803,8 +819,10 @@ begin
begin begin
StorePreformatted:=InPreformatted; StorePreformatted:=InPreformatted;
InPreformatted:=true; InPreformatted:=true;
DocGetTagParam('SRC',src);
AddChar(hscInImage); AddChar(hscInImage);
AddText('['+Alt+']'); AddText('[--'+Src+'--'+hscLineBreak);
AddText(Alt+hscLineBreak+'--]');
AddChar(hscInImage); AddChar(hscInImage);
AddChar(hscNormText); AddChar(hscNormText);
InPreformatted:=StorePreformatted; InPreformatted:=StorePreformatted;
@ -1202,9 +1220,8 @@ begin
SearchTopic:=P; SearchTopic:=P;
end; end;
function TCustomHTMLHelpFile.ReadTopic(T: PTopic): boolean; function TCustomHTMLHelpFile.GetTopicInfo(T: PTopic) : string;
var OK: boolean; var OK: boolean;
HTMLFile: PMemoryTextFile;
Name: string; Name: string;
Link,Bookmark: string; Link,Bookmark: string;
P: sw_integer; P: sw_integer;
@ -1231,6 +1248,43 @@ begin
Bookmark:=copy(Link,P+1,length(Link)); Bookmark:=copy(Link,P+1,length(Link));
Link:=copy(Link,1,P-1); Link:=copy(Link,1,P-1);
end; end;
{ if CurFileName='' then Name:=Link else
Name:=CompletePath(CurFileName,Link);}
Name:=Link;
end;
end;
GetTopicInfo:=Name+'#'+BookMark;
end;
function TCustomHTMLHelpFile.ReadTopic(T: PTopic): boolean;
var OK: boolean;
HTMLFile: PMemoryTextFile;
Name: string;
Link,Bookmark: string;
P: sw_integer;
begin
Bookmark:='';
OK:=T<>nil;
if OK then
begin
if T^.HelpCtx=0 then
begin
Name:=DefaultFileName;
P:=0;
end
else
begin
Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
Link:=FormatPath(Link);
{$ifdef DEBUG}
DebugMessage(Link,' looking for',1,1);
{$endif DEBUG}
P:=Pos('#',Link);
if P>0 then
begin
Bookmark:=copy(Link,P+1,length(Link));
Link:=copy(Link,1,P-1);
end;
{ if CurFileName='' then Name:=Link else { if CurFileName='' then Name:=Link else
Name:=CompletePath(CurFileName,Link);} Name:=CompletePath(CurFileName,Link);}
Name:=Link; Name:=Link;
@ -1281,7 +1335,14 @@ begin
if BookMark='' then if BookMark='' then
T^.StartNamedMark:=0 T^.StartNamedMark:=0
else else
T^.StartNamedMark:=T^.GetNamedMarkIndex(BookMark)+1; begin
P:=T^.GetNamedMarkIndex(BookMark);
{$ifdef DEBUG}
if p=-1 then
DebugMessage(Name,Link+'#'+Bookmark+' bookmark not found',1,1);
{$endif DEBUG}
T^.StartNamedMark:=P+1;
end;
end; end;
ReadTopic:=OK; ReadTopic:=OK;
end; end;

View File

@ -38,6 +38,7 @@ type
private private
CurLinkText: string; CurLinkText: string;
CurURL: string; CurURL: string;
CurName: string;
CurDoc: string; CurDoc: string;
InAnchor,InNameAnchor: boolean; InAnchor,InNameAnchor: boolean;
LastSynonym: PHTMLLinkScanDocument; LastSynonym: PHTMLLinkScanDocument;
@ -170,23 +171,44 @@ begin
begin begin
CurLinkText:=''; CurLinkText:='';
if DocGetTagParam('HREF',CurURL)=false then if DocGetTagParam('HREF',CurURL)=false then
if DocGetTagParam('NAME',CurURL) then CurURL:='';
if not DocGetTagParam('NAME',CurName) then
if not DocGetTagParam('ID',CurName) then
CurName:='';
if CurName<>'' then
begin begin
InNameAnchor:=true; InNameAnchor:=true;
If Pos('#',CurURL)=0 then If Pos('#',CurName)=0 then
CurURL:=CurDoc+'#'+CurURL; CurName:=CurDoc+'#'+CurName;
CurName:=Trim(CurName);
CurName:=CompleteURL(GetDocumentBaseURL,CurName);
if CurURL='' then
CurURL:=CurName;
end end
else else
CurURL:=''; CurName:='';
CurURL:=Trim(CurURL); CurURL:=Trim(CurURL);
CurURL:=CompleteURL(GetDocumentBaseURL,CurURL); CurURL:=CompleteURL(GetDocumentBaseURL,CurURL);
end end
else else
begin begin
CurLinkText:=Trim(CurLinkText); CurLinkText:=Trim(CurLinkText);
if InNameAnchor or if (CurName='') and CheckURL(CurURL) and CheckText(CurLinkText) and
(CheckURL(CurURL) and CheckText(CurLinkText)and not DisableCrossIndexing) then not DisableCrossIndexing then
AddLink(CurLinkText,CurURL); begin
AddLink(CurLinkText,CurURL);
{$ifdef DEBUG}
DebugMessage('',' Adding ScanLink "'+CurLinkText+'" to "'+
CurURL+'"',1,1);
{$endif DEBUG}
end;
if InNameAnchor and CheckURL(CurName) and CheckText(CurLinkText) then
begin
AddLink(CurLinkText,CurName);
{$ifdef DEBUG}
DebugMessage('',' Adding ScanName '+CurLinkText+' to '+CurName,1,1);
{$endif DEBUG}
end;
InNameAnchor:=false; InNameAnchor:=false;
end; end;
InAnchor:=Entered; InAnchor:=Entered;