Sign in Join
Wiki copytemporary

Creating IDE Help: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# Overview
22
33The IDE can search help for various things and there are various sources in various help formats. Here is a short list to understand the complexity:
44
55- **FPC messages**: compiler message like *Error: Illegal enum minimum-size specifier*. The IDE has a default built-in to search for the *FPCSrcDir/compiler/msg/errore.msg file*, search the message there and show the corresponding comment. The comments contain Latex tags which are stripped. At the moment a simple MessageDlg is shown. Some notorious messages need more explanation and are manually connected to URLs.
66- **IDE windows, dialogs and controls**:
77- **Pascal sources**:
88- **FPC keywords**:
99- **FPC directives**:
1010- **IDE directives**:
1111
1212# Demos and explore
1313
1414You can see the currently installed help under **View / IDE Internals / About IDE / Help**.
1515
1616There is a test and demonstration package under **examples/idehelp/demoidehelp.lpk**. It contains example code how you can add help to the IDE.
1717
1818To show your help in the user's browser see examples/helphtml/htmlhelp1.lpi.
1919
2020To show HTML help in a LCL control see examples/htmlhelp_ipro/htmlhelpsample.lpi.
2121
2222## Help for LCL units
2323
2424Whenever the user presses F1 for an Object Inspector property or on an identifier in the source editor the IDE searches the declaration and invokes the HTML viewer for the fpdoc item. The items can be edited easily via the [[FPDoc Editor]] tool.
2525
2626You can see the state of the LCL documentation here: [[LCL Documentation Roadmap]].
2727
2828## Help for IDE windows
2929
3030This feature exists since 0.9.15.
3131
32-The help for the IDE windows (i.e. 'Object Inspector' or the 'Compiler Options') are documented in this wiki. The IDE has a mapping file *docs/IDEWindowHelpTree.xml*, which contains the paths from the various IDE forms/controls to wiki pages. This mapping file is edited via an editor that is shown at any place in the IDE via <span class="kbd">Ctrl</span>+<span class="kbd">Shift</span>+<span class="kbd">F1</span>, except for controls that catch all keys, like synedit. You can set the shortcut in the editor options -\> key mapping.
32+The help for the IDE windows (i.e. 'Object Inspector' or the 'Compiler Options') are documented in this wiki. The IDE has a mapping file *docs/IDEWindowHelpTree.xml*, which contains the paths from the various IDE forms/controls to wiki pages. This mapping file is edited via an editor that is shown at any place in the IDE via `Ctrl`+`Shift`+`F1`, except for controls that catch all keys, like synedit. You can set the shortcut in the editor options -\> key mapping.
3333
3434The root page of the IDE window docs is [[Lazarus IDE]].
3535
3636### Example
3737
3838- Open the project options: Project / Project Options
39-- Open the help editor: <span class="kbd">Shift</span>+<span class="kbd">Ctrl</span>+<span class="kbd">F1</span>
39+- Open the help editor: `Shift`+`Ctrl`+`F1`
4040
41-<figure>
42-<img src="HelpEditor1.png" title="HelpEditor1.png" />
43-<figcaption>HelpEditor1.png</figcaption>
44-</figure>
41+![](/wiki-images/d/d3/HelpEditor1.png)
4542
4643- To the left, you can see all controls of the project options dialog. You can see there are also the compiler options.
4744- Select the **ProjectApplicationOptionsFrame**
4845- Click **Create Help node**. This will create a new item on the right.
4946- Check **Has Help**
5047- Check **Is a root control**. All controls on the frame should use the help on our new help page.
5148- Change the path to **Project_Options**
5249
53-<figure>
54-<img src="HelpEditorProjectOptions.png" title="HelpEditorProjectOptions.png" />
55-<figcaption>HelpEditorProjectOptions.png</figcaption>
56-</figure>
50+![](/wiki-images/1/11/HelpEditorProjectOptions.png)
5751
5852- You can click the **Test** button and should see [[IDE Window: Project Options]] in your browser.
5953
6054### Redirect
6155
6256The TreeView in the IDE options dialog redirects the help to the help of the selected frame:
6357
6458ide/ideoptionsdlg.pas
6559
6660``` pascal
6761procedure TIDEOptionsDialog.CategoryTreeKeyDown(Sender: TObject; var Key: Word;
6862 Shift: TShiftState);
6963var
7064 Command: Word;
7165begin
7266 Command := EditorOpts.KeyMap.TranslateKey(Key,Shift,nil);
7367 if (Command=ecContextHelp) and (PrevEditor <> nil) then begin
7468 Key:=VK_UNKNOWN;
7569 ShowContextHelpForIDE(PrevEditor);
7670 end;
7771end;
7872```
7973
8074## Help for FPC keywords
8175
8276You can register a help for fpc keywords. Note: One database can handle multiple contexts, for example help for fpc keywords, help for sources and help for messages.
8377
8478``` pascal
8579uses
8680 IDEHelpIntfs, HelpIntfs, LazHelpIntf, LazHelpHTML...
8781
8882 { TSimpleFPCKeywordHelpDatabase }
8983
9084 TSimpleFPCKeywordHelpDatabase = class(THTMLHelpDatabase) // you can use any type of database you like
9185 private
9286 FKeywordPrefixNode: THelpNode;
9387 public
9488 function GetNodesForKeyword(const HelpKeyword: string;
9589 var ListOfNodes: THelpNodeQueryList; var ErrMsg: string
9690 ): TShowHelpResult; override;
9791 function ShowHelp(Query: THelpQuery; BaseNode, NewNode: THelpNode;
9892 QueryItem: THelpQueryItem;
9993 var ErrMsg: string): TShowHelpResult; override;
10094 end;
10195
10296function TSimpleFPCKeywordHelpDatabase.GetNodesForKeyword(
10397 const HelpKeyword: string; var ListOfNodes: THelpNodeQueryList;
10498 var ErrMsg: string): TShowHelpResult;
10599var
106100 KeyWord: String;
107101begin
108102 Result:=shrHelpNotFound;
109103 if (csDesigning in ComponentState) then exit;
110104 if (FPCKeyWordHelpPrefix<>'')
111105 and (LeftStr(HelpKeyword,length(FPCKeyWordHelpPrefix))=FPCKeyWordHelpPrefix) then begin
112106 // HelpKeyword starts with KeywordPrefix
113107 KeyWord:=copy(HelpKeyword,length(FPCKeyWordHelpPrefix)+1,length(HelpKeyword));
114108 // test: testfcpkeyword
115109 if KeyWord='testfcpkeyword' then begin
116110 // this help database knows this keyword
117111 // => add a node, so that if there are several possibilities the IDE can
118112 // show the user a dialog to choose
119113 // Note: In your own database you can create one dummy node or
120114 // one node per keyword or one node per group of keywords
121115 // or whatever you like.
122116 if FKeywordPrefixNode=nil then
123117 FKeywordPrefixNode:=THelpNode.CreateURL(Self,'','');
124118 FKeywordPrefixNode.Title:='Pascal keyword '+KeyWord;
125119 CreateNodeQueryListAndAdd(FKeywordPrefixNode,nil,ListOfNodes,true);
126120 Result:=shrSuccess;
127121 end;
128122 end;
129123end;
130124
131125function TSimpleFPCKeywordHelpDatabase.ShowHelp(Query: THelpQuery; BaseNode,
132126 NewNode: THelpNode; QueryItem: THelpQueryItem; var ErrMsg: string
133127 ): TShowHelpResult;
134128var
135129 KeywordQuery: THelpQueryKeyword;
136130 KeyWord: String;
137131begin
138132 Result:=shrHelpNotFound;
139133 if not (Query is THelpQueryKeyword) then exit;
140134 KeywordQuery:=THelpQueryKeyword(Query);
141135 KeyWord:=copy(KeywordQuery.Keyword,length(FPCKeyWordHelpPrefix)+1,length(KeywordQuery.Keyword));
142136 debugln(['TSimpleFPCKeywordHelpDatabase.ShowHelp Keyword=',Keyword]);
143137 // ShowURL ...
144138end;
145139
146140procedure Register;
147141begin
148142 FPCKeywordsHelpDB:=HelpDatabases.CreateHelpDatabase('NameYourHelpDB',
149143 TSimpleFPCKeywordHelpDatabase,true);
150144end;
151145```
152146
153147## Help for Messages
154148
155149This feature exists since 0.9.15 and requires the FPC sources installed locally.
156150
157151This is invoked when the user presses F1 or uses the Help menu item of the message window.
158152
159153Normally the IDE will search the errore.msg file in the FPC sources and show the comment for the message. But some messages like *unit not found* need extra help. The following describes how to do that:
160154
161155To add a wiki help page for a message, do the following:
162156
163157- Create a wiki page under [[Build messages]]
164158- Right click on messages window / Edit help
165159- This shows the editor for message additions.
166160
167-<figure>
168-<img src="AdditionalHelpForMessages.png" title="AdditionalHelpForMessages.png" />
169-<figcaption>AdditionalHelpForMessages.png</figcaption>
170-</figure>
161+![](/wiki-images/6/69/AdditionalHelpForMessages.png)
171162
172163The items are stored in **\<lazarusdir\>/docs/additionalmsghelp.xml**.
173164
174165## Adding Kylix help
175166
176167For wow to use the Borland Help files within the IDE editor, see [[Installing Help in the IDE|Adding Kylix Help]].
177168
178169---
179170*From the Free Pascal wiki, page "Creating IDE Help", as it stood on 2020-08-22 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
180171Category: Help and Docs
181172Category: IDE
182173Category: Lazarus

Back to history