mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 18:06:12 +02:00
+ Help debug infos added
git-svn-id: trunk@6045 -
This commit is contained in:
parent
c31dab5ee5
commit
d027efe65e
@ -120,6 +120,7 @@ type
|
||||
function LoadIndex: boolean; virtual;
|
||||
function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual;
|
||||
function ReadTopic(T: PTopic): boolean; virtual;
|
||||
function GetTopicInfo(T: PTopic) : string; virtual;
|
||||
private
|
||||
procedure MaintainTopicCache;
|
||||
end;
|
||||
@ -134,6 +135,7 @@ type
|
||||
function AddFile(const FileName, Param: string): PHelpFile;
|
||||
function AddHelpFile(H: PHelpFile): boolean;
|
||||
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 BuildIndexTopic: PTopic; virtual;
|
||||
destructor Done; virtual;
|
||||
@ -702,6 +704,12 @@ begin
|
||||
ReadTopic:=false; { remove warning }
|
||||
end;
|
||||
|
||||
function THelpFile.GetTopicInfo(T: PTopic) : string;
|
||||
begin
|
||||
Abstract;
|
||||
GetTopicInfo:=''; { remove warning }
|
||||
end;
|
||||
|
||||
procedure THelpFile.MaintainTopicCache;
|
||||
var Count: sw_integer;
|
||||
MinLRU: longint;
|
||||
@ -802,6 +810,28 @@ begin
|
||||
LoadTopic:=P;
|
||||
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 ScanHelpFile(H: PHelpFile): boolean; {$ifndef FPC}far;{$endif}
|
||||
function Search(P: PIndexEntry): boolean; {$ifndef FPC}far;{$endif}
|
||||
|
@ -207,6 +207,7 @@ type
|
||||
procedure InitScrollBars; virtual;
|
||||
procedure InitHelpView; virtual;
|
||||
procedure ShowIndex; virtual;
|
||||
procedure ShowDebugInfos; virtual;
|
||||
procedure ShowTopic(SourceFileID: word; Context: THelpCtx); virtual;
|
||||
procedure HandleEvent(var Event: TEvent); virtual;
|
||||
procedure Close; virtual;
|
||||
@ -861,8 +862,17 @@ begin
|
||||
end;
|
||||
|
||||
function THelpViewer.GetLinkTarget(Index: sw_integer): string;
|
||||
var
|
||||
Ctx : THelpCtx;
|
||||
ID : sw_integer;
|
||||
begin
|
||||
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;
|
||||
|
||||
function THelpViewer.GetLinkText(Index: sw_integer): string;
|
||||
@ -1356,6 +1366,18 @@ begin
|
||||
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;
|
||||
var R: TRect;
|
||||
begin
|
||||
|
@ -86,6 +86,7 @@ type
|
||||
procedure DocTITLE(Entered: boolean); virtual;
|
||||
procedure DocBODY(Entered: boolean); virtual;
|
||||
procedure DocAnchor(Entered: boolean); virtual;
|
||||
procedure DocUnknownTag; virtual;
|
||||
procedure DocHeading(Level: integer; Entered: boolean); virtual;
|
||||
procedure DocParagraph(Entered: boolean); virtual;
|
||||
procedure DocBreak; virtual;
|
||||
@ -148,6 +149,7 @@ type
|
||||
constructor Init(AID: word);
|
||||
destructor Done; virtual;
|
||||
public
|
||||
function GetTopicInfo(T: PTopic) : string; virtual;
|
||||
function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual;
|
||||
function ReadTopic(T: PTopic): boolean; virtual;
|
||||
private
|
||||
@ -642,23 +644,29 @@ begin
|
||||
begin
|
||||
if DocGetTagParam('HREF',HRef)=false then HRef:='';
|
||||
if DocGetTagParam('NAME',Name)=false then Name:='';
|
||||
if (HRef='') and (Name='') then
|
||||
if {(HRef='') and} (Name='') then
|
||||
if DocGetTagParam('ID',Name)=false then
|
||||
Name:='';
|
||||
if Name<>'' then
|
||||
begin
|
||||
Topic^.NamedMarks^.InsertStr(Name);
|
||||
{$ifdef DEBUG}
|
||||
DebugMessage('',' Adding Name '+Name,1,1);
|
||||
{$endif DEBUG}
|
||||
AddChar(hscNamedMark);
|
||||
end;
|
||||
if (HRef<>'')then
|
||||
begin
|
||||
InAnchor:=true;
|
||||
AddChar(hscLink);
|
||||
if (LinkPtr<MaxTopicLinks){and
|
||||
if (LinkPtr<MaxTopicLinks){ and
|
||||
not DisableCrossIndexing} then
|
||||
begin
|
||||
InAnchor:=true;
|
||||
AddChar(hscLink);
|
||||
HRef:=CompleteURL(URL,HRef);
|
||||
LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
|
||||
{$ifdef DEBUG}
|
||||
DebugMessage('',' Adding Link '+HRef,1,1);
|
||||
{$endif DEBUG}
|
||||
Inc(LinkPtr);
|
||||
end;
|
||||
end;
|
||||
@ -670,6 +678,14 @@ begin
|
||||
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);
|
||||
begin
|
||||
Align:=UpcaseStr(Align);
|
||||
@ -803,8 +819,10 @@ begin
|
||||
begin
|
||||
StorePreformatted:=InPreformatted;
|
||||
InPreformatted:=true;
|
||||
DocGetTagParam('SRC',src);
|
||||
AddChar(hscInImage);
|
||||
AddText('['+Alt+']');
|
||||
AddText('[--'+Src+'--'+hscLineBreak);
|
||||
AddText(Alt+hscLineBreak+'--]');
|
||||
AddChar(hscInImage);
|
||||
AddChar(hscNormText);
|
||||
InPreformatted:=StorePreformatted;
|
||||
@ -1202,9 +1220,8 @@ begin
|
||||
SearchTopic:=P;
|
||||
end;
|
||||
|
||||
function TCustomHTMLHelpFile.ReadTopic(T: PTopic): boolean;
|
||||
function TCustomHTMLHelpFile.GetTopicInfo(T: PTopic) : string;
|
||||
var OK: boolean;
|
||||
HTMLFile: PMemoryTextFile;
|
||||
Name: string;
|
||||
Link,Bookmark: string;
|
||||
P: sw_integer;
|
||||
@ -1231,6 +1248,43 @@ begin
|
||||
Bookmark:=copy(Link,P+1,length(Link));
|
||||
Link:=copy(Link,1,P-1);
|
||||
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
|
||||
Name:=CompletePath(CurFileName,Link);}
|
||||
Name:=Link;
|
||||
@ -1281,7 +1335,14 @@ begin
|
||||
if BookMark='' then
|
||||
T^.StartNamedMark:=0
|
||||
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;
|
||||
ReadTopic:=OK;
|
||||
end;
|
||||
|
@ -38,6 +38,7 @@ type
|
||||
private
|
||||
CurLinkText: string;
|
||||
CurURL: string;
|
||||
CurName: string;
|
||||
CurDoc: string;
|
||||
InAnchor,InNameAnchor: boolean;
|
||||
LastSynonym: PHTMLLinkScanDocument;
|
||||
@ -170,23 +171,44 @@ begin
|
||||
begin
|
||||
CurLinkText:='';
|
||||
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
|
||||
InNameAnchor:=true;
|
||||
If Pos('#',CurURL)=0 then
|
||||
CurURL:=CurDoc+'#'+CurURL;
|
||||
If Pos('#',CurName)=0 then
|
||||
CurName:=CurDoc+'#'+CurName;
|
||||
CurName:=Trim(CurName);
|
||||
CurName:=CompleteURL(GetDocumentBaseURL,CurName);
|
||||
if CurURL='' then
|
||||
CurURL:=CurName;
|
||||
end
|
||||
else
|
||||
CurURL:='';
|
||||
CurName:='';
|
||||
CurURL:=Trim(CurURL);
|
||||
CurURL:=CompleteURL(GetDocumentBaseURL,CurURL);
|
||||
end
|
||||
else
|
||||
begin
|
||||
CurLinkText:=Trim(CurLinkText);
|
||||
if InNameAnchor or
|
||||
(CheckURL(CurURL) and CheckText(CurLinkText)and not DisableCrossIndexing) then
|
||||
AddLink(CurLinkText,CurURL);
|
||||
if (CurName='') and CheckURL(CurURL) and CheckText(CurLinkText) and
|
||||
not DisableCrossIndexing then
|
||||
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;
|
||||
end;
|
||||
InAnchor:=Entered;
|
||||
|
Loading…
Reference in New Issue
Block a user