splitted helpintf into helpintf and idehelpintf

git-svn-id: trunk@9272 -
This commit is contained in:
mattias 2006-05-13 12:18:52 +00:00
parent 9c1a175b91
commit e58dd594be
8 changed files with 123 additions and 88 deletions

1
.gitattributes vendored
View File

@ -1301,6 +1301,7 @@ ideintf/helphtml.pas svneol=native#text/pascal
ideintf/helpintf.pas svneol=native#text/pascal ideintf/helpintf.pas svneol=native#text/pascal
ideintf/idecommands.pas svneol=native#text/pascal ideintf/idecommands.pas svneol=native#text/pascal
ideintf/idedialogs.pas svneol=native#text/plain ideintf/idedialogs.pas svneol=native#text/plain
ideintf/idehelpintf.pas svneol=native#text/plain
ideintf/idemsgintf.pas svneol=native#text/plain ideintf/idemsgintf.pas svneol=native#text/plain
ideintf/idewindowintf.pas svneol=native#text/plain ideintf/idewindowintf.pas svneol=native#text/plain
ideintf/imagelisteditor.lfm svneol=native#text/plain ideintf/imagelisteditor.lfm svneol=native#text/plain

View File

@ -38,7 +38,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, Dialogs, FileUtil, TextTools, MacroIntf, Classes, SysUtils, LCLProc, Dialogs, FileUtil, TextTools, MacroIntf,
LazarusIDEStrConsts, LazConfigStorage, HelpIntf, HelpHTML; LazarusIDEStrConsts, LazConfigStorage, IDEHelpIntf, HelpIntf, HelpHTML;
const const
lihcFPCMessages = 'FreePascal Compiler messages'; lihcFPCMessages = 'FreePascal Compiler messages';

View File

@ -39,7 +39,7 @@ uses
PascalParserTool, FindDeclarationTool, PascalParserTool, FindDeclarationTool,
PropEdits, ObjectInspector, FormEditingIntf, ProjectIntf, PropEdits, ObjectInspector, FormEditingIntf, ProjectIntf,
HelpIntf, HelpHTML, HelpFPDoc, MacroIntf, IDEWindowIntf, IDEMsgIntf, HelpIntf, HelpHTML, HelpFPDoc, MacroIntf, IDEWindowIntf, IDEMsgIntf,
LazIDEIntf, LazIDEIntf, IDEHelpIntf,
LazarusIDEStrConsts, TransferMacros, DialogProcs, IDEOptionDefs, LazarusIDEStrConsts, TransferMacros, DialogProcs, IDEOptionDefs,
ObjInspExt, EnvironmentOpts, AboutFrm, MsgView, Project, PackageDefs, MainBar, ObjInspExt, EnvironmentOpts, AboutFrm, MsgView, Project, PackageDefs, MainBar,
OutputFilter, HelpOptions, MainIntf, LazConf, HelpFPCMessages, OutputFilter, HelpOptions, MainIntf, LazConf, HelpFPCMessages,

View File

@ -44,7 +44,7 @@ uses
SynEdit, SynEdit,
CodeToolManager, CodeCache, CodeToolManager, CodeCache,
Laz_DOM, Laz_XMLRead, Laz_XMLWrite, Laz_DOM, Laz_XMLRead, Laz_XMLWrite,
HelpIntf, IDEHelpIntf, HelpIntf,
IDEProcs, LazarusIDEStrConsts; IDEProcs, LazarusIDEStrConsts;
const const

View File

@ -35,6 +35,7 @@ uses
HelpIntf, HelpIntf,
IDECommands, IDECommands,
IDEDialogs, IDEDialogs,
IDEHelpIntf,
IDEMsgIntf, IDEMsgIntf,
IDEWindowIntf, IDEWindowIntf,
ImageListEditor, ImageListEditor,

View File

@ -28,8 +28,22 @@ unit HelpIntf;
interface interface
uses uses
Classes, SysUtils, LCLProc, Controls, FileUtil, LazConfigStorage, MacroIntf, Classes, SysUtils, LCLProc, Controls, FileUtil, LazConfigStorage;
TextTools, ObjInspStrConsts;
resourcestring
rsHelpHelpNodeHasNoHelpDatabase = 'Help node %s%s%s has no Help Database';
rsHelpHelpDatabaseDidNotFoundAViewerForAHelpPageOfType = 'Help Database %s%'
+'s%s did not found a viewer for a help page of type %s';
rsHelpAlreadyRegistered = '%s: Already registered';
rsHelpNotRegistered = '%s: Not registered';
rsHelpHelpDatabaseNotFound = 'Help Database %s%s%s not found';
rsHelpHelpKeywordNotFoundInDatabase = 'Help keyword %s%s%s not found in '
+'Database %s%s%s.';
rsHelpHelpKeywordNotFound = 'Help keyword %s%s%s not found.';
rsHelpHelpContextNotFoundInDatabase = 'Help context %s not found in '
+'Database %s%s%s.';
rsHelpHelpContextNotFound = 'Help context %s not found.';
rsHelpNoHelpFoundForSource = 'No help found for line %d, column %d of %s.';
type type
// All help-specific error messages should be thrown as this type. // All help-specific error messages should be thrown as this type.
@ -284,29 +298,6 @@ type
end; end;
{ THelpDBIRegExprMessage
Help registration item for matching a message (e.g. a fpc warning) with
a regular expression.
For example a line like
"/usr/share/lazarus/components/synedit/syneditkeycmds.pp(532,10) Warning: Function result does not seem to be set"
could be matched with
Expression=') Warning: Function result does not seem to be set'
}
THelpDBIRegExprMessage = class(THelpDBIMessage)
private
FExpression: string;
FModifierStr: string;
public
constructor Create(TheNode: THelpNode; const RegularExpression,
TheModifierStr: string);
function MessageMatches(const TheMessage: string; MessageParts: TStrings
): boolean; override;
property Expression: string read FExpression write FExpression;
property ModifierStr: string read FModifierStr write FModifierStr;
end;
{ THelpQuery } { THelpQuery }
THelpQuery = class(TPersistent) THelpQuery = class(TPersistent)
@ -693,29 +684,9 @@ type
property BaseURL: string read FBaseURL write SetBaseURL; property BaseURL: string read FBaseURL write SetBaseURL;
end; end;
{ TBaseHelpManager }
TBaseHelpManager = class(TComponent)
public
procedure ConnectMainBarEvents; virtual; abstract;
procedure LoadHelpOptions; virtual; abstract;
procedure SaveHelpOptions; virtual; abstract;
function ShowHelpForSourcePosition(const Filename: string;
const CodePos: TPoint;
var ErrMsg: string): TShowHelpResult; virtual; abstract;
procedure ShowHelpForMessage(Line: integer); virtual; abstract;
procedure ShowHelpForObjectInspector(Sender: TObject); virtual; abstract;
function ConvertSourcePosToPascalHelpContext(const CaretPos: TPoint;
const Filename: string): TPascalHelpContextList; virtual; abstract;
end;
var var
HelpDatabases: THelpDatabases; // initialized by the IDE HelpDatabases: THelpDatabases; // initialized by the IDE
HelpViewers: THelpViewers; // initialized by the IDE HelpViewers: THelpViewers; // initialized by the IDE
LazarusHelp: TBaseHelpManager; // initialized by the IDE
//============================================================================== //==============================================================================
{ Showing help (how it works): { Showing help (how it works):
@ -1136,14 +1107,14 @@ end;
procedure THelpDatabase.RegisterSelf; procedure THelpDatabase.RegisterSelf;
begin begin
if Databases<>nil then if Databases<>nil then
raise EHelpSystemException.Create(Format(oisHelpAlreadyRegistered, [ID])); raise EHelpSystemException.Create(Format(rsHelpAlreadyRegistered, [ID]));
Databases:=HelpDatabases; Databases:=HelpDatabases;
end; end;
procedure THelpDatabase.UnregisterSelf; procedure THelpDatabase.UnregisterSelf;
begin begin
if Databases=nil then if Databases=nil then
raise EHelpSystemException.Create(Format(oisHelpNotRegistered, [ID])); raise EHelpSystemException.Create(Format(rsHelpNotRegistered, [ID]));
Databases:=nil; Databases:=nil;
end; end;
@ -1349,7 +1320,7 @@ begin
Viewers:=HelpViewers.GetViewersSupportingMimeType(MimeType); Viewers:=HelpViewers.GetViewersSupportingMimeType(MimeType);
try try
if (Viewers=nil) or (Viewers.Count=0) then begin if (Viewers=nil) or (Viewers.Count=0) then begin
ErrMsg:=Format(oisHelpHelpDatabaseDidNotFoundAViewerForAHelpPageOfType, [ ErrMsg:=Format(rsHelpHelpDatabaseDidNotFoundAViewerForAHelpPageOfType, [
'"', ID, '"', MimeType]); '"', ID, '"', MimeType]);
Result:=shrViewerNotFound; Result:=shrViewerNotFound;
end else begin end else begin
@ -1492,7 +1463,7 @@ begin
if HelpDB=nil then begin if HelpDB=nil then begin
Result:=false; Result:=false;
HelpResult:=shrDatabaseNotFound; HelpResult:=shrDatabaseNotFound;
ErrMsg:=Format(oisHelpHelpDatabaseNotFound, ['"', ID, '"']); ErrMsg:=Format(rsHelpHelpDatabaseNotFound, ['"', ID, '"']);
end else begin end else begin
HelpResult:=shrSuccess; HelpResult:=shrSuccess;
Result:=true; Result:=true;
@ -1618,7 +1589,7 @@ begin
// show node // show node
if NodeQuery.Node.Owner=nil then begin if NodeQuery.Node.Owner=nil then begin
Result:=shrDatabaseNotFound; Result:=shrDatabaseNotFound;
ErrMsg:=Format(oisHelpHelpNodeHasNoHelpDatabase, ['"', NodeQuery.Node.Title, '"']); ErrMsg:=Format(rsHelpHelpNodeHasNoHelpDatabase, ['"', NodeQuery.Node.Title, '"']);
exit; exit;
end; end;
Result:=NodeQuery.Node.Owner.ShowHelp(Query,nil, Result:=NodeQuery.Node.Owner.ShowHelp(Query,nil,
@ -1677,10 +1648,10 @@ begin
if (Nodes=nil) or (Nodes.Count=0) then begin if (Nodes=nil) or (Nodes.Count=0) then begin
Result:=shrContextNotFound; Result:=shrContextNotFound;
if Query.HelpDatabaseID<>'' then if Query.HelpDatabaseID<>'' then
ErrMsg:=Format(oisHelpHelpContextNotFoundInDatabase, [IntToStr( ErrMsg:=Format(rsHelpHelpContextNotFoundInDatabase, [IntToStr(
Query.Context), '"', Query.HelpDatabaseID, '"']) Query.Context), '"', Query.HelpDatabaseID, '"'])
else else
ErrMsg:=Format(oisHelpHelpContextNotFound, ErrMsg:=Format(rsHelpHelpContextNotFound,
[IntToStr(Query.Context)]); [IntToStr(Query.Context)]);
exit; exit;
end; end;
@ -1717,10 +1688,10 @@ begin
if (Nodes=nil) or (Nodes.Count=0) then begin if (Nodes=nil) or (Nodes.Count=0) then begin
Result:=shrContextNotFound; Result:=shrContextNotFound;
if Query.HelpDatabaseID<>'' then if Query.HelpDatabaseID<>'' then
ErrMsg:=Format(oisHelpHelpKeywordNotFoundInDatabase, ['"',Query.Keyword, ErrMsg:=Format(rsHelpHelpKeywordNotFoundInDatabase, ['"',Query.Keyword,
'"', '"', Query.HelpDatabaseID, '"']) '"', '"', Query.HelpDatabaseID, '"'])
else else
ErrMsg:=Format(oisHelpHelpKeywordNotFound, ['"',Query.Keyword,'"']); ErrMsg:=Format(rsHelpHelpKeywordNotFound, ['"',Query.Keyword,'"']);
exit; exit;
end; end;
@ -1749,7 +1720,7 @@ begin
// check if at least one node found // check if at least one node found
if (Nodes=nil) or (Nodes.Count=0) then begin if (Nodes=nil) or (Nodes.Count=0) then begin
Result:=shrHelpNotFound; Result:=shrHelpNotFound;
ErrMsg:=format(oisHelpNoHelpFoundForSource, ErrMsg:=format(rsHelpNoHelpFoundForSource,
[Query.SourcePosition.y, Query.SourcePosition.x, Query.Filename]); [Query.SourcePosition.y, Query.SourcePosition.x, Query.Filename]);
exit; exit;
end; end;
@ -2429,7 +2400,7 @@ var
begin begin
ExpFilename:=FFilename; ExpFilename:=FFilename;
if (HelpDatabases<>nil) then if (HelpDatabases<>nil) then
IDEMacros.SubstituteMacros(ExpFilename); HelpDatabases.SubstituteMacros(ExpFilename);
ExpFilename:=TrimFilename(ExpFilename); ExpFilename:=TrimFilename(ExpFilename);
if FilenameIsAbsolute(ExpFilename) then if FilenameIsAbsolute(ExpFilename) then
Result:=ExpFilename Result:=ExpFilename
@ -2578,22 +2549,6 @@ begin
BasePath:=TheBasePath; BasePath:=TheBasePath;
end; end;
{ THelpDBIRegExprMessage }
constructor THelpDBIRegExprMessage.Create(TheNode: THelpNode;
const RegularExpression, TheModifierStr: string);
begin
FNode:=TheNode;
FExpression:=RegularExpression;
FModifierStr:=TheModifierStr;
end;
function THelpDBIRegExprMessage.MessageMatches(const TheMessage: string;
MessageParts: TStrings): boolean;
begin
Result:=REMatches(TheMessage,Expression,ModifierStr);
end;
{ THelpNodeQuery } { THelpNodeQuery }
constructor THelpNodeQuery.Create; constructor THelpNodeQuery.Create;

91
ideintf/idehelpintf.pas Normal file
View File

@ -0,0 +1,91 @@
{ $Id: helpintf.pas 9271 2006-05-13 12:00:43Z mattias $ }
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
Author: Mattias Gaertner
Abstract:
This unit defines various base classes for the Help System used by the IDE.
}
unit IDEHelpIntf;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, HelpIntf, TextTools;
type
{ THelpDBIRegExprMessage
Help registration item for matching a message (e.g. a fpc warning) with
a regular expression.
For example a line like
"/usr/share/lazarus/components/synedit/syneditkeycmds.pp(532,10) Warning: Function result does not seem to be set"
could be matched with
Expression=') Warning: Function result does not seem to be set'
}
THelpDBIRegExprMessage = class(THelpDBIMessage)
private
FExpression: string;
FModifierStr: string;
public
constructor Create(TheNode: THelpNode; const RegularExpression,
TheModifierStr: string);
function MessageMatches(const TheMessage: string; MessageParts: TStrings
): boolean; override;
property Expression: string read FExpression write FExpression;
property ModifierStr: string read FModifierStr write FModifierStr;
end;
{ TBaseHelpManager }
TBaseHelpManager = class(TComponent)
public
procedure ConnectMainBarEvents; virtual; abstract;
procedure LoadHelpOptions; virtual; abstract;
procedure SaveHelpOptions; virtual; abstract;
function ShowHelpForSourcePosition(const Filename: string;
const CodePos: TPoint;
var ErrMsg: string): TShowHelpResult; virtual; abstract;
procedure ShowHelpForMessage(Line: integer); virtual; abstract;
procedure ShowHelpForObjectInspector(Sender: TObject); virtual; abstract;
function ConvertSourcePosToPascalHelpContext(const CaretPos: TPoint;
const Filename: string): TPascalHelpContextList; virtual; abstract;
end;
var
LazarusHelp: TBaseHelpManager; // initialized by the IDE
implementation
{ THelpDBIRegExprMessage }
constructor THelpDBIRegExprMessage.Create(TheNode: THelpNode;
const RegularExpression, TheModifierStr: string);
begin
Node:=TheNode;
FExpression:=RegularExpression;
FModifierStr:=TheModifierStr;
end;
function THelpDBIRegExprMessage.MessageMatches(const TheMessage: string;
MessageParts: TStrings): boolean;
begin
Result:=REMatches(TheMessage,Expression,ModifierStr);
end;
end.

View File

@ -278,19 +278,6 @@ resourcestring
oisNone = '(none)'; oisNone = '(none)';
oisComponentNameIsNotAValidIdentifier = 'Component name %s%s%s is not a ' oisComponentNameIsNotAValidIdentifier = 'Component name %s%s%s is not a '
+'valid identifier'; +'valid identifier';
oisHelpHelpNodeHasNoHelpDatabase = 'Help node %s%s%s has no Help Database';
oisHelpHelpDatabaseDidNotFoundAViewerForAHelpPageOfType = 'Help Database %s%'
+'s%s did not found a viewer for a help page of type %s';
oisHelpAlreadyRegistered = '%s: Already registered';
oisHelpNotRegistered = '%s: Not registered';
oisHelpHelpDatabaseNotFound = 'Help Database %s%s%s not found';
oisHelpHelpKeywordNotFoundInDatabase = 'Help keyword %s%s%s not found in '
+'Database %s%s%s.';
oisHelpHelpKeywordNotFound = 'Help keyword %s%s%s not found.';
oisHelpHelpContextNotFoundInDatabase = 'Help context %s not found in '
+'Database %s%s%s.';
oisHelpHelpContextNotFound = 'Help context %s not found.';
oisHelpNoHelpFoundForSource = 'No help found for line %d, column %d of %s.';
oisLoadImageDialog = 'Load Image Dialog'; oisLoadImageDialog = 'Load Image Dialog';
oisOK = '&OK'; oisOK = '&OK';
oisCancel = '&Cancel'; oisCancel = '&Cancel';