fpmhelp.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. {
  2. $Id$
  3. This file is part of the ffff
  4. Copyright (c) 1998 by Berczi Gabor
  5. Help menu entries
  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. procedure TIDEApp.HelpContents;
  13. begin
  14. HelpTopic('Help_Contents'{0,hcContents,false});
  15. end;
  16. procedure TIDEApp.HelpHelpIndex;
  17. begin
  18. HelpIndex('');
  19. end;
  20. procedure TIDEApp.HelpTopicSearch;
  21. begin
  22. end;
  23. procedure TIDEApp.HelpPrevTopic;
  24. begin
  25. if HelpWindow=nil then HelpContents else
  26. with HelpWindow^ do
  27. if GetState(sfVisible) then Message(HelpWindow^.HelpView,evCommand,cmPrevTopic,nil)
  28. else begin HelpWindow^.Show; HelpWindow^.MakeFirst; end;
  29. end;
  30. procedure TIDEApp.HelpUsingHelp;
  31. begin
  32. Help(0,hcUsingHelp,false);
  33. end;
  34. type
  35. PHelpFileListBox = ^THelpFileListBox;
  36. THelpFileListBox = object(TListBox)
  37. function GetText(Item: sw_Integer; MaxLen: sw_Integer): String; virtual;
  38. end;
  39. PHelpFilesDialog = ^THelpFilesDialog;
  40. THelpFilesDialog = object(TCenterDialog)
  41. constructor Init;
  42. procedure HandleEvent(var Event: TEvent); virtual;
  43. destructor Done; virtual;
  44. private
  45. LB: PHelpFileListBox;
  46. C : PUnsortedStringCollection;
  47. end;
  48. function THelpFileListBox.GetText(Item: sw_Integer; MaxLen: sw_Integer): String;
  49. var S: string;
  50. P: integer;
  51. begin
  52. S:=inherited GetText(Item,MaxLen);
  53. P:=Pos('|',S);
  54. if P>0 then S:=copy(S,P+1,255)+' - '+copy(S,1,P-1);
  55. GetText:=copy(S,1,MaxLen);
  56. end;
  57. constructor THelpFilesDialog.Init;
  58. var R,R2: TRect;
  59. SB: PScrollBar;
  60. I: integer;
  61. begin
  62. R.Assign(0,0,round(ScreenWidth*5/8),ScreenHeight-10);
  63. inherited Init(R, dialog_helpfiles);
  64. New(C, Init(20,10));
  65. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=R.B.X-13;
  66. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  67. New(SB, Init(R2)); Insert(SB);
  68. New(LB, Init(R, 1, SB));
  69. for I:=0 to HelpFiles^.Count-1 do
  70. begin
  71. C^.Insert(NewStr(HelpFiles^.At(I)^));
  72. end;
  73. LB^.NewList(C);
  74. Insert(LB);
  75. R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
  76. Insert(New(PLabel, Init(R2, label_helpfiles_helpfiles, LB)));
  77. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=R.B.X-13+1; R.B.Y:=R.A.Y+2;
  78. Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
  79. R.Move(0,2);
  80. Insert(New(PButton, Init(R, button_New, cmAddItem, bfNormal)));
  81. R.Move(0,2);
  82. Insert(New(PButton, Init(R, button_Delete, cmDeleteItem, bfNormal)));
  83. R.Move(0,2);
  84. Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
  85. LB^.Select;
  86. end;
  87. procedure THelpFilesDialog.HandleEvent(var Event: TEvent);
  88. var I: integer;
  89. D: PFileDialog;
  90. FileName: string;
  91. Re: word;
  92. S: string;
  93. LS: PFPHTMLFileLinkScanner;
  94. BS: PBufStream;
  95. { Version: word;}
  96. begin
  97. case Event.What of
  98. evKeyDown :
  99. case Event.KeyCode of
  100. kbIns :
  101. begin
  102. Message(@Self,evCommand,cmAddItem,nil);
  103. ClearEvent(Event);
  104. end;
  105. kbDel :
  106. begin
  107. Message(@Self,evCommand,cmDeleteItem,nil);
  108. ClearEvent(Event);
  109. end;
  110. end;
  111. evCommand :
  112. case Event.Command of
  113. cmAddItem :
  114. begin
  115. S:='';
  116. New(D, Init(HelpFileExts,
  117. dialog_installhelpfile,
  118. label_installhelpfile_filename,
  119. fdOpenButton,0));
  120. Re:=Desktop^.ExecView(D);
  121. if Re<>cmCancel then
  122. begin
  123. D^.GetFileName(FileName);
  124. if UpcaseStr(ExtOf(FileName))=UpcaseStr(HTMLIndexExt) then
  125. begin
  126. S:='HTML Index';
  127. end
  128. else
  129. if UpcaseStr(copy(ExtOf(FileName),1,length(HTMLExt)))=UpcaseStr(HTMLExt) then
  130. begin
  131. Re:=ConfirmBox(msg_createkeywordindexforhelpfile,nil,true);
  132. if Re<>cmCancel then
  133. if Re=cmNo then
  134. Re:=InputBox(dialog_topictitle,label_topictitle_title,S,40)
  135. else
  136. begin
  137. ShowMessage(msg_pleasewaitwhilecreatingindex);
  138. S:='HTML Index';
  139. PushStatus(FormatStrStr(msg_buildingindexfile,FileName));
  140. New(LS, Init);
  141. LS^.ProcessDocument(FileName,[soSubDocsOnly]);
  142. if LS^.GetDocumentCount=0 then
  143. begin
  144. ErrorBox(FormatStrStr(msg_filedoesnotcontainanylinks,FileName),nil);
  145. Re:=cmCancel;
  146. end
  147. else
  148. begin
  149. FileName:=DirAndNameOf(FileName)+HTMLIndexExt;
  150. if ExistsFile(FileName) then
  151. if ConfirmBox(FormatStrStr(msg_filealreadyexistsoverwrite,FileName),nil,true)<>cmYes then
  152. Re:=cmCancel;
  153. if Re<>cmCancel then
  154. begin
  155. PushStatus(FormatStrStr(msg_storinghtmlindexinfile,FileName));
  156. New(BS, Init(FileName, stCreate, 4096));
  157. if Assigned(BS)=false then
  158. begin
  159. ErrorBox(FormatStrStr(msg_cantcreatefile,FileName),nil);
  160. Re:=cmCancel;
  161. end
  162. else
  163. begin
  164. { Version:=HTMLIndexVersion;
  165. BS^.Write(Version,sizeof(Version));}
  166. LS^.StoreDocuments(BS^);
  167. if BS^.Status<>stOK then
  168. begin
  169. ErrorBox(FormatStrInt(msg_errorstoringindexdata,BS^.Status),nil);
  170. Re:=cmCancel;
  171. end;
  172. Dispose(BS, Done);
  173. end;
  174. PopStatus;
  175. end;
  176. end;
  177. Dispose(LS, Done);
  178. PopStatus;
  179. HideMessage;
  180. end;
  181. end;
  182. end;
  183. if Re<>cmCancel then
  184. begin
  185. if S<>'' then FileName:=FileName+'|'+S;
  186. LB^.List^.Insert(NewStr(FileName));
  187. LB^.SetRange(LB^.List^.Count);
  188. ReDraw;
  189. end;
  190. Dispose(D, Done);
  191. ClearEvent(Event);
  192. end;
  193. cmDeleteItem :
  194. if LB^.Range>0 then
  195. begin
  196. LB^.List^.AtFree(LB^.Focused);
  197. LB^.SetRange(LB^.List^.Count);
  198. ReDraw;
  199. ClearEvent(Event);
  200. end;
  201. cmOK :
  202. begin
  203. HelpFiles^.FreeAll;
  204. for I:=0 to LB^.List^.Count-1 do
  205. HelpFiles^.Insert(NewStr(C^.At(I)^));
  206. end;
  207. end;
  208. end;
  209. inherited HandleEvent(Event);
  210. end;
  211. destructor THelpFilesDialog.Done;
  212. begin
  213. if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
  214. inherited Done;
  215. end;
  216. procedure TIDEApp.HelpFiles;
  217. begin
  218. if Desktop^.ExecView(New(PHelpFilesDialog, Init))=cmOK then
  219. begin
  220. DoneHelpSystem;
  221. Message(Application,evBroadcast,cmHelpFilesChanged,nil);
  222. InitHelpSystem;
  223. end;
  224. end;
  225. procedure TIDEApp.About;
  226. begin
  227. ExecuteDialog(New(PFPAboutDialog, Init), nil);
  228. end;
  229. {
  230. $Log$
  231. Revision 1.11 2000-05-29 10:44:57 pierre
  232. + New bunch of Gabor's changes: see fixes.txt
  233. Revision 1.10 2000/05/02 08:42:28 pierre
  234. * new set of Gabor changes: see fixes.txt
  235. Revision 1.9 2000/04/25 08:42:33 pierre
  236. * New Gabor changes : see fixes.txt
  237. Revision 1.8 2000/02/07 08:29:13 michael
  238. [*] the fake (!) TOKENS.PAS still contained the typo bug
  239. FSplit(,n,d,e) (correctly FSplit(,d,n,e))
  240. [*] CodeComplete had a very ugly bug - coordinates were document-relative
  241. (instead of being screen-relative)
  242. [*] TResourceStream didn't count the size of the resource names when
  243. determining the file size and this could lead to the last resources not
  244. loaded correctly
  245. [+] Ctrl-Enter in editor now tries to open the file at cursor
  246. [+] CodeComplete option added to Options|Environment|Editor
  247. [+] user interface for managing CodeComplete implemented
  248. [+] user interface for CodeTemplates implemented
  249. [+] CodeComplete wordlist and CodeTemplates stored in desktop file
  250. [+] help topic size no longer limited to 64KB when compiled with FPC
  251. Revision 1.7 1999/05/22 13:44:31 peter
  252. * fixed couple of bugs
  253. Revision 1.6 1999/03/01 15:41:56 peter
  254. + Added dummy entries for functions not yet implemented
  255. * MenuBar didn't update itself automatically on command-set changes
  256. * Fixed Debugging/Profiling options dialog
  257. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  258. set
  259. * efBackSpaceUnindents works correctly
  260. + 'Messages' window implemented
  261. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  262. + Added TP message-filter support (for ex. you can call GREP thru
  263. GREP2MSG and view the result in the messages window - just like in TP)
  264. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  265. so topic search didn't work...
  266. * In FPHELP.PAS there were still context-variables defined as word instead
  267. of THelpCtx
  268. * StdStatusKeys() was missing from the statusdef for help windows
  269. + Topic-title for index-table can be specified when adding a HTML-files
  270. Revision 1.5 1999/02/22 02:15:16 peter
  271. + default extension for save in the editor
  272. + Separate Text to Find for the grep dialog
  273. * fixed redir crash with tp7
  274. Revision 1.4 1999/01/21 11:54:18 peter
  275. + tools menu
  276. + speedsearch in symbolbrowser
  277. * working run command
  278. Revision 1.3 1999/01/12 14:29:34 peter
  279. + Implemented still missing 'switch' entries in Options menu
  280. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  281. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  282. ASCII chars and inserted directly in the text.
  283. + Added symbol browser
  284. * splitted fp.pas to fpide.pas
  285. Revision 1.2 1998/12/28 15:47:48 peter
  286. + Added user screen support, display & window
  287. + Implemented Editor,Mouse Options dialog
  288. + Added location of .INI and .CFG file
  289. + Option (INI) file managment implemented (see bottom of Options Menu)
  290. + Switches updated
  291. + Run program
  292. Revision 1.2 1998/12/22 10:39:47 peter
  293. + options are now written/read
  294. + find and replace routines
  295. }