fpmtools.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Tools 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.Calculator;
  13. begin
  14. with CalcWindow^ do
  15. begin
  16. if GetState(sfVisible)=false then Show;
  17. MakeFirst;
  18. end;
  19. end;
  20. procedure TIDEApp.ExecuteTool(Idx: integer);
  21. var Title,ProgramPath,Params: string;
  22. W: word;
  23. Err: integer;
  24. begin
  25. if (Idx<1) or (Idx>GetToolCount) then Exit;
  26. GetToolParams(Idx-1,Title,ProgramPath,Params,W);
  27. Err:=ParseToolParams(Params,false);
  28. if Err=-1 then Exit;
  29. if Err<>0 then
  30. begin ErrorBox(^C'Error parsing tool params.',nil); Exit; end;
  31. DoExecute(ProgramPath,Params,false);
  32. if (DosError<>0) then
  33. ErrorBox('Error executing tool '+KillTilde(GetToolName(Idx-1)),nil) else
  34. if DosExitCode<>0 then
  35. ErrorBox('Execution successful. Exit code '+IntToStr(DosExitCode),nil);
  36. end;
  37. procedure TIDEApp.Grep;
  38. var PGrepDialog : PCenterDialog;
  39. R,R2 : TRect;
  40. IL : PInputLine;
  41. p,lineNb : longint;
  42. error : word;
  43. GrepExe,GrepArgs,Line,ModuleName : String;
  44. GrepOut : text;
  45. Params : Array[0..4] of longint;
  46. Const GrepOutName = 'grep$$.out';
  47. {$ifdef linux}
  48. GrepExeName = 'grep';
  49. {$else linux}
  50. GrepExeName = 'grep.exe';
  51. {$endif linux}
  52. begin
  53. GrepExe:=GrepExeName;
  54. If not LocateExeFile(GrepExe) then
  55. Begin
  56. ErrorBox('Grep program not found',nil);
  57. Exit;
  58. End;
  59. R.Assign(0,0,45,6);
  60. new(PGrepDialog,Init(R,'Grep arguments'));
  61. with PGrepDialog^ do
  62. begin
  63. R2.A.Y:=R.A.Y+3;
  64. R2.B.Y:=R2.A.Y+1;
  65. R2.A.X:=R.A.X+3;
  66. R2.B.X:=R.B.X-3;
  67. New(IL, Init(R2, 128));
  68. If not(DeskTop^.First=nil) and
  69. (DeskTop^.First^.HelpCtx=hcSourceWindow) then
  70. GrepArgs:=PSourceWindow(DeskTop^.First)^.Editor^.GetCurrentWord
  71. else
  72. GrepArgs:='';
  73. GrepArgs:='-n -i '+GrepArgs+' *.pas *.pp *.inc';
  74. IL^.Data^:=GrepArgs;
  75. Insert(IL);
  76. R2.Move(0,-1);
  77. Insert(New(PLabel, Init(R2, '~G~rep arguments', IL)));
  78. end;
  79. InsertButtons(PGrepDialog);
  80. if Desktop^.ExecView(PGrepDialog)=cmOK then
  81. begin
  82. GrepArgs:=IL^.Data^;
  83. { Linux ? }
  84. if not ExecuteRedir(GrepExe,GrepArgs,GrepOutName,'grep$$.err') then
  85. Begin
  86. { 2 as exit code just means that
  87. some file vwere not found ! }
  88. if (IOStatus<>0) or (ExecuteResult<>2) then
  89. begin
  90. Params[0]:=IOStatus;
  91. Params[1]:=ExecuteResult;
  92. WarningBox(#3'Error running Grep'#13#3'DosError = %d'#13#3'Exit code = %d',@Params);
  93. end;
  94. End;
  95. Assign(GrepOut,GrepOutName);
  96. Reset(GrepOut);
  97. While not eof(GrepOut) do
  98. begin
  99. readln(GrepOut,Line);
  100. p:=pos(':',line);
  101. if p>0 then
  102. begin
  103. ModuleName:=copy(Line,1,p-1);
  104. Line:=Copy(Line,p+1,255);
  105. p:=pos(':',Line);
  106. val(copy(Line,1,p-1),lineNb,error);
  107. if error=0 then
  108. ProgramInfoWindow^.AddMessage(V_Normal,Copy(Line,p+1,255),
  109. ModuleName,LineNb);
  110. end;
  111. ProgramInfoWindow^.Show;
  112. ProgramInfoWindow^.MakeFirst;
  113. end;
  114. end;
  115. Close(GrepOut);
  116. Dispose(PGrepDialog, Done);
  117. end;
  118. {
  119. $Log$
  120. Revision 1.6 1999-02-05 13:51:42 peter
  121. * unit name of FPSwitches -> FPSwitch which is easier to use
  122. * some fixes for tp7 compiling
  123. Revision 1.5 1999/02/05 12:11:59 pierre
  124. + SourceDir that stores directories for sources that the
  125. compiler should not know about
  126. Automatically asked for addition when a new file that
  127. needed filedialog to be found is in an unknown directory
  128. Stored and retrieved from INIFile
  129. + Breakpoints conditions added to INIFile
  130. * Breakpoints insterted and removed at debin and end of debug session
  131. Revision 1.4 1999/02/04 15:59:08 pierre
  132. * grep$$$.out was not closed
  133. Revision 1.3 1999/02/04 13:32:09 pierre
  134. * Several things added (I cannot commit them independently !)
  135. + added TBreakpoint and TBreakpointCollection
  136. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  137. + Breakpoint list in INIFile
  138. * Select items now also depend of SwitchMode
  139. * Reading of option '-g' was not possible !
  140. + added search for -Fu args pathes in TryToOpen
  141. + added code for automatic opening of FileDialog
  142. if source not found
  143. Revision 1.2 1999/01/21 11:54:21 peter
  144. + tools menu
  145. + speedsearch in symbolbrowser
  146. * working run command
  147. Revision 1.1 1998/12/22 14:27:54 peter
  148. * moved
  149. Revision 1.2 1998/12/22 10:39:49 peter
  150. + options are now written/read
  151. + find and replace routines
  152. }