fpmfile.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. File 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.NewEditor;
  13. begin
  14. OpenEditorWindow(nil,'',0,0);
  15. end;
  16. procedure TIDEApp.NewFromTemplate;
  17. var D: PCenterDialog;
  18. R,R2: TRect;
  19. SB: PScrollBar;
  20. LB: PAdvancedListBox;
  21. I: integer;
  22. C: PUnsortedStringCollection;
  23. TE: PSourceWindow;
  24. begin
  25. if GetTemplateCount=0 then
  26. begin InformationBox('No templates available.',nil); Exit; end;
  27. New(C, Init(10,10));
  28. R.Assign(0,0,40,14);
  29. New(D, Init(R, 'New from template'));
  30. with D^ do
  31. begin
  32. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); Dec(R.B.X,12);
  33. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  34. New(SB, Init(R2)); Insert(SB);
  35. New(LB, Init(R,1,SB));
  36. LB^.Default:=true;
  37. for I:=0 to GetTemplateCount-1 do
  38. C^.Insert(NewStr(GetTemplateName(I)));
  39. LB^.NewList(C);
  40. Insert(LB);
  41. Dec(R.A.Y); R.B.Y:=R.A.Y+1;
  42. Insert(New(PLabel, Init(R, 'Available ~t~emplates', LB)));
  43. GetExtent(R2); R2.Grow(-2,-3); R2.A.X:=R.B.X+2; R2.B.Y:=R2.A.Y+2;
  44. Insert(New(PButton, Init(R2, 'O~K~', cmOK, bfDefault)));
  45. R2.Move(0,2);
  46. Insert(New(PButton, Init(R2, 'Cancel', cmCancel, bfNormal)));
  47. end;
  48. LB^.Select;
  49. if Desktop^.ExecView(D)=cmOK then
  50. begin
  51. Desktop^.Lock;
  52. TE:=OpenEditorWindow(nil,'',0,0);
  53. if TE<>nil then
  54. begin
  55. StartTemplate(LB^.Focused,TE^.Editor);
  56. TE^.Editor^.Modified:=false; { if nothing changes, we don't need to save it }
  57. TE^.Hide; { we need this trick to get the editor updated }
  58. TE^.Show;
  59. end;
  60. Desktop^.UnLock;
  61. end;
  62. Dispose(D, Done);
  63. Dispose(C, Done);
  64. end;
  65. procedure TIDEApp.Open(FileName: string);
  66. var D: PFileDialog;
  67. OpenIt: boolean;
  68. begin
  69. OpenIt:=FileName<>'';
  70. if not OpenIt then
  71. begin
  72. New(D, Init(OpenFileLastExt,'Open a file','File to open',fdOpenButton,0));
  73. OpenIt:=Desktop^.ExecView(D)<>cmCancel;
  74. if OpenIt then
  75. Begin
  76. D^.GetFileName(FileName);
  77. OpenFileLastExt:=D^.WildCard;
  78. End;
  79. Dispose(D, Done);
  80. end;
  81. if OpenIt then
  82. begin
  83. FileName:=FExpand(LocatePasFile(FileName));
  84. OpenEditorWindow(nil,FileName,0,0);
  85. end;
  86. end;
  87. function TIDEApp.OpenSearch(FileName: string) : boolean;
  88. var D: PFileDialog;
  89. OpenIt: boolean;
  90. P : PString;
  91. Dir : String;
  92. begin
  93. OpenIt:=False;
  94. if not OpenIt then
  95. begin
  96. New(D, Init(FileName+'*','Open a file','Looking for '+FileName,fdOpenButton,0));
  97. OpenIt:=Desktop^.ExecView(D)<>cmCancel;
  98. if OpenIt then
  99. Begin
  100. D^.GetFileName(FileName);
  101. End;
  102. Dispose(D, Done);
  103. end;
  104. if OpenIt then
  105. begin
  106. FileName:=FExpand(LocatePasFile(FileName));
  107. Dir:=DirOf(FileName);
  108. P:=@Dir;
  109. If Pos(Dir+';',GetSourceDirectories)=0 then
  110. if ConfirmBox(#3'Directory %s is not in list'#13#3+
  111. 'Should we add it ?',@P,false)=cmYes then
  112. SourceDirs:=SourceDirs+';'+Dir;
  113. OpenEditorWindow(nil,FileName,0,0);
  114. end;
  115. OpenSearch:=OpenIt;
  116. end;
  117. procedure TIDEApp.OpenRecentFile(RecentIndex: integer);
  118. begin
  119. with RecentFiles[RecentIndex] do
  120. if OpenEditorWindow(nil,FileName,LastPos.X,LastPos.Y)<>nil then
  121. RemoveRecentFile(RecentIndex);
  122. end;
  123. procedure TIDEApp.SaveAll;
  124. procedure SendSave(P: PView); {$ifndef FPC}far;{$endif}
  125. begin
  126. Message(P,evCommand,cmSave,nil);
  127. end;
  128. begin
  129. Desktop^.ForEach(@SendSave);
  130. end;
  131. procedure TIDEApp.ChangeDir;
  132. begin
  133. ExecuteDialog(New(PChDirDialog, Init(cdNormal, hisChDirDialog)),nil);
  134. CurDirChanged;
  135. end;
  136. {
  137. $Log$
  138. Revision 1.8 1999-02-05 12:11:57 pierre
  139. + SourceDir that stores directories for sources that the
  140. compiler should not know about
  141. Automatically asked for addition when a new file that
  142. needed filedialog to be found is in an unknown directory
  143. Stored and retrieved from INIFile
  144. + Breakpoints conditions added to INIFile
  145. * Breakpoints insterted and removed at debin and end of debug session
  146. Revision 1.7 1999/02/04 13:32:05 pierre
  147. * Several things added (I cannot commit them independently !)
  148. + added TBreakpoint and TBreakpointCollection
  149. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  150. + Breakpoint list in INIFile
  151. * Select items now also depend of SwitchMode
  152. * Reading of option '-g' was not possible !
  153. + added search for -Fu args pathes in TryToOpen
  154. + added code for automatic opening of FileDialog
  155. if source not found
  156. Revision 1.6 1999/02/02 16:41:41 peter
  157. + automatic .pas/.pp adding by opening of file
  158. * better debuggerscreen changes
  159. Revision 1.5 1999/01/21 11:54:17 peter
  160. + tools menu
  161. + speedsearch in symbolbrowser
  162. * working run command
  163. Revision 1.4 1999/01/14 21:42:21 peter
  164. * source tracking from Gabor
  165. Revision 1.3 1999/01/04 11:49:46 peter
  166. * 'Use tab characters' now works correctly
  167. + Syntax highlight now acts on File|Save As...
  168. + Added a new class to syntax highlight: 'hex numbers'.
  169. * There was something very wrong with the palette managment. Now fixed.
  170. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  171. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  172. process revised
  173. Revision 1.2 1998/12/28 15:47:47 peter
  174. + Added user screen support, display & window
  175. + Implemented Editor,Mouse Options dialog
  176. + Added location of .INI and .CFG file
  177. + Option (INI) file managment implemented (see bottom of Options Menu)
  178. + Switches updated
  179. + Run program
  180. Revision 1.4 1998/12/24 08:27:12 gabor
  181. + displaying 'opening source file...' text while reading
  182. Revision 1.3 1998/12/22 10:39:46 peter
  183. + options are now written/read
  184. + find and replace routines
  185. }