mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:20:46 +02:00
implemented help jump to FPDoc html unit
git-svn-id: trunk@5838 -
This commit is contained in:
parent
e910a6ac44
commit
845b65c847
@ -36,9 +36,9 @@ uses
|
|||||||
Classes, SysUtils, LCLProc, Forms, Controls, Buttons, StdCtrls, Dialogs,
|
Classes, SysUtils, LCLProc, Forms, Controls, Buttons, StdCtrls, Dialogs,
|
||||||
CodeToolManager, CodeAtom, CodeCache, CustomCodeTool, CodeTree,
|
CodeToolManager, CodeAtom, CodeCache, CustomCodeTool, CodeTree,
|
||||||
PascalParserTool, FindDeclarationTool,
|
PascalParserTool, FindDeclarationTool,
|
||||||
HelpIntf, HelpHTML, DialogProcs,
|
HelpIntf, HelpHTML, HelpFPDoc,
|
||||||
IDEOptionDefs, EnvironmentOpts, AboutFrm, Project, PackageDefs, MainBar,
|
TransferMacros, DialogProcs, IDEOptionDefs, EnvironmentOpts, AboutFrm,
|
||||||
HelpOptions, MainIntf;
|
Project, PackageDefs, MainBar, HelpOptions, MainIntf;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TBaseHelpManager }
|
{ TBaseHelpManager }
|
||||||
@ -62,13 +62,15 @@ type
|
|||||||
|
|
||||||
TIDEHelpDatabases = class(THelpDatabases)
|
TIDEHelpDatabases = class(THelpDatabases)
|
||||||
public
|
public
|
||||||
function ShowHelpSelector(Nodes: TList; var ErrMsg: string;
|
function ShowHelpSelector(Query: THelpQuery; Nodes: TList;
|
||||||
|
var ErrMsg: string;
|
||||||
var Selection: THelpNode): TShowHelpResult; override;
|
var Selection: THelpNode): TShowHelpResult; override;
|
||||||
procedure ShowError(ShowResult: TShowHelpResult; const ErrMsg: string); override;
|
procedure ShowError(ShowResult: TShowHelpResult; const ErrMsg: string); override;
|
||||||
function GetBaseDirectoryForBasePathObject(BasePathObject: TObject): string; override;
|
function GetBaseDirectoryForBasePathObject(BasePathObject: TObject): string; override;
|
||||||
function ShowHelpForSourcePosition(const Filename: string;
|
function ShowHelpForSourcePosition(Query: THelpQuerySourcePosition;
|
||||||
const CodePos: TPoint;
|
|
||||||
var ErrMsg: string): TShowHelpResult; override;
|
var ErrMsg: string): TShowHelpResult; override;
|
||||||
|
function StrHasMacros(const s: string): boolean; override;
|
||||||
|
function SubstituteMacros(var s: string): boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ type
|
|||||||
procedure mnuHelpOnlineHelpClicked(Sender: TObject);
|
procedure mnuHelpOnlineHelpClicked(Sender: TObject);
|
||||||
private
|
private
|
||||||
FMainHelpDB: THelpDatabase;
|
FMainHelpDB: THelpDatabase;
|
||||||
|
FFCLHelpDB: THelpDatabase;
|
||||||
procedure RegisterIDEHelpDatabases;
|
procedure RegisterIDEHelpDatabases;
|
||||||
procedure RegisterDefaultIDEHelpViewers;
|
procedure RegisterDefaultIDEHelpViewers;
|
||||||
public
|
public
|
||||||
@ -100,11 +103,14 @@ type
|
|||||||
var ErrMsg: string): TShowHelpResult; override;
|
var ErrMsg: string): TShowHelpResult; override;
|
||||||
public
|
public
|
||||||
property MainHelpDB: THelpDatabase read FMainHelpDB;
|
property MainHelpDB: THelpDatabase read FMainHelpDB;
|
||||||
|
property FCLHelpDB: THelpDatabase read FFCLHelpDB;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Help Contexts for IDE help }
|
{ Help Contexts for IDE help }
|
||||||
const
|
const
|
||||||
lihcStartPage = 'StartPage';
|
lihcStartPage = 'StartPage';
|
||||||
|
lihcFCLStartPage = 'FCLStartPage';
|
||||||
|
lihcFCLUnits = 'FCLUnits';
|
||||||
|
|
||||||
var
|
var
|
||||||
HelpBoss: TBaseHelpManager;
|
HelpBoss: TBaseHelpManager;
|
||||||
@ -232,8 +238,8 @@ end;
|
|||||||
|
|
||||||
{ TIDEHelpDatabases }
|
{ TIDEHelpDatabases }
|
||||||
|
|
||||||
function TIDEHelpDatabases.ShowHelpSelector(Nodes: TList; var ErrMsg: string;
|
function TIDEHelpDatabases.ShowHelpSelector(Query: THelpQuery; Nodes: TList;
|
||||||
var Selection: THelpNode): TShowHelpResult;
|
var ErrMsg: string; var Selection: THelpNode): TShowHelpResult;
|
||||||
var
|
var
|
||||||
Dialog: THelpSelectorDialog;
|
Dialog: THelpSelectorDialog;
|
||||||
i: LongInt;
|
i: LongInt;
|
||||||
@ -284,12 +290,26 @@ begin
|
|||||||
Result:=TProject(BasePathObject).ProjectDirectory
|
Result:=TProject(BasePathObject).ProjectDirectory
|
||||||
else if BasePathObject is TLazPackage then
|
else if BasePathObject is TLazPackage then
|
||||||
Result:=TLazPackage(BasePathObject).Directory;
|
Result:=TLazPackage(BasePathObject).Directory;
|
||||||
|
SubstituteMacros(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDEHelpDatabases.ShowHelpForSourcePosition(const Filename: string;
|
function TIDEHelpDatabases.ShowHelpForSourcePosition(
|
||||||
const CodePos: TPoint; var ErrMsg: string): TShowHelpResult;
|
Query: THelpQuerySourcePosition; var ErrMsg: string): TShowHelpResult;
|
||||||
begin
|
begin
|
||||||
Result:=HelpBoss.ShowHelpForSourcePosition(Filename,CodePos,ErrMsg);
|
Result:=HelpBoss.ShowHelpForSourcePosition(Query.Filename,
|
||||||
|
Query.SourcePosition,ErrMsg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIDEHelpDatabases.StrHasMacros(const s: string): boolean;
|
||||||
|
begin
|
||||||
|
Result:=MainIDEInterface.MacroList.StrHasMacros(s);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIDEHelpDatabases.SubstituteMacros(var s: string): boolean;
|
||||||
|
begin
|
||||||
|
//debugln('TIDEHelpDatabases.SubstituteMacros s="',s,'" ');
|
||||||
|
Result:=MainIDEInterface.MacroList.SubstituteStr(s);
|
||||||
|
//debugln('TIDEHelpDatabases.SubstituteMacros END s="',s,'"');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ THelpManager }
|
{ THelpManager }
|
||||||
@ -311,19 +331,60 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THelpManager.RegisterIDEHelpDatabases;
|
procedure THelpManager.RegisterIDEHelpDatabases;
|
||||||
var
|
|
||||||
HTMLHelp: THTMLHelpDatabase;
|
procedure CreateMainIDEHelpDB;
|
||||||
StartNode: THelpNode;
|
var
|
||||||
|
StartNode: THelpNode;
|
||||||
|
HTMLHelp: THTMLHelpDatabase;
|
||||||
|
begin
|
||||||
|
FMainHelpDB:=HelpDatabases.CreateHelpDatabase('Lazarus IDE',
|
||||||
|
THTMLHelpDatabase,true);
|
||||||
|
HTMLHelp:=FMainHelpDB as THTMLHelpDatabase;
|
||||||
|
HTMLHelp.BasePathObject:=Self;
|
||||||
|
// nodes
|
||||||
|
StartNode:=THelpNode.CreateURLID(HTMLHelp,'Lazarus',
|
||||||
|
'file://docs/index.html',lihcStartPage);
|
||||||
|
HTMLHelp.TOCNode:=THelpNode.Create(HTMLHelp,StartNode);
|
||||||
|
HTMLHelp.RegisterItemWithNode(StartNode);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure CreateFCLHelpDB;
|
||||||
|
var
|
||||||
|
HTMLHelp: TFPDocHTMLHelpDatabase;
|
||||||
|
StartNode: THelpNode;
|
||||||
|
FPDocNode: THelpNode;
|
||||||
|
DirItem: THelpDBSISourceDirectory;
|
||||||
|
begin
|
||||||
|
FFCLHelpDB:=HelpDatabases.CreateHelpDatabase('FCL',TFPDocHTMLHelpDatabase,
|
||||||
|
true);
|
||||||
|
HTMLHelp:=FFCLHelpDB as TFPDocHTMLHelpDatabase;
|
||||||
|
|
||||||
|
// FCL
|
||||||
|
StartNode:=THelpNode.CreateURLID(HTMLHelp,
|
||||||
|
'FCL - Free Pascal Component Library',
|
||||||
|
'http://www.freepascal.org/docs-html/fcl/index.html',
|
||||||
|
lihcFCLStartPage);
|
||||||
|
HTMLHelp.TOCNode:=THelpNode.Create(HTMLHelp,StartNode);
|
||||||
|
HTMLHelp.RegisterItemWithNode(StartNode);
|
||||||
|
|
||||||
|
// FPDoc: units in the FCL
|
||||||
|
FPDocNode:=THelpNode.CreateURL(HTMLHelp,
|
||||||
|
'FCL - Free Pascal Component Library Units',
|
||||||
|
'http://www.freepascal.org/docs-html/fcl/index.html');
|
||||||
|
DirItem:=THelpDBSISourceDirectory.Create(FPDocNode,'$(FPCSrcDir)/fcl',
|
||||||
|
'*.pp;*.pas',true);
|
||||||
|
HTMLHelp.RegisterItem(DirItem);
|
||||||
|
|
||||||
|
// FPDoc: some RTL units are documented in the FCL
|
||||||
|
DirItem:=THelpDBSISourceDirectory.Create(
|
||||||
|
THelpNode.Create(HTMLHelp,FPDocNode),
|
||||||
|
'$(FPCSrcDir)/rtl','classes.pp;',true);
|
||||||
|
HTMLHelp.RegisterItem(DirItem);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FMainHelpDB:=HelpDatabases.CreateHelpDatabase('Lazarus IDE',THTMLHelpDatabase,
|
CreateMainIDEHelpDB;
|
||||||
true);
|
CreateFCLHelpDB;
|
||||||
HTMLHelp:=FMainHelpDB as THTMLHelpDatabase;
|
|
||||||
HTMLHelp.BasePathObject:=Self;
|
|
||||||
// nodes
|
|
||||||
StartNode:=THelpNode.CreateURLID(HTMLHelp,'Lazarus',
|
|
||||||
'file://docs/index.html',lihcStartPage);
|
|
||||||
HTMLHelp.TOCNode:=THelpNode.Create(HTMLHelp,StartNode);
|
|
||||||
HTMLHelp.RegisterItemWithNode(StartNode);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THelpManager.RegisterDefaultIDEHelpViewers;
|
procedure THelpManager.RegisterDefaultIDEHelpViewers;
|
||||||
@ -519,7 +580,7 @@ begin
|
|||||||
|
|
||||||
// invoke help system
|
// invoke help system
|
||||||
debugln('THelpManager.ShowHelpForSourcePosition D PascalHelpContextLists.Count=',dbgs(PascalHelpContextLists.Count));
|
debugln('THelpManager.ShowHelpForSourcePosition D PascalHelpContextLists.Count=',dbgs(PascalHelpContextLists.Count));
|
||||||
Result:=ShowHelpForPascalContexts(PascalHelpContextLists,ErrMsg);
|
ShowHelpForPascalContexts(Filename,CodePos,PascalHelpContextLists,ErrMsg);
|
||||||
end else begin
|
end else begin
|
||||||
MainIDEInterface.DoJumpToCodeToolBossError;
|
MainIDEInterface.DoJumpToCodeToolBossError;
|
||||||
end;
|
end;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
This unit defines the classes TTransferMacro and TTransferMacroList. These
|
This unit defines the classes TTransferMacro and TTransferMacroList. These
|
||||||
classes stores and substitutes macros in strings. Transfer macros are an
|
classes store and substitute macros in strings. Transfer macros are an
|
||||||
easy way to transfer some ide variables to programs like the compiler,
|
easy way to transfer some ide variables to programs like the compiler,
|
||||||
the debugger and all the other tools.
|
the debugger and all the other tools.
|
||||||
Transfer macros have the form $(macro_name). It is also possible to define
|
Transfer macros have the form $(macro_name). It is also possible to define
|
||||||
@ -100,13 +100,13 @@ type
|
|||||||
procedure Add(NewMacro: TTransferMacro);
|
procedure Add(NewMacro: TTransferMacro);
|
||||||
function FindByName(const MacroName: string): TTransferMacro; virtual;
|
function FindByName(const MacroName: string): TTransferMacro; virtual;
|
||||||
function SubstituteStr(var s:string): boolean; virtual;
|
function SubstituteStr(var s:string): boolean; virtual;
|
||||||
|
function StrHasMacros(const s: string): boolean;
|
||||||
property OnSubstitution: TOnSubstitution
|
property OnSubstitution: TOnSubstitution
|
||||||
read fOnSubstitution write fOnSubstitution;
|
read fOnSubstitution write fOnSubstitution;
|
||||||
property MarkUnhandledMacros: boolean read FMarkUnhandledMacros
|
property MarkUnhandledMacros: boolean read FMarkUnhandledMacros
|
||||||
write SetMarkUnhandledMacros;
|
write SetMarkUnhandledMacros;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -374,6 +374,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTransferMacroList.StrHasMacros(const s: string): boolean;
|
||||||
|
// search for $( or $xxx(
|
||||||
|
var
|
||||||
|
p: Integer;
|
||||||
|
Len: Integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
p:=1;
|
||||||
|
Len:=length(s);
|
||||||
|
while (p<Len) do begin
|
||||||
|
if s[p]='$' then begin
|
||||||
|
inc(p);
|
||||||
|
if (p<Len) and (s[p]<>'$') then begin
|
||||||
|
// skip macro function name
|
||||||
|
while (p<Len) and (s[p]<>'(') do inc(p);
|
||||||
|
if (p<Len) then begin
|
||||||
|
Result:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// $$ is not a macro
|
||||||
|
inc(p);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
inc(p);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TTransferMacroList.FindByName(const MacroName: string): TTransferMacro;
|
function TTransferMacroList.FindByName(const MacroName: string): TTransferMacro;
|
||||||
var
|
var
|
||||||
l: Integer;
|
l: Integer;
|
||||||
|
@ -22,16 +22,75 @@ unit HelpFPDoc;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, HelpIntf;
|
Classes, SysUtils, LCLProc, FileCtrl, HelpIntf, HelpHTML;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TFPDocHelpDatabase }
|
{ TFPDocHTMLHelpDatabase }
|
||||||
|
|
||||||
TFPDocHelpDatabase = class(THelpDatabase)
|
TFPDocHTMLHelpDatabase = class(THTMLHelpDatabase)
|
||||||
|
public
|
||||||
|
function ShowHelp(Query: THelpQuery; BaseNode, NewNode: THelpNode;
|
||||||
|
var ErrMsg: string): TShowHelpResult; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{ TFPDocHTMLHelpDatabase }
|
||||||
|
|
||||||
|
function TFPDocHTMLHelpDatabase.ShowHelp(Query: THelpQuery; BaseNode,
|
||||||
|
NewNode: THelpNode; var ErrMsg: string): TShowHelpResult;
|
||||||
|
var
|
||||||
|
ContextList: TPascalHelpContextList;
|
||||||
|
UnitName: String;
|
||||||
|
URL: String;
|
||||||
|
TheBaseURL: String;
|
||||||
|
Filename: String;
|
||||||
|
begin
|
||||||
|
if (Query is THelpQueryPascalContexts)
|
||||||
|
and (NewNode.QueryItem is TPascalHelpContextList) then begin
|
||||||
|
// a pascal context query
|
||||||
|
ContextList:=TPascalHelpContextList(NewNode.QueryItem);
|
||||||
|
if (ContextList.Count>0) and (ContextList.List[0].Descriptor=pihcFilename)
|
||||||
|
then begin
|
||||||
|
// extract unit filename
|
||||||
|
UnitName:=lowercase(ExtractFileNameOnly(ContextList.List[0].Context));
|
||||||
|
DebugLn('TFPDocHTMLHelpDatabase.ShowHelp A Unitname=',Unitname,' NewNode.HelpType=',dbgs(ord(NewNode.HelpType)),' NewNode.Title=',NewNode.Title,' NewNode.URL=',NewNode.URL);
|
||||||
|
if UnitName<>'' then begin
|
||||||
|
|
||||||
|
Filename:=UnitName+'/';
|
||||||
|
// TODO: context in unit
|
||||||
|
Filename:=Filename+'index.html';
|
||||||
|
|
||||||
|
TheBaseURL:='';
|
||||||
|
if NewNode.URLValid then begin
|
||||||
|
// the node has an URL => use only the path
|
||||||
|
TheBaseURL:=NewNode.URL;
|
||||||
|
debugln('A TheBaseURL=',TheBaseURL);
|
||||||
|
if (HelpDatabases<>nil) then
|
||||||
|
HelpDatabases.SubstituteMacros(TheBaseURL);
|
||||||
|
debugln('B TheBaseURL=',TheBaseURL);
|
||||||
|
TheBaseURL:=ExtractURLDirectory(TheBaseURL);
|
||||||
|
debugln('C TheBaseURL=',TheBaseURL);
|
||||||
|
DebugLn('TFPDocHTMLHelpDatabase.ShowHelp Node Base URL TheBaseURL=',TheBaseURL);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if TheBaseURL='' then
|
||||||
|
TheBaseURL:=GetEffectiveBaseURL;
|
||||||
|
|
||||||
|
// show URL
|
||||||
|
if TheBaseURL<>'' then
|
||||||
|
URL:=TheBaseURL+Filename
|
||||||
|
else
|
||||||
|
URL:=FilenameToURL(Filename);
|
||||||
|
Result:=ShowURL(URL,NewNode.Title,ErrMsg);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// otherwise use default
|
||||||
|
Result:=inherited ShowHelp(Query, BaseNode, NewNode, ErrMsg);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ type
|
|||||||
procedure SetBaseURL(const AValue: string);
|
procedure SetBaseURL(const AValue: string);
|
||||||
public
|
public
|
||||||
constructor Create(TheID: THelpDatabaseID); override;
|
constructor Create(TheID: THelpDatabaseID); override;
|
||||||
function ShowHelp(BaseNode, NewNode: THelpNode;
|
function ShowURL(const URL, Title: string;
|
||||||
|
var ErrMsg: string): TShowHelpResult; virtual;
|
||||||
|
function ShowHelp(Query: THelpQuery; BaseNode, NewNode: THelpNode;
|
||||||
var ErrMsg: string): TShowHelpResult; override;
|
var ErrMsg: string): TShowHelpResult; override;
|
||||||
function GetEffectiveBaseURL: string;
|
function GetEffectiveBaseURL: string;
|
||||||
public
|
public
|
||||||
@ -80,54 +82,62 @@ begin
|
|||||||
AddSupportedMimeType('text/html');
|
AddSupportedMimeType('text/html');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function THTMLHelpDatabase.ShowHelp(BaseNode, NewNode: THelpNode;
|
function THTMLHelpDatabase.ShowURL(const URL, Title: string; var ErrMsg: string
|
||||||
var ErrMsg: string): TShowHelpResult;
|
): TShowHelpResult;
|
||||||
var
|
var
|
||||||
URLType, URLPath, URLParams: string;
|
URLType, URLPath, URLParams: string;
|
||||||
BaseURLType, BaseURLPath, BaseURLParams: string;
|
BaseURLType, BaseURLPath, BaseURLParams: string;
|
||||||
Viewer: THelpViewer;
|
Viewer: THelpViewer;
|
||||||
EffBaseURL: String;
|
EffBaseURL: String;
|
||||||
Node: THelpNode;
|
Node: THelpNode;
|
||||||
URL: String;
|
FullURL: String;
|
||||||
|
begin
|
||||||
|
DebugLn('THTMLHelpDatabase.ShowURL A URL="',URL,'" Title="',Title,'"');
|
||||||
|
|
||||||
|
// find HTML viewer
|
||||||
|
Result:=FindViewer('text/html',ErrMsg,Viewer);
|
||||||
|
if Result<>shrSuccess then exit;
|
||||||
|
|
||||||
|
// make URL absolute
|
||||||
|
SplitURL(URL,URLType,URLPath,URLParams);
|
||||||
|
debugln('THTMLHelpDatabase.ShowHelp A NewNode.URL=',URL,' URLType=',URLType,' URLPath=',URLPath,' URLParams=',URLParams);
|
||||||
|
|
||||||
|
if URLType='file' then begin
|
||||||
|
if not URLFilenameIsAbsolute(URLPath) then begin
|
||||||
|
EffBaseURL:=GetEffectiveBaseURL;
|
||||||
|
SplitURL(EffBaseURL,BaseURLType,BaseURLPath,BaseURLParams);
|
||||||
|
if (BaseURLType='file') and (BaseURLPath<>'') then
|
||||||
|
URLPath:=BaseURLPath+URLPath;
|
||||||
|
end;
|
||||||
|
if (not FileExists(URLPath)) then begin
|
||||||
|
Result:=shrContextNotFound;
|
||||||
|
ErrMsg:=Format(oisHelpTheHelpDatabaseWasUnableToFindFile, ['"', ID,
|
||||||
|
'"', '"', URLPath, '"']);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
FullURL:=CombineURL(URLType,URLPath,URLParams);
|
||||||
|
debugln('THTMLHelpDatabase.ShowHelp B URL=',URL,' URLType=',URLType,' URLPath=',URLPath,' URLParams=',URLParams);
|
||||||
|
|
||||||
|
// call viewer
|
||||||
|
Node:=nil;
|
||||||
|
try
|
||||||
|
Node:=THelpNode.CreateURL(Self,Title,FullURL);
|
||||||
|
Result:=Viewer.ShowNode(Node,ErrMsg);
|
||||||
|
finally
|
||||||
|
Node.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function THTMLHelpDatabase.ShowHelp(Query: THelpQuery;
|
||||||
|
BaseNode, NewNode: THelpNode; var ErrMsg: string): TShowHelpResult;
|
||||||
begin
|
begin
|
||||||
ErrMsg:='';
|
ErrMsg:='';
|
||||||
Result:=shrContextNotFound;
|
Result:=shrContextNotFound;
|
||||||
if NewNode.URLValid then begin
|
if NewNode.URLValid then begin
|
||||||
// find HTML viewer
|
Result:=ShowURL(NewNode.URL,NewNode.Title,ErrMsg);
|
||||||
Result:=FindViewer('text/html',ErrMsg,Viewer);
|
|
||||||
if Result<>shrSuccess then exit;
|
|
||||||
|
|
||||||
// make URL absolute
|
|
||||||
SplitURL(NewNode.URL,URLType,URLPath,URLParams);
|
|
||||||
//debugln('THTMLHelpDatabase.ShowHelp A NewNode.URL=',NewNode.URL,' URLType=',URLType,' URLPath=',URLPath,' URLParams=',URLParams);
|
|
||||||
|
|
||||||
if URLType='file' then begin
|
|
||||||
if not URLFilenameIsAbsolute(URLPath) then begin
|
|
||||||
EffBaseURL:=GetEffectiveBaseURL;
|
|
||||||
SplitURL(EffBaseURL,BaseURLType,BaseURLPath,BaseURLParams);
|
|
||||||
if (BaseURLType='file') and (BaseURLPath<>'') then
|
|
||||||
URLPath:=BaseURLPath+URLPath;
|
|
||||||
end;
|
|
||||||
if (not FileExists(URLPath)) then begin
|
|
||||||
Result:=shrContextNotFound;
|
|
||||||
ErrMsg:=Format(oisHelpTheHelpDatabaseWasUnableToFindFile, ['"', ID,
|
|
||||||
'"', '"', URLPath, '"']);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end else begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
URL:=CombineURL(URLType,URLPath,URLParams);
|
|
||||||
//debugln('THTMLHelpDatabase.ShowHelp B URL=',URL,' URLType=',URLType,' URLPath=',URLPath,' URLParams=',URLParams);
|
|
||||||
|
|
||||||
// call viewer
|
|
||||||
Node:=THelpNode.Create(Self,NewNode);
|
|
||||||
try
|
|
||||||
Node.URL:=URL;
|
|
||||||
Result:=Viewer.ShowNode(Node,ErrMsg);
|
|
||||||
finally
|
|
||||||
Node.Free;
|
|
||||||
end;
|
|
||||||
end else begin
|
end else begin
|
||||||
Result:=shrContextNotFound;
|
Result:=shrContextNotFound;
|
||||||
ErrMsg:='THTMLHelpDatabase.ShowHelp Node.URLValid=false';
|
ErrMsg:='THTMLHelpDatabase.ShowHelp Node.URLValid=false';
|
||||||
@ -137,9 +147,11 @@ end;
|
|||||||
function THTMLHelpDatabase.GetEffectiveBaseURL: string;
|
function THTMLHelpDatabase.GetEffectiveBaseURL: string;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if BaseURL<>'' then
|
if BaseURL<>'' then begin
|
||||||
Result:=BaseURL
|
Result:=BaseURL;
|
||||||
else if (BasePathObject<>nil) and (Databases<>nil) then
|
if (HelpDatabases<>nil) then
|
||||||
|
HelpDatabases.SubstituteMacros(Result);
|
||||||
|
end else if (BasePathObject<>nil) and (Databases<>nil) then
|
||||||
Result:=Databases.GetBaseURLForBasePathObject(BasePathObject);
|
Result:=Databases.GetBaseURLForBasePathObject(BasePathObject);
|
||||||
if (Result<>'') and (Result[length(Result)]<>'/') then
|
if (Result<>'') and (Result[length(Result)]<>'/') then
|
||||||
Result:=Result+'/';
|
Result:=Result+'/';
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -821,11 +821,100 @@ end;
|
|||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
||||||
|
|
||||||
|
Checks if 'Filename' fits to one of the mask in 'Masks'.
|
||||||
|
Note: It checks the whole Filename. So, for example /somewhere/unit1.pas does
|
||||||
|
not fit the mask 'unit*.pas', but it will fit '*.pas'.
|
||||||
|
|
||||||
|
Masks is delimited by semicolon.
|
||||||
|
Masks allows asterisk (*) for arbitrary text and question mark (?) for one
|
||||||
|
arbitrary character.
|
||||||
|
Examples:
|
||||||
|
'*.pas;*.pp;*.inc'
|
||||||
|
'*.tar.*'
|
||||||
|
'lazarus*.xpm'
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
||||||
|
var
|
||||||
|
TrimmedFile: String;
|
||||||
|
MasksLen: Integer;
|
||||||
|
MaskStartPos: Integer;
|
||||||
|
MaskEndPos: Integer;
|
||||||
|
MaskPos: LongInt;
|
||||||
|
FilePos: Integer;
|
||||||
|
FileLen: Integer;
|
||||||
|
MaskChar: Char;
|
||||||
begin
|
begin
|
||||||
// TODO
|
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
if (Filename='') or (Masks='') then exit;
|
||||||
|
TrimmedFile:=TrimFilename(Filename); // do not expand
|
||||||
|
// try each Mask
|
||||||
|
MasksLen:=length(Masks);
|
||||||
|
FileLen:=length(TrimmedFile);
|
||||||
|
MaskEndPos:=1;
|
||||||
|
repeat
|
||||||
|
|
||||||
|
// find next Mask
|
||||||
|
MaskStartPos:=MaskEndPos;
|
||||||
|
while (MaskStartPos<=MasksLen) and (Masks[MaskStartPos]=';') do
|
||||||
|
inc(MaskStartPos);
|
||||||
|
if MaskStartPos>MasksLen then exit; // no mask -> end
|
||||||
|
MaskEndPos:=MaskStartPos+1;
|
||||||
|
while (MaskEndPos<=MasksLen) and (Masks[MaskEndPos]<>';') do
|
||||||
|
inc(MaskEndPos);
|
||||||
|
|
||||||
|
// check if mask fits to filename
|
||||||
|
MaskPos:=MaskStartPos;
|
||||||
|
FilePos:=1;
|
||||||
|
while MaskPos<MaskEndPos do begin
|
||||||
|
MaskChar:=Masks[MaskPos];
|
||||||
|
case MaskChar of
|
||||||
|
|
||||||
|
'?': begin
|
||||||
|
// skip one character
|
||||||
|
inc(FilePos);
|
||||||
|
inc(MaskPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
'*': begin
|
||||||
|
// Anything. Will be handled by the 'else' part below
|
||||||
|
inc(MaskPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
else
|
||||||
|
{$IFDEF win32}
|
||||||
|
if UpperCaseTable[byte(MaskChar)]
|
||||||
|
=UpperCaseTable[byte(TrimmedFile[FilePos])] then
|
||||||
|
{$ELSE}
|
||||||
|
if MaskChar=TrimmedFile[FilePos] then
|
||||||
|
{$ENDIF}
|
||||||
|
begin
|
||||||
|
// character fits
|
||||||
|
inc(MaskPos);
|
||||||
|
inc(FilePos);
|
||||||
|
end else begin
|
||||||
|
//character does not fit
|
||||||
|
// -> go back to last astersik (*)
|
||||||
|
while (MaskPos>MaskStartPos) and (Masks[MaskPos-1]<>'*') do begin
|
||||||
|
dec(MaskPos);
|
||||||
|
dec(FilePos);
|
||||||
|
end;
|
||||||
|
if (MaskPos=MaskStartPos) then begin
|
||||||
|
// there was no asterisk (*) => the filename does not fit this mask
|
||||||
|
break;
|
||||||
|
end else begin
|
||||||
|
// there is an asterisk (*) => try the next position
|
||||||
|
inc(FilePos);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if (MaskPos=MaskEndPos) and (FilePos>FileLen) then begin
|
||||||
|
// found
|
||||||
|
Result:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -958,6 +1047,9 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.48 2004/08/23 15:05:09 mattias
|
||||||
|
implemented help jump to FPDoc html unit
|
||||||
|
|
||||||
Revision 1.47 2004/08/22 22:47:43 mattias
|
Revision 1.47 2004/08/22 22:47:43 mattias
|
||||||
implemented context help for source editor
|
implemented context help for source editor
|
||||||
|
|
||||||
|
@ -4283,7 +4283,7 @@ begin
|
|||||||
csPreviewFileDialog,
|
csPreviewFileDialog,
|
||||||
csColorDialog,
|
csColorDialog,
|
||||||
csFontDialog:
|
csFontDialog:
|
||||||
if GtkWidgetIsA(p,GTK_WINDOW_TYPE) then
|
if GtkWidgetIsA(p,gtk_window_get_type) then
|
||||||
gtk_window_set_title(pGtkWindow(p),PLabel);
|
gtk_window_set_title(pGtkWindow(p),PLabel);
|
||||||
|
|
||||||
csLabel:
|
csLabel:
|
||||||
@ -9268,6 +9268,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.531 2004/08/23 15:05:09 mattias
|
||||||
|
implemented help jump to FPDoc html unit
|
||||||
|
|
||||||
Revision 1.530 2004/08/19 18:50:53 mattias
|
Revision 1.530 2004/08/19 18:50:53 mattias
|
||||||
splitted IDE component owner hierachy to reduce notification time
|
splitted IDE component owner hierachy to reduce notification time
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user