fphelp.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Help routines for the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit FPHelp;
  13. interface
  14. uses
  15. Drivers,HelpCtx,WHlpView,
  16. {$ifdef EDITORS}
  17. Editors,
  18. {$else}
  19. WEditor,
  20. {$endif}
  21. FPViews;
  22. type
  23. PIDEStatusLine = ^TIDEStatusLine;
  24. TIDEStatusLine = object(TAdvancedStatusLine)
  25. function Hint(AHelpCtx: Word): String; virtual;
  26. procedure HandleEvent(var Event: TEvent); virtual;
  27. end;
  28. procedure Help(FileID, Context: word; Modal: boolean);
  29. procedure HelpIndex(Keyword: string);
  30. procedure HelpTopicSearch(Editor: PEditor);
  31. procedure HelpTopic(S: string);
  32. procedure InitHelpSystem;
  33. procedure DoneHelpSystem;
  34. procedure InitHelpFiles;
  35. procedure DoneHelpFiles;
  36. procedure PushStatus(S: string);
  37. procedure SetStatus(S: string);
  38. procedure ClearStatus;
  39. procedure PopStatus;
  40. const
  41. HelpWindow : PIDEHelpWindow = nil;
  42. HelpInited : boolean = false;
  43. implementation
  44. uses Objects,Views,App,MsgBox,
  45. WHelp,
  46. FPConst,FPVars,FPUtils;
  47. var StatusStack : array[0..10] of string[MaxViewWidth];
  48. const
  49. StatusStackPtr : integer = 0;
  50. procedure TIDEStatusLine.HandleEvent(var Event: TEvent);
  51. begin
  52. case Event.What of
  53. evBroadcast :
  54. case Event.Command of
  55. cmUpdate : Update;
  56. end;
  57. end;
  58. inherited HandleEvent(Event);
  59. end;
  60. function TIDEStatusLine.Hint(AHelpCtx: Word): String;
  61. var S: string;
  62. begin
  63. case AHelpCtx of
  64. hcNoContext : S:='';
  65. hcSourceWindow : S:='';
  66. hcHelpWindow : S:='';
  67. hcCalcWindow : S:='';
  68. hcInfoWindow : S:='';
  69. hcClipboardWindow:S:='';
  70. hcSystemMenu : S:='System menu';
  71. hcUpdate : S:='Refresh and redraw display';
  72. hcAbout : S:='Show version and copyright information';
  73. hcFileMenu : S:='File managment commands (Open, New, Save, etc.)';
  74. hcNew : S:='Create a new file in a new edit window';
  75. hcNewFromTemplate:S:='Create a new file using a code template';
  76. hcOpen : S:='Locate and open a file in an edit window';
  77. hcSave : S:='Save the file in the active edit window';
  78. hcSaveAs : S:='Save the current file under a different name, directory or drive';
  79. hcSaveAll : S:='Save all modified files';
  80. hcChangeDir : S:='Choose a new default directory';
  81. hcDOSShell : S:='Temporarily exit to DOS';
  82. hcQuit : S:='Exit the IDE';
  83. hcRecentFileBase..hcRecentFileBase+10
  84. : S:='Open indicated file in a new editor window';
  85. hcEditMenu : S:='Clipboard editing commands';
  86. hcUndo : S:='Undo the previous editor operation';
  87. hcRedo : S:='Redo the previously undone editor operation';
  88. hcCut : S:='Remove the selected text and put it in the clipboard';
  89. hcCopy : S:='Copy the selected text in the clipboard';
  90. hcPaste : S:='Insert selected text from the clipboard at the cursor position';
  91. hcClear : S:='Delete the selected text';
  92. hcShowClipboard : S:='Open then clipboard window';
  93. hcSearchMenu : S:='Text and symbols search commands';
  94. hcFind : S:='Search for text';
  95. hcReplace : S:='Search for text and replace it with new text';
  96. hcSearchAgain : S:='Repeat the last Search or Replace command';
  97. hcGotoLine : S:='Move the cursor to a specified line number';
  98. hcObjects : S:='Open a browser displaying all objects in the program';
  99. hcModules : S:='Open a browser displaying all modules of the program';
  100. hcGlobals : S:='Open a browser displaying all global symbols in the program';
  101. hcRunMenu : S:='Execution and parameters';
  102. hcRun : S:='Run the current program';
  103. hcParameters : S:='Set command-line parameters passed to program at execution';
  104. hcUserScreen : S:='Switch to the full-screen user output';
  105. hcCompileMenu : S:='Compile, build & make';
  106. hcCompile : S:='Compile the current source file';
  107. hcMake : S:='Rebuild soruce file and all other files that have been modified';
  108. hcBuild : S:='Rebuild program and all available source files';
  109. hcTarget : S:='Select target platform to compile for';
  110. hcPrimaryFile : S:='Define then file that is the focus of Make and Build';
  111. hcClearPrimary : S:='Clear the file previously set to Primary';
  112. hcInformation : S:='Show compiler messages and program information';
  113. hcDebugMenu : S:='';
  114. hcToolsMenu : S:='User installed tools';
  115. hcCalculator : S:='Show calculator';
  116. hcToolsBase..
  117. hcToolsBase+MaxToolCount
  118. : S:='User installed tool';
  119. hcOptionsMenu : S:='Setting for compiler, editor, mouse, etc.';
  120. hcSwitchesMode : S:='Select settings for normal, debug or release version';
  121. hcCompiler : S:='Set default compiler directives and conditional defines';
  122. hcMemorySizes : S:='Set default stack and heap sizes for generated programs';
  123. hcLinker : S:='Set linker options';
  124. hcDebugger : S:='Set debug information options';
  125. hcDirectories : S:='Set paths for units, include, object and generated files';
  126. hcTools : S:='Create or change tools';
  127. hcEnvironmentMenu:S:='Specify environment settins';
  128. hcPreferences : S:='Specify desktop settings';
  129. hcEditor : S:='Specify default editor settings';
  130. hcMouse : S:='Specify mouse settings';
  131. hcStartup : S:='Permanently change default startup options';
  132. hcColors : S:='Customize IDE colors for windows, menus, editors, etc.';
  133. hcOpenINI : S:='Load a previously saved options file';
  134. hcSaveINI : S:='Save all the changes made in the options menu';
  135. hcSaveAsINI : S:='Save all the changes made under a different name';
  136. hcWindowMenu : S:='Windows managment commands';
  137. hcTile : S:='Arrange windows on desktop by tiling';
  138. hcCascade : S:='Arrange windows on desktop by cascading';
  139. hcCloseAll : S:='Close all windows on the desktop';
  140. hcResize : S:='Change the size/postion of the active window';
  141. hcZoom : S:='Enlarge or restore the size of the active window';
  142. hcNext : S:='Make the next window active';
  143. hcPrev : S:='Make the previous window active';
  144. hcClose : S:='Close the active window';
  145. hcWindowList : S:='Show a list of all open windows';
  146. hcUserScreenWindow:S:='Show contents of user screen in a window';
  147. hcHelpMenu : S:='Get online help';
  148. hcHelpContents : S:='Show table of contents for Online Help';
  149. hcHelpIndex : S:='Show index for Online Help';
  150. hcHelpTopicSearch:S:='Display help on the word at cursor';
  151. hcHelpPrevTopic : S:='Redisplay the last-viewed Online Help screen';
  152. hcHelpUsingHelp : S:='How to use Online Help';
  153. hcHelpFiles : S:='Install or remove installed help files';
  154. hcOpenAtCursor : S:='Attempt to open the file indicated by the word at cursor';
  155. hcBrowseAtCursor: S:='Attempt to browse the symbol at cursor';
  156. hcEditorOptions : S:='Specify editor settings';
  157. else S:='???';
  158. end;
  159. Hint:=S;
  160. end;
  161. procedure InitHelpSystem;
  162. procedure AddFile(HelpFile: string);
  163. begin
  164. {$IFDEF DEBUG}SetStatus(strLoadingHelp+' ('+SmartPath(HelpFile)+')');{$ENDIF}
  165. HelpFacility^.AddHelpFile(HelpFile);
  166. {$IFDEF DEBUG}SetStatus(strLoadingHelp);{$ENDIF}
  167. end;
  168. var I: integer;
  169. begin
  170. New(HelpFacility, Init);
  171. PushStatus(strLoadingHelp);
  172. for I:=0 to HelpFiles^.Count-1 do
  173. AddFile(HelpFiles^.At(I)^);
  174. PopStatus;
  175. end;
  176. procedure CheckHelpSystem;
  177. begin
  178. if HelpInited then Exit;
  179. InitHelpSystem;
  180. HelpInited:=true;
  181. end;
  182. procedure DoneHelpSystem;
  183. begin
  184. if HelpFacility<>nil then Dispose(HelpFacility, Done); HelpFacility:=nil;
  185. HelpInited:=false;
  186. end;
  187. procedure HelpCreateWindow;
  188. var R: TRect;
  189. begin
  190. CheckHelpSystem;
  191. if HelpWindow=nil then
  192. begin
  193. Desktop^.GetExtent(R); R.Grow(-15,-3); Dec(R.A.Y);
  194. New(HelpWindow, Init(R, 'Help', 0, 0, wnNoNumber));
  195. if HelpWindow<>nil then
  196. begin
  197. HelpWindow^.HelpCtx:=hcHelpWindow;
  198. HelpWindow^.HideOnClose:=true;
  199. HelpWindow^.Hide;
  200. Desktop^.Insert(HelpWindow);
  201. end;
  202. end;
  203. end;
  204. procedure Help(FileID, Context: word; Modal: boolean);
  205. begin
  206. if Modal then
  207. begin MessageBox('Sorry, modal help not yet implemented.',nil,mfInformation+mfInsertInApp+mfOKButton); Exit; end;
  208. HelpCreateWindow;
  209. with HelpWindow^ do
  210. begin
  211. HelpWindow^.ShowTopic(0,Context);
  212. if GetState(sfVisible)=false then Show;
  213. MakeFirst;
  214. end;
  215. Message(Application,evCommand,cmUpdate,nil);
  216. end;
  217. procedure HelpTopicSearch(Editor: PEditor);
  218. var S: string;
  219. begin
  220. if Editor=nil then S:='' else
  221. S:=GetEditorCurWord(Editor);
  222. HelpTopic(S);
  223. end;
  224. procedure HelpTopic(S: string);
  225. var FileID, Ctx: word;
  226. var Found: boolean;
  227. begin
  228. CheckHelpSystem;
  229. PushStatus(strLocatingTopic);
  230. Found:=HelpFacility^.TopicSearch(S,FileID,Ctx);
  231. PopStatus;
  232. if Found then
  233. Help(FileID,Ctx,false) else
  234. HelpIndex(S);
  235. end;
  236. procedure HelpIndex(Keyword: string);
  237. begin
  238. HelpCreateWindow;
  239. with HelpWindow^ do
  240. begin
  241. PushStatus(strBuildingHelpIndex);
  242. HelpWindow^.ShowIndex;
  243. if Keyword<>'' then
  244. HelpWindow^.HelpView^.Lookup(Keyword);
  245. PopStatus;
  246. if GetState(sfVisible)=false then Show;
  247. MakeFirst;
  248. end;
  249. Message(Application,evCommand,cmUpdate,nil);
  250. end;
  251. procedure PushStatus(S: string);
  252. begin
  253. if StatusLine=nil then Exit;
  254. StatusStack[StatusStackPtr]:=PAdvancedStatusLine(StatusLine)^.GetStatusText;
  255. SetStatus(S);
  256. Inc(StatusStackPtr);
  257. end;
  258. procedure PopStatus;
  259. begin
  260. if StatusLine=nil then Exit;
  261. Dec(StatusStackPtr);
  262. SetStatus(StatusStack[StatusStackPtr]);
  263. end;
  264. procedure SetStatus(S: string);
  265. begin
  266. if StatusLine=nil then Exit;
  267. PAdvancedStatusLine(StatusLine)^.SetStatusText(S);
  268. end;
  269. procedure ClearStatus;
  270. begin
  271. PAdvancedStatusLine(StatusLine)^.ClearStatusText;
  272. end;
  273. procedure InitHelpFiles;
  274. begin
  275. New(HelpFiles, Init(10,10));
  276. end;
  277. procedure DoneHelpFiles;
  278. begin
  279. if HelpFiles<>nil then Dispose(HelpFiles, Done);
  280. end;
  281. END.
  282. {
  283. $Log$
  284. Revision 1.4 1999-01-21 11:54:13 peter
  285. + tools menu
  286. + speedsearch in symbolbrowser
  287. * working run command
  288. Revision 1.3 1999/01/04 11:49:44 peter
  289. * 'Use tab characters' now works correctly
  290. + Syntax highlight now acts on File|Save As...
  291. + Added a new class to syntax highlight: 'hex numbers'.
  292. * There was something very wrong with the palette managment. Now fixed.
  293. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  294. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  295. process revised
  296. Revision 1.2 1998/12/28 15:47:44 peter
  297. + Added user screen support, display & window
  298. + Implemented Editor,Mouse Options dialog
  299. + Added location of .INI and .CFG file
  300. + Option (INI) file managment implemented (see bottom of Options Menu)
  301. + Switches updated
  302. + Run program
  303. Revision 1.3 1998/12/22 10:39:42 peter
  304. + options are now written/read
  305. + find and replace routines
  306. }