fpmhelp.inc 11 KB

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