fpide.pas 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901
  1. {
  2. This file is part of the Free Pascal Integrated Development Environment
  3. Copyright (c) 1998 by Berczi Gabor
  4. Main IDEApp object
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit fpide;
  12. {$i globdir.inc}
  13. interface
  14. uses
  15. Objects,Drivers,Views,App,Gadgets,MsgBox,Tabs,
  16. WEditor,WCEdit,
  17. Comphook,Browcol,
  18. WHTMLScn,
  19. FPViews,FPSymbol
  20. {$ifndef NODEBUG}
  21. ,fpevalw
  22. {$endif};
  23. type
  24. TExecType = (exNormal,exNoSwap,exDosShell);
  25. Tdisplaymode = (dmIDE,dmUser);
  26. TIDEApp = object(TApplication)
  27. IsRunning : boolean;
  28. displaymode : Tdisplaymode;
  29. constructor Init;
  30. procedure InitDesktop; virtual;
  31. procedure LoadMenuBar;
  32. procedure InitMenuBar; virtual;
  33. procedure reload_menubar;
  34. procedure InitStatusLine; virtual;
  35. procedure Open(FileName: string;FileDir:string);
  36. function OpenSearch(FileName: string) : boolean;
  37. function AskSaveAll: boolean;
  38. function SaveAll: boolean;
  39. function AutoSave: boolean;
  40. procedure Idle; virtual;
  41. procedure Update;
  42. procedure UpdateMode;
  43. procedure UpdateRunMenu(DebuggeeRunning : boolean);
  44. procedure UpdateTarget;
  45. procedure GetEvent(var Event: TEvent); virtual;
  46. procedure HandleEvent(var Event: TEvent); virtual;
  47. procedure GetTileRect(var R: TRect); virtual;
  48. function GetPalette: PPalette; virtual;
  49. procedure DosShell; {virtual;}
  50. procedure ShowReadme;
  51. destructor Done; virtual;
  52. procedure ShowUserScreen;
  53. procedure ShowIDEScreen;
  54. function IsClosing : boolean;
  55. private
  56. procedure NewEditor;
  57. procedure NewFromTemplate;
  58. procedure OpenRecentFile(RecentIndex: integer);
  59. procedure ChangeDir;
  60. procedure Print;
  61. procedure PrinterSetup;
  62. procedure ShowClipboard;
  63. procedure FindProcedure;
  64. procedure Objects;
  65. procedure Modules;
  66. procedure Globals;
  67. procedure SearchSymbol;
  68. procedure RunDir;
  69. procedure Parameters;
  70. procedure DoStepOver;
  71. procedure DoTraceInto;
  72. procedure DoRun;
  73. procedure DoResetDebugger;
  74. procedure DoContToCursor;
  75. procedure DoContUntilReturn;
  76. procedure Target;
  77. procedure DoCompilerMessages;
  78. procedure DoPrimaryFile;
  79. procedure DoClearPrimary;
  80. procedure DoUserScreenWindow;
  81. procedure DoCloseUserScreenWindow;
  82. procedure DoUserScreen;
  83. procedure DoOpenGDBWindow;
  84. procedure DoToggleBreak;
  85. procedure DoShowCallStack;
  86. procedure DoShowDisassembly;
  87. procedure DoShowBreakpointList;
  88. procedure DoShowWatches;
  89. procedure DoAddWatch;
  90. procedure do_evaluate;
  91. procedure DoShowRegisters;
  92. procedure DoShowFPU;
  93. procedure DoShowVector;
  94. function CheckModifiedEditor:boolean;
  95. function AskRecompileIfModified:boolean;
  96. procedure Messages;
  97. procedure Calculator;
  98. procedure DoAsciiTable;
  99. procedure ExecuteTool(Idx: integer);
  100. procedure SetSwitchesMode;
  101. procedure DoCompilerSwitch;
  102. procedure MemorySizes;
  103. procedure DoLinkerSwitch;
  104. procedure DoDebuggerSwitch;
  105. {$ifdef SUPPORT_REMOTE}
  106. procedure DoRemote;
  107. procedure TransferRemote;
  108. {$endif SUPPORT_REMOTE}
  109. procedure Directories;
  110. procedure Tools;
  111. procedure DoGrep;
  112. procedure Preferences;
  113. procedure EditorOptions(Editor: PEditor);
  114. procedure CodeComplete;
  115. procedure CodeTemplates;
  116. procedure BrowserOptions(Browser: PBrowserWindow);
  117. procedure DesktopOptions;
  118. procedure ResizeApplication(x, y : longint);
  119. procedure Mouse;
  120. procedure StartUp;
  121. procedure Colors;
  122. procedure OpenINI;
  123. procedure SaveINI;
  124. procedure SaveAsINI;
  125. procedure CloseAll;
  126. procedure WindowList;
  127. procedure HelpContents;
  128. procedure HelpHelpIndex;
  129. procedure HelpTopicSearch;
  130. procedure HelpPrevTopic;
  131. procedure HelpUsingHelp;
  132. procedure HelpFiles;
  133. procedure About;
  134. procedure CreateAnsiFile;
  135. public
  136. procedure SourceWindowClosed;
  137. function DoExecute(ProgramPath, Params, InFile, OutFile, ErrFile: string; ExecType: TExecType): boolean;
  138. private
  139. SaveCancelled: boolean;
  140. InsideDone : boolean;
  141. LastEvent: longint;
  142. procedure AddRecentFile(AFileName: string; CurX, CurY: sw_integer);
  143. function SearchRecentFile(AFileName: string): integer;
  144. procedure RemoveRecentFile(Index: integer);
  145. procedure CurDirChanged;
  146. procedure UpdatePrimaryFile;
  147. procedure UpdateINIFile;
  148. procedure UpdateRecentFileList;
  149. procedure UpdateTools;
  150. end;
  151. procedure PutEvent(TargetView: PView; E: TEvent);
  152. procedure PutCommand(TargetView: PView; What, Command: Word; InfoPtr: Pointer);
  153. var
  154. IDEApp: TIDEApp;
  155. implementation
  156. uses
  157. {$ifdef HasSignal}
  158. fpcatch,
  159. {$endif HasSignal}
  160. {$ifdef WinClipSupported}
  161. WinClip,
  162. {$endif WinClipSupported}
  163. {$ifdef Unix}
  164. fpKeys,
  165. {$endif Unix}
  166. FpDpAnsi,WConsts,
  167. Video,Mouse,Keyboard,
  168. Compiler,Version,
  169. FVConsts,
  170. Dos{,Memory},Menus,Dialogs,StdDlg,timeddlg,
  171. Systems,
  172. WUtils,WHlpView,WViews,WHTMLHlp,WHelp,WConsole,
  173. FPConst,FPVars,FPUtils,FPSwitch,FPIni,FPIntf,FPCompil,FPHelp,
  174. FPTemplt,FPCalc,FPUsrScr,FPTools,
  175. {$ifndef NODEBUG}
  176. FPDebug,FPRegs,
  177. {$endif}
  178. FPRedir,
  179. FPDesk,FPCodCmp,FPCodTmp;
  180. type
  181. TTargetedEvent = record
  182. Target: PView;
  183. Event: TEvent;
  184. end;
  185. const
  186. TargetedEventHead : integer = 0;
  187. TargetedEventTail : integer = 0;
  188. var
  189. TargetedEvents : array[0..10] of TTargetedEvent;
  190. resourcestring menu_local_gotosource = '~G~oto source';
  191. menu_local_tracksource = '~T~rack source';
  192. menu_local_options = '~O~ptions...';
  193. menu_local_clear = '~C~lear';
  194. menu_local_saveas = 'Save ~a~s';
  195. { menu_key_common_helpindex = 'Shift+F1';
  196. menu_key_common_topicsearch = 'Ctrl+F1';
  197. menu_key_common_prevtopic = 'Alt+F1';}
  198. { menu entries }
  199. menu_file = '~F~ile';
  200. menu_file_new = '~N~ew';
  201. menu_file_template = 'New from ~t~emplate...';
  202. menu_file_open = '~O~pen...';
  203. menu_file_save = '~S~ave';
  204. menu_file_saveas = 'Save ~a~s...';
  205. menu_file_saveall = 'Save a~l~l';
  206. menu_file_reload = '~R~eload';
  207. menu_file_print = '~P~rint';
  208. menu_file_printsetup = 'Print s~e~tup';
  209. menu_file_changedir = '~C~hange dir...';
  210. menu_file_dosshell = 'Comman~d~ shell';
  211. menu_file_exit = 'E~x~it';
  212. menu_edit = '~E~dit';
  213. {$ifdef HASAMIGA}
  214. {$ifdef AROS}
  215. menu_edit_copywin = 'Cop~y~ to AROS';
  216. menu_edit_pastewin = 'Paste from A~R~OS';
  217. {$else}
  218. menu_edit_copywin = 'Cop~y~ to System';
  219. menu_edit_pastewin = 'Paste from Syste~m~';
  220. {$endif}
  221. {$else}
  222. menu_edit_copywin = 'Cop~y~ to Windows';
  223. menu_edit_pastewin = 'Paste from ~W~indows';
  224. {$endif}
  225. menu_edit_undo = '~U~ndo';
  226. menu_edit_redo = '~R~edo';
  227. menu_edit_cut = 'Cu~t~';
  228. menu_edit_copy = '~C~opy';
  229. menu_edit_paste = '~P~aste';
  230. menu_edit_clear = 'C~l~ear';
  231. menu_edit_showclipboard= '~S~how clipboard';
  232. menu_edit_selectall = 'Select ~A~ll';
  233. menu_edit_unselect = 'U~n~select';
  234. menu_search = '~S~earch';
  235. menu_search_find = '~F~ind...';
  236. menu_search_replace = '~R~eplace...';
  237. menu_search_searchagain= '~S~earch again';
  238. menu_search_jumpline = '~G~o to line number...';
  239. menu_search_findproc = 'Find ~p~rocedure...';
  240. menu_search_objects = '~O~bjects';
  241. menu_search_modules = 'Mod~u~les';
  242. menu_search_globals = 'G~l~obals';
  243. menu_search_symbol = 'S~y~mbol...';
  244. menu_run = '~R~un';
  245. menu_run_run = '~R~un';
  246. menu_run_continue = '~C~ontinue';
  247. menu_run_stepover = '~S~tep over';
  248. menu_run_traceinto = '~T~race into';
  249. menu_run_conttocursor = '~G~oto Cursor';
  250. menu_run_untilreturn = '~U~ntil return';
  251. menu_run_rundir = 'Run ~D~irectory...';
  252. menu_run_parameters = 'P~a~rameters...';
  253. menu_run_resetdebugger = '~P~rogram reset';
  254. menu_compile = '~C~ompile';
  255. menu_compile_compile = '~C~ompile';
  256. menu_compile_make = '~M~ake';
  257. menu_compile_build = '~B~uild';
  258. menu_compile_target = '~T~arget...';
  259. menu_compile_primaryfile = '~P~rimary file...';
  260. menu_compile_clearprimaryfile = 'C~l~ear primary file';
  261. menu_compile_information = '~I~nformation...';
  262. menu_compile_compilermessages = 'C~o~mpiler messages';
  263. menu_debug = '~D~ebug';
  264. menu_debug_output = '~O~utput';
  265. menu_debug_userscreen = '~U~ser screen';
  266. menu_debug_breakpoint = '~B~reakpoint';
  267. menu_debug_callstack = '~C~all stack';
  268. menu_debug_remote = '~S~end to remote';
  269. menu_debug_registers = '~R~egisters';
  270. menu_debug_fpu_registers = '~F~loating Point Unit';
  271. menu_debug_vector_registers = '~V~ector Unit';
  272. menu_debug_addwatch = '~A~dd Watch';
  273. menu_debug_watches = '~W~atches';
  274. menu_debug_breakpointlist = 'Breakpoint ~L~ist';
  275. menu_debug_gdbwindow = '~G~DB window';
  276. menu_debug_disassemble = '~D~isassemble';
  277. menu_tools = '~T~ools';
  278. menu_tools_messages = '~M~essages';
  279. menu_tools_msgnext = 'Goto ~n~ext';
  280. menu_tools_msgprev = 'Goto ~p~revious';
  281. menu_tools_grep = '~G~rep';
  282. menu_tools_calculator = '~C~alculator';
  283. menu_tools_asciitable = 'Ascii ~t~able';
  284. menu_options = '~O~ptions';
  285. menu_options_mode = 'Mode~.~..';
  286. menu_options_compiler = '~C~ompiler...';
  287. menu_options_memory = '~M~emory sizes...';
  288. menu_options_linker = '~L~inker...';
  289. menu_options_debugger = 'De~b~ugger...';
  290. menu_options_remote = '~R~emote...';
  291. menu_options_directories = '~D~irectories...';
  292. menu_options_browser = 'Bro~w~ser...';
  293. menu_options_tools = '~T~ools...';
  294. menu_options_env = '~E~nvironment';
  295. menu_options_env_preferences = '~P~references...';
  296. menu_options_env_editor= '~E~ditor...';
  297. menu_options_env_codecomplete = 'Code~C~omplete...';
  298. menu_options_env_codetemplates = 'Code~T~emplates...';
  299. menu_options_env_desktop = '~D~esktop...';
  300. menu_options_env_keybmouse = 'Keyboard & ~m~ouse...';
  301. menu_options_env_startup = '~S~tartup...';
  302. menu_options_env_colors= '~C~olors';
  303. menu_options_learn_keys= 'Learn ~K~eys';
  304. menu_options_open = '~O~pen...';
  305. menu_options_save = '~S~ave';
  306. menu_options_saveas = 'Save ~a~s...';
  307. menu_window = '~W~indow';
  308. menu_window_tile = '~T~ile';
  309. menu_window_cascade = 'C~a~scade';
  310. menu_window_closeall = 'Cl~o~se all';
  311. menu_window_resize = '~S~ize/Move';
  312. menu_window_zoom = '~Z~oom';
  313. menu_window_next = '~N~ext';
  314. menu_window_previous = '~P~revious';
  315. menu_window_hide = '~H~ide';
  316. menu_window_close = '~C~lose';
  317. menu_window_list = '~L~ist...';
  318. menu_window_update = '~R~efresh display';
  319. menu_help = '~H~elp';
  320. menu_help_contents = '~C~ontents';
  321. menu_help_index = '~I~ndex';
  322. menu_help_topicsearch = '~T~opic search';
  323. menu_help_prevtopic = '~P~revious topic';
  324. menu_help_using = '~U~sing help';
  325. menu_help_files = '~F~iles...';
  326. menu_help_about = '~A~bout...';
  327. { Source editor local menu items }
  328. menu_srclocal_openfileatcursor = 'Open ~f~ile at cursor';
  329. menu_srclocal_browseatcursor = '~B~rowse symbol at cursor';
  330. menu_srclocal_topicsearch = 'Topic ~s~earch';
  331. menu_srclocal_options = '~O~ptions...';
  332. menu_srclocal_reload = '~R~eload modified file';
  333. { Help viewer local menu items }
  334. menu_hlplocal_contents = '~C~ontents';
  335. menu_hlplocal_index = '~I~ndex';
  336. menu_hlplocal_topicsearch = '~T~opic search';
  337. menu_hlplocal_prevtopic = '~P~revious topic';
  338. menu_hlplocal_copy = '~C~opy';
  339. { Messages local menu items }
  340. menu_msglocal_clear = '~C~lear';
  341. menu_msglocal_gotosource = '~G~oto source';
  342. menu_msglocal_tracksource = '~T~rack source';
  343. { menu_msglocal_saveas = menu_local_saveas;}
  344. { short cut entries in menu }
  345. menu_key_file_open = 'F3';
  346. menu_key_file_save = 'F2';
  347. menu_key_file_exit = 'Alt+X';
  348. menu_key_edit_undo = 'Alt+BkSp';
  349. menu_key_edit_cut_borland = 'Shift+Del';
  350. menu_key_edit_copy_borland = menu_key_common_copy_borland;
  351. menu_key_edit_paste_borland = 'Shift+Ins';
  352. menu_key_edit_cut_microsoft = 'Ctrl+X';
  353. menu_key_edit_copy_microsoft = menu_key_common_copy_microsoft;
  354. menu_key_edit_paste_microsoft = 'Ctrl+V';
  355. menu_key_edit_clear = 'Ctrl+Del';
  356. menu_key_edit_all_microsoft = 'Ctrl+A';
  357. menu_key_edit_all_borland = '';
  358. menu_key_run_run = 'Ctrl+F9';
  359. menu_key_run_stepover = 'F8';
  360. menu_key_run_traceinto = 'F7';
  361. menu_key_run_conttocursor = 'F4';
  362. menu_key_run_untilreturn= 'Alt+F4';
  363. menu_key_run_resetdebugger = 'Ctrl+F2';
  364. menu_key_compile_compile = 'Alt+F9';
  365. menu_key_compile_make = 'F9';
  366. menu_key_compile_compilermessages = 'F12';
  367. menu_key_debug_userscreen = 'Alt+F5';
  368. menu_key_debug_breakpoint = 'Ctrl+F8';
  369. menu_key_debug_callstack = 'Ctrl+F3';
  370. menu_key_debug_addwatch = 'Ctrl+F7';
  371. menu_key_tools_messages= 'F11';
  372. menu_key_tools_msgnext = 'Alt+F8';
  373. menu_key_tools_msgprev = 'Alt+F7';
  374. menu_key_tools_grep = 'Shift+F2';
  375. menu_key_window_resize = 'Ctrl+F5';
  376. menu_key_window_zoom = 'F5';
  377. menu_key_window_next = 'F6';
  378. menu_key_window_previous = 'Shift+F6';
  379. menu_key_window_close = 'Alt+F3';
  380. menu_key_window_list = 'Alt+0';
  381. menu_key_window_hide = 'Ctrl+F6';
  382. menu_key_help_helpindex = menu_key_common_helpindex;
  383. menu_key_help_topicsearch = menu_key_common_topicsearch;
  384. menu_key_help_prevtopic= menu_key_common_prevtopic;
  385. menu_key_hlplocal_index = menu_key_common_helpindex;
  386. menu_key_hlplocal_topicsearch = menu_key_common_topicsearch;
  387. menu_key_hlplocal_prevtopic = menu_key_common_prevtopic;
  388. menu_key_hlplocal_copy_borland = menu_key_common_copy_borland;
  389. menu_key_hlplocal_copy_microsoft = menu_key_common_copy_microsoft;
  390. { status line entries }
  391. status_help = '~F1~ Help';
  392. status_help_on_help = '~F1~ Help on help';
  393. status_help_previoustopic = '~Alt+F1~ Previous topic';
  394. status_help_index = '~Shift+F1~ Help index';
  395. status_help_close = '~Esc~ Close help';
  396. status_save = '~F2~ Save';
  397. status_open = '~F3~ Open';
  398. status_compile = '~Alt+F9~ Compile';
  399. status_make = '~F9~ Make';
  400. status_localmenu = '~Alt+F10~ Local menu';
  401. status_transferchar = '~Ctrl+Enter~ Transfer AnsiChar';
  402. status_msggotosource = '~'+EnterSign+'~ Goto source';
  403. status_msgtracksource = '~Space~ Track source';
  404. status_close = '~Esc~ Close';
  405. status_calculatorpaste = '~Ctrl+Enter~ Transfer result';
  406. status_disassemble = '~Alt+I~ Disassemble';
  407. { error messages }
  408. error_saving_cfg_file = 'Error saving configuration.';
  409. error_saving_dsk_file = 'Error saving desktop file.'#13+
  410. 'Desktop layout could not be stored.';
  411. error_user_screen_not_avail = 'Sorry, user screen not available.';
  412. { standard button texts }
  413. button_OK = 'O~K~';
  414. button_Cancel = 'Cancel';
  415. button_New = '~N~ew';
  416. button_Delete = '~D~elete';
  417. button_Show = '~S~how';
  418. button_Hide = '~H~ide';
  419. { dialogs }
  420. dialog_fillintemplateparameter = 'Fill in template parameter';
  421. dialog_calculator = 'Calculator';
  422. dialog_openafile = 'Open a file';
  423. dialog_browsesymbol = 'Browse Symbol';
  424. msg_confirmsourcediradd = 'Directory %s is not in search path for source files. '+
  425. 'Should we add it ?';
  426. msg_quitconfirm = 'Do You really want to quit?';
  427. msg_printernotopened = 'Can''t open printer,'#13#3'check device name in "print setup"';
  428. msg_printerror = 'Error while printing';
  429. msg_impossibletoreachcursor = 'Impossible to reach current cursor';
  430. msg_impossibletosetbreakpoint = 'Impossible to set breakpoints here';
  431. msg_nothingtorun = 'Oooops, nothing to run.';
  432. msg_cannotrununit = 'Can''t run a unit';
  433. msg_cannotrunlibrary = 'Can''t run a library';
  434. msg_errorexecutingshell = 'Error cannot run shell';
  435. msg_userscreennotavailable = 'Sorry, user screen not available.';
  436. msg_cantsetscreenmode = #3'Impossible to set'#13#3'%dx%d mode';
  437. msg_confirmnewscreenmode = 'Please, confirm that new mode'#13 +
  438. 'is displayed correctly';
  439. { Debugger confirmations and messages }
  440. msg_nodebuginfoavailable = 'No debug info available.';
  441. msg_nodebuggersupportavailable = 'No debugger support available.';
  442. msg_invalidfilename = 'Invalid filename %s';
  443. { File|New from template dialog }
  444. msg_notemplatesavailable = 'No templates available.';
  445. dialog_newfromtemplate = 'New from template';
  446. label_availabletemplates = 'Available ~t~emplates';
  447. label_filetoopen = 'File to ope~n~';
  448. label_lookingfor = 'Looking for %s';
  449. {Printing.}
  450. dialog_setupprinter = 'Setup printer';
  451. label_setupprinter_device = '~D~evice';
  452. {Find procedure.}
  453. dialog_proceduredialog = 'Find Procedure';
  454. label_enterproceduretofind = 'Enter ~m~atching expr.';
  455. label_sym_findprocedure = 'Procedures';
  456. label_sym_findprocedure2 = 'Matching ';
  457. { Browser messages }
  458. { msg_symbolnotfound = #3'Symbol %s not found';
  459. msg_nobrowserinfoavailable = 'No Browser info available';}
  460. msg_toomanysymbolscantdisplayall= 'Too many symbols. Can''t display all of them.';
  461. label_sym_objects = 'Objects';
  462. label_sym_globalscope = 'Global scope';
  463. label_sym_globals = 'Globals';
  464. dialog_units = 'Units';
  465. label_entersymboltobrowse = 'Enter S~y~mbol to browse';
  466. {Program parameters dialog.}
  467. dialog_programparameters = 'Program parameters';
  468. label_parameters_parameter = '~P~arameter';
  469. msg_programnotrundoserroris = #3'Program %s'#13#3'not run'#13#3'DosError = %d';
  470. msg_programfileexitedwithexitcode = #3'Program %s'#13#3'exited with '#13#3'exitcode = %d';
  471. {Target platform dialog.}
  472. dialog_target = 'Target';
  473. label_target_platform = 'Target platform';
  474. {Primary file dialog.}
  475. label_primaryfile_primaryfile = 'Primary file';
  476. {Switches mode.}
  477. dialog_switchesmode = 'SwitchesMode';
  478. static_switchesmode_switchesmode = 'Switches Mode';
  479. {Compiler options.}
  480. dialog_compilerswitches = 'Compiler Switches';
  481. label_compiler_syntaxswitches = 'S~y~ntax Switches';
  482. label_compiler_mode = 'Compiler ~m~ode';
  483. label_compiler_codegeneration = 'Code generation';
  484. label_compiler_optimizations = 'Optimizations';
  485. label_compiler_opt_targetprocessor = 'Optimization target processor';
  486. label_compiler_codegen_targetprocessor = 'Code generation target processor';
  487. label_compiler_linkafter = 'Linking stage';
  488. label_compiler_verboseswitches = 'Verbose Switches';
  489. label_compiler_browser = 'Browser';
  490. label_compiler_assemblerreader = 'Assembler reader';
  491. label_compiler_assemblerinfo = 'Assembler info';
  492. label_compiler_assembleroutput = 'Assembler output';
  493. page_compiler_syntax = 'S~y~ntax';
  494. page_compiler_codegeneration = '~G~enerated code';
  495. page_compiler_verbose = '~V~erbose';
  496. page_compiler_browser = '~B~rowser';
  497. page_compiler_assembler = '~A~ssembler';
  498. {Memory sizes dialog.}
  499. dialog_memorysizes = 'Memory sizes';
  500. {Linker options dialog.}
  501. dialog_linker = 'Linker';
  502. label_linker_preferredlibtype = 'Preferred library type';
  503. {Debugger options dialog.}
  504. dialog_debugger = 'Browsing/Debugging/Profiling';
  505. label_debugger_debuginfo = 'Debugging information';
  506. label_debugger_profileswitches = 'Profiling Switches';
  507. label_debugger_compilerargs = 'Additional ~c~ompiler args';
  508. label_debugger_useanotherconsole = '~U~se another console';
  509. label_debugger_redirection = 'Debuggee ~R~edirection';
  510. label_debugger_useanothertty = '~U~se Another tty for Debuggee';
  511. { Remote options dialog }
  512. dialog_remote = 'Remote setup';
  513. label_remote_machine = 'Remote machine ~n~ame';
  514. label_remote_port = 'Remote ~p~ort number';
  515. label_remote_dir = 'Remote ~d~irectory';
  516. label_remote_config = 'Remote config ~o~ptions';
  517. label_remote_ident = 'Remote ~i~dent';
  518. label_remote_send_command = 'Remote ~S~end command';
  519. label_remote_exec_command = 'Remote ~E~xec command';
  520. label_remote_ssh_exec_command = 'Remote Ss~h~ exec command';
  521. label_remote_copy = 'Remote copy executable';
  522. label_remote_shell = 'Remote shell executable';
  523. label_remote_gdbserver = 'Remote gdbserver executable';
  524. {Directories dialog.}
  525. dialog_directories = 'Directories';
  526. {Editor options window.}
  527. dialog_defaulteditoroptions = 'Default Editor Options';
  528. dialog_editoroptions = 'Editor Options';
  529. label_editor_backupfiles = 'Create backup ~f~iles';
  530. label_editor_insertmode = '~I~nsert mode';
  531. label_editor_autoindentmode = '~A~uto indent mode';
  532. label_editor_usetabcharacters = '~U~se tab characters';
  533. label_editor_backspaceunindents = '~B~ackspace unindents';
  534. label_editor_persistentblocks = '~P~ersistent blocks';
  535. label_editor_overwriteblocks = '~O~verwrite blocks';
  536. label_editor_syntaxhighlight = '~S~yntax highlight';
  537. label_editor_blockinsertcursor = 'B~l~ock insert cursor';
  538. label_editor_verticalblocks = '~V~ertical blocks';
  539. label_editor_highlightcolumn = 'Highlight ~c~olumn';
  540. label_editor_highlightrow = 'Highlight ~r~ow';
  541. label_editor_autoclosingbrackets = 'Aut~o~-closing brackets';
  542. label_editor_keeptrailingspaces = '~K~eep trailing spaces';
  543. label_editor_codecomplete = 'Co~d~eComplete enabled';
  544. label_editor_folds = 'E~n~able folds';
  545. label_editor_editoroptions = '~E~ditor options';
  546. label_editor_tabsize = '~T~ab size';
  547. label_editor_indentsize = 'Indent si~z~e';
  548. label_editor_highlightextensions = '~H~ighlight extensions';
  549. label_editor_filepatternsneedingtabs = 'File ~p~atterns needing tabs';
  550. {Browser options dialog.}
  551. dialog_browseroptions = 'Browser Options';
  552. dialog_localbrowseroptions = 'Local Browser Options';
  553. label_browser_labels = '~L~abels';
  554. label_browser_constants = '~C~onstants';
  555. label_browser_types = '~T~ypes';
  556. label_browser_variables = '~V~ariables';
  557. label_browser_procedures = '~P~rocedures';
  558. label_browser_inherited = '~I~nherited';
  559. label_browser_symbols = 'Symbols';
  560. label_browser_newbrowser = '~N~ew browser';
  561. label_browser_currentbrowser = '~R~eplace current';
  562. label_browser_subbrowsing = 'Sub-browsing';
  563. label_browser_scope = '~S~cope';
  564. label_browser_reference = 'R~e~ference';
  565. label_browser_preferredpane = 'Preferred pane';
  566. label_browser_qualifiedsymbols = '~Q~ualified symbols';
  567. label_browser_sortsymbols = 'S~o~rt always';
  568. label_browser_display = 'Display';
  569. {Preferences dialog.}
  570. dialog_preferences = 'Preferences';
  571. label_preferences_videomode = 'Video mode';
  572. label_preferences_currentdirectory = 'C~u~rrent directory';
  573. label_preferences_configdirectory = 'Conf~i~g file directory';
  574. label_preferences_desktopfile = 'Desktop file';
  575. label_preferences_editorfiles = 'Editor ~f~iles';
  576. label_preferences_environment = '~E~nvironment';
  577. label_preferences_desktop = '~D~esktop';
  578. label_preferences_autosave = 'Auto save';
  579. label_preferences_autotracksource = '~A~uto track source';
  580. label_preferences_closeongotosource = 'C~l~ose on go to source';
  581. label_preferences_changedironopen = 'C~h~ange dir on open';
  582. label_preferences_options = 'Options';
  583. {Desktop preferences dialog.}
  584. dialog_desktoppreferences = 'Desktop Preferences';
  585. label_desktop_historylists = '~H~istory lists';
  586. label_desktop_clipboard = '~C~lipboard content';
  587. label_desktop_watches = '~W~atch expressions';
  588. label_desktop_breakpoints = '~B~reakpoints';
  589. label_desktop_openwindow = '~O~pen windows';
  590. label_desktop_symbolinfo = '~S~ymbol information';
  591. label_desktop_codecompletewords = 'Co~d~eComplete wordlist';
  592. label_desktop_codetemplates = 'Code~T~emplates';
  593. label_desktop_preservedacrosssessions = '~P~reserved across sessions';
  594. {Mouse options dialog.}
  595. dialog_mouseoptions = 'Mouse Options';
  596. label_mouse_speedbar = 'Fast Medium Slow';
  597. label_mouse_doubleclickspeed = 'Mouse ~d~ouble click';
  598. label_mouse_reversebuttons = '~R~everse mouse buttons';
  599. label_mouse_crtlrightmousebuttonaction = 'Ctrl+Right mouse button';
  600. label_mouse_altrightmousebuttonaction = 'Alt+Right mouse button';
  601. label_mouse_act_nothing = 'Nothing';
  602. label_mouse_act_topicsearch = 'Topic search';
  603. label_mouse_act_gotocursor = 'Go to cursor';
  604. label_mouse_act_breakpoint = 'Breakpoint';
  605. label_mouse_act_evaluate = 'Evaluate';
  606. label_mouse_act_addwatch = 'Add watch';
  607. label_mouse_act_browsesymbol = 'Browse symbol';
  608. {Open options dialog.}
  609. dialog_openoptions = 'Open Options';
  610. msg_cantopenconfigfile = 'Can''t open config file.';
  611. msg_errorsavingconfigfile = 'Error saving config file.';
  612. {Save options dialog.}
  613. dialog_saveoptions = 'Save Options As';
  614. dialog_ini_filename = 'Name of INI file';
  615. {Window list dialog.}
  616. dialog_windowlist = 'Window List';
  617. label_wndlist_windows = '~W~indows';
  618. msg_windowlist_hidden = 'hidden';
  619. {Help files dialog.}
  620. dialog_helpfiles = 'Install Help Files';
  621. label_helpfiles_helpfiles = '~H~elp files';
  622. {Install help file.}
  623. dialog_installhelpfile = 'Install a help file';
  624. label_installhelpfile_filename = '~H~elp file name';
  625. {Topic title dialog.}
  626. dialog_topictitle = 'Topic title';
  627. label_topictitle_title = 'Title';
  628. { About window }
  629. { dialog_about = 'About';
  630. label_about_compilerversion = 'Compiler Version';
  631. label_about_debugger = 'Debugger';}
  632. msg_errorparsingtoolparams = 'Error parsing tool params.';
  633. msg_executingtool = 'Executing tool %s ...';
  634. msg_errorreadingoutput = 'Error reading output.';
  635. msg_executingfilterfor = 'Executing filter for %s ...';
  636. msg_cantfindfilteredoutput = 'Can''t find filtered output.';
  637. msg_errorprocessingfilteredoutput = 'Error processing filtered output.';
  638. msg_errorexecutingfilter = 'Error executing filter %s';
  639. msg_errorexecutingtool = 'Error executing tool %s';
  640. msg_filterexecutionsuccessfulexitcodeis = 'Filter execution successful. Exit code = %d';
  641. msg_toolexecutionsuccessfulexitcodeis = 'Tool execution successful. Exit code = %d';
  642. msg_xmustbesettoyforz_doyouwanttochangethis =
  643. '%s must be set to "%s" for %s. '+
  644. 'Do you want to change this option automatically?';
  645. dialog_greparguments = 'Grep arguments';
  646. msg_grepprogramnotfound = 'Grep program not found';
  647. label_grep_texttofind = '~T~ext to find';
  648. label_grep_greparguments = '~G~rep arguments';
  649. msg_runninggrepwithargs = 'Running Grep -n %s';
  650. msg_errorrunninggrep = #3'Error running Grep'#13#3'DosError = %d'#13#3'Exit code = %d';
  651. msg_errorreadinggrepoutput = #3'Error reading Grep output'#13#3'In line %d of %s';
  652. msg_filealreadyexistsoverwrite = 'File %s already exists. Overwrite?';
  653. msg_createkeywordindexforhelpfile = 'Create keyword index from help file?';
  654. msg_pleasewaitwhilecreatingindex = 'Please wait while creating index...';
  655. msg_buildingindexfile = 'Building index file %s';
  656. msg_filedoesnotcontainanylinks = '%s doesn''t contain any links, thus it isn''t suitable for indexing.';
  657. msg_storinghtmlindexinfile = 'Storing HTML index in %s';
  658. msg_errorstoringindexdata = 'Error storing index data (%d)';
  659. msg_cantcreatefile = 'Can''t create %s';
  660. {ANSI screenshots.}
  661. msg_saveansifile = 'Save previous screen as Ansi File';
  662. msg_click_upper_left = 'Click to select upper left corner; Escape to cancel; Enter to select (0,0)';
  663. msg_click_lower_right = 'Click to select lower right corner; Escape to cancel; Enter to select (maxX,maxY)';
  664. function IncTargetedEventPtr(I: integer): integer;
  665. begin
  666. Inc(I);
  667. if I>High(TargetedEvents) then I:=Low(TargetedEvents);
  668. IncTargetedEventPtr:=I;
  669. end;
  670. procedure PutEvent(TargetView: PView; E: TEvent);
  671. begin
  672. if IncTargetedEventPtr(TargetedEventHead)=TargetedEventTail then Exit;
  673. with TargetedEvents[TargetedEventHead] do
  674. begin
  675. Target:=TargetView;
  676. Event:=E;
  677. end;
  678. TargetedEventHead:=IncTargetedEventPtr(TargetedEventHead);
  679. end;
  680. procedure PutCommand(TargetView: PView; What, Command: Word; InfoPtr: Pointer);
  681. var E: TEvent;
  682. begin
  683. FillChar(E,Sizeof(E),0);
  684. E.What:=What;
  685. E.Command:=Command;
  686. E.InfoPtr:=InfoPtr;
  687. PutEvent(TargetView,E);
  688. end;
  689. function GetTargetedEvent(var P: PView; var E: TEvent): boolean;
  690. var OK: boolean;
  691. begin
  692. OK:=TargetedEventHead<>TargetedEventTail;
  693. if OK then
  694. begin
  695. with TargetedEvents[TargetedEventTail] do
  696. begin
  697. P:=Target;
  698. E:=Event;
  699. end;
  700. TargetedEventTail:=IncTargetedEventPtr(TargetedEventTail);
  701. end;
  702. GetTargetedEvent:=OK;
  703. end;
  704. function IDEUseSyntaxHighlight(Editor: PFileEditor): boolean;
  705. begin
  706. IDEUseSyntaxHighlight:=(Editor^.IsFlagSet(efSyntaxHighlight)) and ((Editor^.FileName='') or MatchesMaskList(NameAndExtOf(Editor^.FileName),HighlightExts));
  707. end;
  708. function IDEUseTabsPattern(Editor: PFileEditor): boolean;
  709. begin
  710. { the commented code lead all new files
  711. to become with TAB use enabled which is wrong in my opinion PM }
  712. IDEUseTabsPattern:={(Editor^.FileName='') or }MatchesMaskList(NameAndExtOf(Editor^.FileName),TabsPattern);
  713. end;
  714. constructor TIDEApp.Init;
  715. var R: TRect;
  716. begin
  717. displaymode:=dmIDE;
  718. UseSyntaxHighlight:=@IDEUseSyntaxHighlight;
  719. UseTabsPattern:=@IDEUseTabsPattern;
  720. inherited Init;
  721. InitAdvMsgBox;
  722. InsideDone:=false;
  723. IsRunning:=true;
  724. MenuBar^.GetBounds(R); R.A.X:=R.B.X-8;
  725. New(ClockView, Init(R));
  726. ClockView^.GrowMode:=gfGrowLoX+gfGrowHiX;
  727. Application^.Insert(ClockView);
  728. New(ClipboardWindow, Init);
  729. Desktop^.Insert(ClipboardWindow);
  730. New(CalcWindow, Init); CalcWindow^.Hide;
  731. Desktop^.Insert(CalcWindow);
  732. New(CompilerMessageWindow, Init);
  733. CompilerMessageWindow^.Hide;
  734. Desktop^.Insert(CompilerMessageWindow);
  735. Message(@Self,evBroadcast,cmUpdate,nil);
  736. CurDirChanged;
  737. { heap viewer }
  738. GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-9; R.A.Y:=R.B.Y-1;
  739. New(HeapView, InitKb(R));
  740. if (StartupOptions and soHeapMonitor)=0 then HeapView^.Hide;
  741. Insert(HeapView);
  742. Drivers.ShowMouse;
  743. {$ifdef Windows}
  744. // WindowsShowMouse;
  745. {$endif Windows}
  746. end;
  747. procedure TIDEApp.InitDesktop;
  748. var
  749. R: TRect;
  750. begin
  751. GetExtent(R);
  752. Inc(R.A.Y);
  753. Dec(R.B.Y);
  754. Desktop:=New(PFPDesktop, Init(R));
  755. end;
  756. procedure TIDEApp.LoadMenuBar;
  757. var R: TRect;
  758. WinPMI : PMenuItem;
  759. begin
  760. GetExtent(R); R.B.Y:=R.A.Y+1;
  761. WinPMI:=nil;
  762. {$ifdef WinClipSupported}
  763. if WinClipboardSupported then
  764. WinPMI:=NewLine(
  765. NewItem(menu_edit_copywin,'', kbNoKey, cmCopyWin, hcCopyWin,
  766. NewItem(menu_edit_pastewin,'', kbNoKey, cmPasteWin, hcPasteWin,
  767. nil)));
  768. {$endif WinClipSupported}
  769. MenuBar:=New(PAdvancedMenuBar, Init(R, NewMenu(
  770. NewSubMenu(menu_file,hcFileMenu, NewMenu(
  771. NewItem(menu_file_new,'',kbNoKey,cmNew,hcNew,
  772. NewItem(menu_file_template,'',kbNoKey,cmNewFromTemplate,hcNewFromTemplate,
  773. NewItem(menu_file_open,menu_key_file_open,kbF3,cmOpen,hcOpen,
  774. NewItem(menu_file_reload,'',kbNoKey,cmDoReload,hcDoReload,
  775. NewItem(menu_file_save,menu_key_file_save,kbF2,cmSave,hcSave,
  776. NewItem(menu_file_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  777. NewItem(menu_file_saveall,'',kbNoKey,cmSaveAll,hcSaveAll,
  778. NewLine(
  779. NewItem(menu_file_print,'',kbNoKey,cmPrint,hcPrint,
  780. NewItem(menu_file_printsetup,'',kbNoKey,cmPrinterSetup,hcPrinterSetup,
  781. NewLine(
  782. NewItem(menu_file_changedir,'',kbNoKey,cmChangeDir,hcChangeDir,
  783. NewItem(menu_file_dosshell,'',kbNoKey,cmDOSShell,hcDOSShell,
  784. NewItem(menu_file_exit,menu_key_file_exit,kbNoKey,cmQuit,hcQuit,
  785. nil))))))))))))))),
  786. NewSubMenu(menu_edit,hcEditMenu, NewMenu(
  787. NewItem(menu_edit_undo,menu_key_edit_undo, kbAltBack, cmUndo, hcUndo,
  788. NewItem(menu_edit_redo,'', kbNoKey, cmRedo, hcRedo,
  789. {$ifdef DebugUndo}
  790. NewItem('~D~ump Undo','', kbNoKey, cmDumpUndo, hcUndo,
  791. NewItem('U~n~do All','', kbNoKey, cmUndoAll, hcUndo,
  792. NewItem('R~e~do All','', kbNoKey, cmRedoAll, hcRedo,
  793. {$endif DebugUndo}
  794. NewLine(
  795. NewItem(menu_edit_cut,menu_key_edit_cut, cut_key, cmCut, hcCut,
  796. NewItem(menu_edit_copy,menu_key_edit_copy, copy_key, cmCopy, hcCopy,
  797. NewItem(menu_edit_paste,menu_key_edit_paste, paste_key, cmPaste, hcPaste,
  798. NewItem(menu_edit_clear,menu_key_edit_clear, kbCtrlDel, cmClear, hcClear,
  799. NewItem(menu_edit_selectall,menu_key_edit_all, all_Key, cmSelectAll, hcSelectAll,
  800. NewItem(menu_edit_unselect,'', kbNoKey, cmUnselect, hcUnselect,
  801. NewLine(
  802. NewItem(menu_edit_showclipboard,'', kbNoKey, cmShowClipboard, hcShowClipboard,
  803. WinPMI))))))))
  804. {$ifdef DebugUndo}))){$endif DebugUndo}
  805. )))),
  806. NewSubMenu(menu_search,hcSearchMenu, NewMenu(
  807. NewItem(menu_search_find,'', kbNoKey, cmFind, hcFind,
  808. NewItem(menu_search_replace,'', kbNoKey, cmReplace, hcReplace,
  809. NewItem(menu_search_searchagain,'', kbNoKey, cmSearchAgain, hcSearchAgain,
  810. NewLine(
  811. NewItem(menu_search_jumpline,'', kbNoKey, cmJumpLine, hcGotoLine,
  812. NewItem(menu_search_findproc,'', kbNoKey, cmFindProcedure, hcFindProcedure,
  813. NewLine(
  814. NewItem(menu_search_objects,'', kbNoKey, cmObjects, hcObjects,
  815. NewItem(menu_search_modules,'', kbNoKey, cmModules, hcModules,
  816. NewItem(menu_search_globals,'', kbNoKey, cmGlobals, hcGlobals,
  817. NewLine(
  818. NewItem(menu_search_symbol,'', kbNoKey, cmSymbol, hcSymbol,
  819. nil))))))))))))),
  820. NewSubMenu(menu_run,hcRunMenu, NewMenu(
  821. NewItem(menu_run_run,menu_key_run_run, kbCtrlF9, cmRun, hcRun,
  822. NewItem(menu_run_stepover,menu_key_run_stepover, kbF8, cmStepOver, hcRun,
  823. NewItem(menu_run_traceinto,menu_key_run_traceinto, kbF7, cmTraceInto, hcRun,
  824. NewItem(menu_run_conttocursor,menu_key_run_conttocursor, kbF4, cmContToCursor, hcContToCursor,
  825. NewItem(menu_run_untilreturn,menu_key_run_untilreturn, kbAltF4,cmUntilReturn,hcUntilReturn,
  826. NewItem(menu_run_rundir,'', kbNoKey, cmRunDir, hcRunDir,
  827. NewItem(menu_run_parameters,'', kbNoKey, cmParameters, hcParameters,
  828. NewItem(menu_run_resetdebugger,menu_key_run_resetdebugger, kbCtrlF2, cmResetDebugger, hcResetDebugger,
  829. nil))))))))),
  830. NewSubMenu(menu_compile,hcCompileMenu, NewMenu(
  831. NewItem(menu_compile_compile,menu_key_compile_compile, kbAltF9, cmCompile, hcCompile,
  832. NewItem(menu_compile_make,menu_key_compile_make, kbF9, cmMake, hcMake,
  833. NewItem(menu_compile_build,'', kbNoKey, cmBuild, hcBuild,
  834. NewLine(
  835. NewItem(menu_compile_target,'', kbNoKey, cmTarget, hcTarget,
  836. NewItem(menu_compile_primaryfile,'', kbNoKey, cmPrimaryFile, hcPrimaryFile,
  837. NewItem(menu_compile_clearprimaryfile,'', kbNoKey, cmClearPrimary, hcClearPrimary,
  838. NewLine(
  839. NewItem(menu_compile_compilermessages,menu_key_compile_compilermessages, kbF12, cmCompilerMessages, hcCompilerMessages,
  840. nil)))))))))),
  841. NewSubMenu(menu_debug, hcDebugMenu, NewMenu(
  842. NewItem(menu_debug_output,'', kbNoKey, cmUserScreenWindow, hcUserScreenWindow,
  843. NewItem(menu_debug_userscreen,menu_key_debug_userscreen, kbAltF5, cmUserScreen, hcUserScreen,
  844. NewLine(
  845. {$ifdef SUPPORT_REMOTE}
  846. NewItem(menu_debug_remote,'', kbNoKey, cmTransferRemote, hcTransferRemote,
  847. {$endif SUPPORT_REMOTE}
  848. NewItem(menu_debug_addwatch,menu_key_debug_addwatch, kbCtrlF7, cmAddWatch, hcAddWatch,
  849. NewItem(menu_debug_watches,'', kbNoKey, cmWatches, hcWatchesWindow,
  850. NewItem(menu_debug_breakpoint,menu_key_debug_breakpoint, kbCtrlF8, cmToggleBreakpoint, hcToggleBreakpoint,
  851. NewItem(menu_debug_breakpointlist,'', kbNoKey, cmBreakpointList, hcBreakpointList,
  852. NewItem('~E~valuate...','Ctrl+F4', kbCtrlF4, cmEvaluate, hcEvaluate,
  853. NewItem(menu_debug_callstack,menu_key_debug_callstack, kbCtrlF3, cmStack, hcStackWindow,
  854. NewLine(
  855. NewItem(menu_debug_disassemble,'', kbNoKey, cmDisassemble, hcDisassemblyWindow,
  856. NewItem(menu_debug_registers,'', kbNoKey, cmRegisters, hcRegistersWindow,
  857. NewItem(menu_debug_fpu_registers,'', kbNoKey, cmFPURegisters, hcFPURegisters,
  858. NewItem(menu_debug_vector_registers,'', kbNoKey, cmVectorRegisters, hcVectorRegisters,
  859. NewLine(
  860. NewItem(menu_debug_gdbwindow,'', kbNoKey, cmOpenGDBWindow, hcOpenGDBWindow,
  861. nil
  862. {$ifdef SUPPORT_REMOTE}
  863. )
  864. {$endif SUPPORT_REMOTE}
  865. ))))))))))))))))),
  866. NewSubMenu(menu_tools, hcToolsMenu, NewMenu(
  867. NewItem(menu_tools_messages,menu_key_tools_messages, kbF11, cmToolsMessages, hcToolsMessages,
  868. NewItem(menu_tools_msgnext,menu_key_tools_msgnext, kbAltF8, cmToolsMsgNext, hcToolsMsgNext,
  869. NewItem(menu_tools_msgprev,menu_key_tools_msgprev, kbAltF7, cmToolsMsgPrev, hcToolsMsgPrev,
  870. NewLine(
  871. NewItem(menu_tools_grep,menu_key_tools_grep, kbShiftF2, cmGrep, hcGrep,
  872. NewItem(menu_tools_calculator, '', kbNoKey, cmCalculator, hcCalculator,
  873. NewItem(menu_tools_asciitable, '', kbNoKey, cmAsciiTable, hcAsciiTable,
  874. nil)))))))),
  875. NewSubMenu(menu_options, hcOptionsMenu, NewMenu(
  876. NewItem(menu_options_mode,'', kbNoKey, cmSwitchesMode, hcSwitchesMode,
  877. NewItem(menu_options_compiler,'', kbNoKey, cmCompiler, hcCompiler,
  878. NewItem(menu_options_memory,'', kbNoKey, cmMemorySizes, hcMemorySizes,
  879. NewItem(menu_options_linker,'', kbNoKey, cmLinker, hcLinker,
  880. NewItem(menu_options_debugger,'', kbNoKey, cmDebugger, hcDebugger,
  881. {$ifdef SUPPORT_REMOTE}
  882. NewItem(menu_options_remote,'', kbNoKey, cmRemoteDialog, hcRemoteDialog,
  883. {$endif SUPPORT_REMOTE}
  884. NewItem(menu_options_directories,'', kbNoKey, cmDirectories, hcDirectories,
  885. NewItem(menu_options_browser,'',kbNoKey, cmBrowser, hcBrowser,
  886. NewItem(menu_options_tools,'', kbNoKey, cmTools, hcTools,
  887. NewLine(
  888. NewSubMenu(menu_options_env, hcEnvironmentMenu, NewMenu(
  889. NewItem(menu_options_env_preferences,'', kbNoKey, cmPreferences, hcPreferences,
  890. NewItem(menu_options_env_editor,'', kbNoKey, cmEditor, hcEditor,
  891. NewItem(menu_options_env_codecomplete,'', kbNoKey, cmCodeCompleteOptions, hcCodeCompleteOptions,
  892. NewItem(menu_options_env_codetemplates,'', kbNoKey, cmCodeTemplateOptions, hcCodeTemplateOptions,
  893. NewItem(menu_options_env_desktop,'', kbNoKey, cmDesktopOptions, hcDesktopOptions,
  894. NewItem(menu_options_env_keybmouse,'', kbNoKey, cmMouse, hcMouse,
  895. { NewItem(menu_options_env_startup,'', kbNoKey, cmStartup, hcStartup,
  896. NewItem(menu_options_env_colors,'', kbNoKey, cmColors, hcColors,}
  897. {$ifdef Unix}
  898. NewItem(menu_options_learn_keys,'', kbNoKey, cmKeys, hcKeys,
  899. {$endif Unix}
  900. nil
  901. {$ifdef Unix}
  902. )
  903. {$endif Unix}
  904. {))}))))))),
  905. NewLine(
  906. NewItem(menu_options_open,'', kbNoKey, cmOpenINI, hcOpenINI,
  907. NewItem(menu_options_save,'', kbNoKey, cmSaveINI, hcSaveINI,
  908. NewItem(menu_options_saveas,'', kbNoKey, cmSaveAsINI, hcSaveAsINI,
  909. nil
  910. {$ifdef SUPPORT_REMOTE}
  911. )
  912. {$endif SUPPORT_REMOTE}
  913. ))))))))))))))),
  914. NewSubMenu(menu_window, hcWindowMenu, NewMenu(
  915. NewItem(menu_window_tile,'', kbNoKey, cmTile, hcTile,
  916. NewItem(menu_window_cascade,'', kbNoKey, cmCascade, hcCascade,
  917. NewItem(menu_window_closeall,'', kbNoKey, cmCloseAll, hcCloseAll,
  918. NewLine(
  919. NewItem(menu_window_resize,menu_key_window_resize, kbCtrlF5, cmResize, hcResize,
  920. NewItem(menu_window_zoom,menu_key_window_zoom, kbF5, cmZoom, hcZoom,
  921. NewItem(menu_window_next,menu_key_window_next, kbF6, cmNext, hcNext,
  922. NewItem(menu_window_previous,menu_key_window_previous, kbShiftF6, cmPrev, hcPrev,
  923. NewItem(menu_window_hide,menu_key_window_hide, kbCtrlF6, cmHide, hcHide,
  924. NewItem(menu_window_close,menu_key_window_close, kbAltF3, cmClose, hcClose,
  925. NewLine(
  926. NewItem(menu_window_list,menu_key_window_list, kbAlt0, cmWindowList, hcWindowList,
  927. NewItem(menu_window_update,'', kbNoKey, cmUpdate, hcUpdate,
  928. nil)))))))))))))),
  929. NewSubMenu(menu_help, hcHelpMenu, NewMenu(
  930. NewItem(menu_help_contents,'', kbNoKey, cmHelpContents, hcHelpContents,
  931. NewItem(menu_help_index,menu_key_help_helpindex, kbShiftF1, cmHelpIndex, hcHelpIndex,
  932. NewItem(menu_help_topicsearch,menu_key_help_topicsearch, kbCtrlF1, cmHelpTopicSearch, hcHelpTopicSearch,
  933. NewItem(menu_help_prevtopic,menu_key_help_prevtopic, kbAltF1, cmHelpPrevTopic, hcHelpPrevTopic,
  934. NewItem(menu_help_using,'',kbNoKey, cmHelpUsingHelp, hcHelpUsingHelp,
  935. NewItem(menu_help_files,'',kbNoKey, cmHelpFiles, hcHelpFiles,
  936. NewLine(
  937. NewItem(menu_help_about,'',kbNoKey, cmAbout, hcAbout,
  938. nil))))))))),
  939. nil)))))))))))));
  940. SetCmdState(ToClipCmds+FromClipCmds+NulClipCmds+UndoCmd+RedoCmd,false);
  941. end;
  942. procedure TIDEApp.InitMenuBar;
  943. begin
  944. LoadMenuBar;
  945. DisableCommands(EditorCmds+SourceCmds+CompileCmds);
  946. SetCmdState([cmTile,cmCascade],false);
  947. // Update; Desktop is still nil at that point ...
  948. end;
  949. procedure Tideapp.reload_menubar;
  950. begin
  951. delete(menubar);
  952. dispose(menubar,done);
  953. case EditKeys of
  954. ekm_microsoft:
  955. begin
  956. menu_key_edit_cut:=menu_key_edit_cut_microsoft;
  957. menu_key_edit_copy:=menu_key_edit_copy_microsoft;
  958. menu_key_edit_paste:=menu_key_edit_paste_microsoft;
  959. menu_key_edit_all:=menu_key_edit_all_microsoft;
  960. menu_key_hlplocal_copy:=menu_key_hlplocal_copy_microsoft;
  961. cut_key:=kbCtrlX;
  962. copy_key:=kbCtrlC;
  963. paste_key:=kbCtrlV;
  964. all_key:=kbCtrlA;
  965. end;
  966. ekm_borland:
  967. begin
  968. menu_key_edit_cut:=menu_key_edit_cut_borland;
  969. menu_key_edit_copy:=menu_key_edit_copy_borland;
  970. menu_key_edit_paste:=menu_key_edit_paste_borland;
  971. menu_key_edit_all:=menu_key_edit_all_borland;
  972. menu_key_hlplocal_copy:=menu_key_hlplocal_copy_borland;
  973. cut_key:=kbShiftDel;
  974. copy_key:=kbCtrlIns;
  975. paste_key:=kbShiftIns;
  976. all_key:=kbNoKey;
  977. end;
  978. end;
  979. loadmenubar;
  980. insert(menubar);
  981. end;
  982. procedure TIDEApp.InitStatusLine;
  983. var
  984. R: TRect;
  985. begin
  986. GetExtent(R);
  987. R.A.Y := R.B.Y - 1;
  988. StatusLine:=New(PIDEStatusLine, Init(R,
  989. NewStatusDef(hcDragging, hcDragging,
  990. NewStatusKey(status_help, kbF1, cmHelp,
  991. StdStatusKeys(
  992. NewStatusKey('~Cursor~ Move', kbNoKey, 65535,
  993. NewStatusKey('~Shift+Cursor~ Size', kbNoKey, 65535,
  994. NewStatusKey('~'#17#$C4#$D9'~ Done', kbNoKey, 65535, {#17 = left arrow}
  995. NewStatusKey('~Esc~ Cancel', kbNoKey, 65535,
  996. nil)))))),
  997. NewStatusDef(hcStackWindow, hcStackWindow,
  998. NewStatusKey(status_help, kbF1, cmHelp,
  999. NewStatusKey(status_disassemble, kbAltI, cmDisassemble,
  1000. StdStatusKeys(
  1001. nil))),
  1002. NewStatusDef(hcFirstCommand, hcLastNormalCommand,
  1003. NewStatusKey(status_help, kbF1, cmHelp,
  1004. StdStatusKeys(
  1005. nil)),
  1006. NewStatusDef(hcFirstNoAltXCommand, hcLastCommand,
  1007. NewStatusKey(status_help, kbF1, cmHelp,
  1008. NewStatusKey('', kbF10, cmMenu,
  1009. NewStatusKey('', kbAltF3, cmClose,
  1010. NewStatusKey('', kbF5, cmZoom,
  1011. NewStatusKey('', kbCtrlF5, cmResize,
  1012. NewStatusKey('', kbF6, cmNext,
  1013. NewStatusKey('', kbShiftF6, cmPrev,
  1014. nil))))))),
  1015. NewStatusDef(hcHelpWindow, hcHelpWindow,
  1016. NewStatusKey(status_help_on_help, kbF1, cmHelpUsingHelp,
  1017. NewStatusKey(status_help_previoustopic, kbAltF1, cmHelpPrevTopic,
  1018. NewStatusKey(status_help_index, kbShiftF1, cmHelpIndex,
  1019. NewStatusKey(status_help_close, kbEsc, cmClose,
  1020. StdStatusKeys(
  1021. nil))))),
  1022. NewStatusDef(hcSourceWindow, hcSourceWindow,
  1023. NewStatusKey(status_help, kbF1, cmHelp,
  1024. NewStatusKey(status_save, kbF2, cmSave,
  1025. NewStatusKey(status_open, kbF3, cmOpen,
  1026. NewStatusKey(status_compile, kbAltF9, cmCompile,
  1027. NewStatusKey(status_make, kbF9, cmMake,
  1028. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  1029. StdStatusKeys
  1030. (
  1031. nil))))))),
  1032. NewStatusDef(hcASCIITableWindow, hcASCIITableWindow,
  1033. NewStatusKey(status_help, kbF1, cmHelp,
  1034. NewStatusKey(status_transferchar, kbCtrlEnter, cmTransfer,
  1035. StdStatusKeys(
  1036. nil))),
  1037. NewStatusDef(hcMessagesWindow, hcMessagesWindow,
  1038. NewStatusKey(status_help, kbF1, cmHelp,
  1039. NewStatusKey(status_msggotosource, kbEnter, cmMsgGotoSource,
  1040. NewStatusKey(status_msgtracksource, kbNoKey, cmMsgTrackSource,
  1041. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  1042. NewStatusKey('', kbEsc, cmClose,
  1043. StdStatusKeys(
  1044. nil)))))),
  1045. NewStatusDef(hcCalcWindow, hcCalcWindow,
  1046. NewStatusKey(status_help, kbF1, cmHelp,
  1047. NewStatusKey(status_close, kbEsc, cmClose,
  1048. NewStatusKey(status_calculatorpaste, kbCtrlEnter, cmCalculatorPaste,
  1049. StdStatusKeys(
  1050. nil)))),
  1051. NewStatusDef(0, $FFFF,
  1052. NewStatusKey(status_help, kbF1, cmHelp,
  1053. NewStatusKey(status_open, kbF3, cmOpen,
  1054. NewStatusKey(status_compile, kbAltF9, cmCompile,
  1055. NewStatusKey(status_make, kbF9, cmMake,
  1056. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  1057. StdStatusKeys(
  1058. nil)))))),
  1059. nil))))))))))));
  1060. end;
  1061. procedure TIDEApp.Idle;
  1062. begin
  1063. inherited Idle;
  1064. Message(Application,evIdle,0,nil);
  1065. end;
  1066. procedure TIDEApp.GetEvent(var Event: TEvent);
  1067. var P: PView;
  1068. begin
  1069. { first of all dispatch queued targeted events }
  1070. while GetTargetedEvent(P,Event) do
  1071. P^.HandleEvent(Event);
  1072. { Handle System events directly }
  1073. Drivers.GetSystemEvent(Event); { Load system event }
  1074. If (Event.What <> evNothing) Then
  1075. HandleEvent(Event);
  1076. inherited GetEvent(Event);
  1077. {$ifdef DEBUG}
  1078. if (Event.What=evKeyDown) and (Event.KeyCode=kbAltF11) then
  1079. begin
  1080. {$ifdef HasSignal}
  1081. Generate_SIGSEGV;
  1082. {$else}
  1083. Halt(1);
  1084. {$endif}
  1085. end;
  1086. if (Event.What=evKeyDown) and (Event.KeyCode=kbCtrlF11) then
  1087. begin
  1088. RunError(250);
  1089. end;
  1090. {$endif DEBUG}
  1091. if (Event.What=evKeyDown) and (Event.KeyCode=kbAltF12) then
  1092. begin
  1093. CreateAnsiFile;
  1094. ClearEvent(Event);
  1095. end;
  1096. if Event.What<>evNothing then
  1097. LastEvent:=GetDosTicks
  1098. else
  1099. begin
  1100. if abs(GetDosTicks-LastEvent)>SleepTimeOut then
  1101. GiveUpTimeSlice;
  1102. end;
  1103. end;
  1104. procedure TIDEApp.HandleEvent(var Event: TEvent);
  1105. var DontClear: boolean;
  1106. TempS: string;
  1107. ForceDlg: boolean;
  1108. W : PSourceWindow;
  1109. DS : DirStr;
  1110. NS : NameStr;
  1111. ES : ExtStr;
  1112. {$ifdef HasSignal}
  1113. CtrlCCatched : boolean;
  1114. {$endif HasSignal}
  1115. begin
  1116. {$ifdef HasSignal}
  1117. if (Event.What=evKeyDown) and (Event.keyCode=kbCtrlC) and
  1118. (CtrlCPressed) then
  1119. begin
  1120. CtrlCCatched:=true;
  1121. {$ifdef DEBUG}
  1122. Writeln(stderr,'One Ctrl-C caught');
  1123. {$endif DEBUG}
  1124. end
  1125. else
  1126. CtrlCCatched:=false;
  1127. {$endif HasSignal}
  1128. case Event.What of
  1129. evKeyDown :
  1130. begin
  1131. DontClear:=true;
  1132. { just for debugging purposes }
  1133. end;
  1134. evCommand :
  1135. begin
  1136. DontClear:=false;
  1137. case Event.Command of
  1138. cmUpdate : Message(Application,evBroadcast,cmUpdate,nil);
  1139. { -- File menu -- }
  1140. cmNew : NewEditor;
  1141. cmNewFromTemplate: NewFromTemplate;
  1142. cmOpen : begin
  1143. ForceDlg:=false;
  1144. if (OpenFileName<>'') and
  1145. ((DirOf(OpenFileName)='') or (Pos(ListSeparator,OpenFileName)<>0)) then
  1146. begin
  1147. TempS:=LocateSourceFile(OpenFileName,false);
  1148. if TempS='' then
  1149. ForceDlg:=true
  1150. else
  1151. OpenFileName:=TempS;
  1152. end;
  1153. if ForceDlg then
  1154. OpenSearch(OpenFileName)
  1155. else
  1156. begin
  1157. W:=LastSourceEditor;
  1158. if assigned(W) then
  1159. FSplit(W^.Editor^.FileName,DS,NS,ES)
  1160. else
  1161. DS:='';
  1162. Open(OpenFileName,DS);
  1163. end;
  1164. OpenFileName:='';
  1165. end;
  1166. cmPrint : Print;
  1167. cmPrinterSetup : PrinterSetup;
  1168. cmSaveAll : SaveAll;
  1169. cmChangeDir : ChangeDir;
  1170. cmDOSShell : DOSShell;
  1171. cmRecentFileBase..
  1172. cmRecentFileBase+10
  1173. : OpenRecentFile(Event.Command-cmRecentFileBase);
  1174. { -- Edit menu -- }
  1175. cmShowClipboard : ShowClipboard;
  1176. { -- Search menu -- }
  1177. cmFindProcedure : FindProcedure;
  1178. cmObjects : Objects;
  1179. cmModules : Modules;
  1180. cmGlobals : Globals;
  1181. cmSymbol : SearchSymbol;
  1182. { -- Run menu -- }
  1183. cmRunDir : RunDir;
  1184. cmParameters : Parameters;
  1185. cmStepOver : DoStepOver;
  1186. cmTraceInto : DoTraceInto;
  1187. cmRun,
  1188. cmContinue : DoRun;
  1189. cmResetDebugger : DoResetDebugger;
  1190. cmContToCursor : DoContToCursor;
  1191. cmUntilReturn : DoContUntilReturn;
  1192. { -- Compile menu -- }
  1193. cmCompile : DoCompile(cCompile);
  1194. cmBuild : DoCompile(cBuild);
  1195. cmMake : DoCompile(cMake);
  1196. cmTarget : Target;
  1197. cmPrimaryFile : DoPrimaryFile;
  1198. cmClearPrimary : DoClearPrimary;
  1199. cmCompilerMessages : DoCompilerMessages;
  1200. { -- Debug menu -- }
  1201. cmUserScreen : DoUserScreen;
  1202. cmToggleBreakpoint : DoToggleBreak;
  1203. cmStack : DoShowCallStack;
  1204. cmDisassemble : DoShowDisassembly;
  1205. cmBreakpointList : DoShowBreakpointList;
  1206. cmWatches : DoShowWatches;
  1207. cmAddWatch : DoAddWatch;
  1208. cmOpenGDBWindow : DoOpenGDBWindow;
  1209. cmRegisters : DoShowRegisters;
  1210. cmFPURegisters : DoShowFPU;
  1211. cmVectorRegisters : DoShowVector;
  1212. cmEvaluate : do_evaluate;
  1213. { -- Options menu -- }
  1214. cmSwitchesMode : SetSwitchesMode;
  1215. cmCompiler : DoCompilerSwitch;
  1216. cmMemorySizes : MemorySizes;
  1217. cmLinker : DoLinkerSwitch;
  1218. cmDebugger : DoDebuggerSwitch;
  1219. {$ifdef SUPPORT_REMOTE}
  1220. cmRemoteDialog : DoRemote;
  1221. cmTransferRemote: TransferRemote;
  1222. {$endif SUPPORT_REMOTE}
  1223. cmDirectories : Directories;
  1224. cmTools : Tools;
  1225. cmPreferences : Preferences;
  1226. cmEditor : EditorOptions(nil);
  1227. cmEditorOptions : EditorOptions(Event.InfoPtr);
  1228. cmCodeTemplateOptions: CodeTemplates;
  1229. cmCodeCompleteOptions: CodeComplete;
  1230. cmBrowser : BrowserOptions(nil);
  1231. cmBrowserOptions : BrowserOptions(Event.InfoPtr);
  1232. cmMouse : Mouse;
  1233. cmStartup : StartUp;
  1234. cmDesktopOptions: DesktopOptions;
  1235. cmColors : Colors;
  1236. {$ifdef Unix}
  1237. cmKeys : LearnKeysDialog;
  1238. {$endif Unix}
  1239. cmOpenINI : OpenINI;
  1240. cmSaveINI : SaveINI;
  1241. cmSaveAsINI : SaveAsINI;
  1242. { -- Tools menu -- }
  1243. cmToolsMessages : Messages;
  1244. cmCalculator : Calculator;
  1245. cmAsciiTable : DoAsciiTable;
  1246. cmGrep : DoGrep;
  1247. cmToolsBase+1..
  1248. cmToolsBase+MaxToolCount
  1249. : ExecuteTool(Event.Command-cmToolsBase);
  1250. { -- Window menu -- }
  1251. cmCloseAll : CloseAll;
  1252. cmWindowList : WindowList;
  1253. cmUserScreenWindow: DoUserScreenWindow;
  1254. { -- Help menu -- }
  1255. cmHelp,
  1256. cmHelpContents : HelpContents;
  1257. cmHelpIndex : HelpHelpIndex;
  1258. cmHelpDebug : HelpDebugInfos;
  1259. cmHelpTopicSearch: HelpTopicSearch;
  1260. cmHelpPrevTopic : HelpPrevTopic;
  1261. cmHelpUsingHelp : HelpUsingHelp;
  1262. cmHelpFiles : HelpFiles;
  1263. cmAbout : About;
  1264. cmShowReadme : ShowReadme;
  1265. cmResizeApp : ResizeApplication(Event.Id, Event.InfoWord);
  1266. cmQuitApp : Message(@Self, evCommand, cmQuit, nil);
  1267. else DontClear:=true;
  1268. end;
  1269. if DontClear=false then ClearEvent(Event);
  1270. end;
  1271. evBroadcast :
  1272. case Event.Command of
  1273. cmSaveCancelled :
  1274. SaveCancelled:=true;
  1275. cmUpdateTools :
  1276. UpdateTools;
  1277. cmCommandSetChanged :
  1278. UpdateMenu(MenuBar^.Menu);
  1279. cmUpdate :
  1280. Update;
  1281. cmSourceWndClosing :
  1282. begin
  1283. with PSourceWindow(Event.InfoPtr)^ do
  1284. if Editor^.FileName<>'' then
  1285. AddRecentFile(Editor^.FileName,Editor^.CurPos.X,Editor^.CurPos.Y);
  1286. {$ifndef NODEBUG}
  1287. if assigned(Debugger) and (PView(Event.InfoPtr)=Debugger^.LastSource) then
  1288. Debugger^.LastSource:=nil;
  1289. {$endif}
  1290. end;
  1291. end;
  1292. end;
  1293. inherited HandleEvent(Event);
  1294. {$ifdef HasSignal}
  1295. { Reset flag if CrtlC was handled }
  1296. if CtrlCCatched and (Event.What=evNothing) then
  1297. begin
  1298. CtrlCPressed:=false;
  1299. {$ifdef DEBUG}
  1300. Writeln(stderr,'One CtrlC handled');
  1301. {$endif DEBUG}
  1302. end;
  1303. {$endif HasSignal}
  1304. end;
  1305. procedure TIDEApp.GetTileRect(var R: TRect);
  1306. begin
  1307. Desktop^.GetExtent(R);
  1308. { Leave the compiler messages window in the bottom }
  1309. if assigned(CompilerMessageWindow) and (CompilerMessageWindow^.GetState(sfVisible)) then
  1310. R.B.Y:=Min(CompilerMessageWindow^.Origin.Y,R.B.Y);
  1311. { Leave the messages window in the bottom }
  1312. if assigned(MessagesWindow) and (MessagesWindow^.GetState(sfVisible)) then
  1313. R.B.Y:=Min(MessagesWindow^.Origin.Y,R.B.Y);
  1314. {$ifndef NODEBUG}
  1315. { Leave the watch window in the bottom }
  1316. if assigned(WatchesWindow) and (WatchesWindow^.GetState(sfVisible)) then
  1317. R.B.Y:=Min(WatchesWindow^.Origin.Y,R.B.Y);
  1318. {$endif NODEBUG}
  1319. end;
  1320. {****************************************************************************
  1321. Switch Screens
  1322. ****************************************************************************}
  1323. procedure TIDEApp.ShowUserScreen;
  1324. begin
  1325. displaymode:=dmUser;
  1326. if Assigned(UserScreen) then
  1327. UserScreen^.SaveIDEScreen;
  1328. DoneSysError;
  1329. DoneEvents;
  1330. { DoneKeyboard should be called last to
  1331. restore the keyboard correctly PM }
  1332. {$ifndef go32v2}
  1333. donevideo;
  1334. {$endif ndef go32v2}
  1335. DoneKeyboard;
  1336. If UseMouse then
  1337. DoneMouse
  1338. else
  1339. ButtonCount:=0;
  1340. { DoneDosMem;}
  1341. if Assigned(UserScreen) then
  1342. UserScreen^.SwitchToConsoleScreen;
  1343. end;
  1344. procedure TIDEApp.ShowIDEScreen;
  1345. var oldH,oldW : byte;
  1346. begin
  1347. if Assigned(UserScreen) then
  1348. UserScreen^.SaveConsoleScreen;
  1349. { InitDosMem;}
  1350. InitKeyboard;
  1351. If UseMouse then
  1352. InitMouse
  1353. else
  1354. ButtonCount:=0;
  1355. oldH:=ScreenHeight;
  1356. oldW:=ScreenWidth;
  1357. {$ifndef go32v2}
  1358. initvideo;
  1359. {$endif ndef go32v2}
  1360. {Videobuffer has been reallocated, need passive video situation detection
  1361. again.}
  1362. initscreen;
  1363. {$ifdef Windows}
  1364. { write the empty screen to dummy console handle }
  1365. UpdateScreen(true);
  1366. {$endif ndef Windows}
  1367. InitEvents;
  1368. InitSysError;
  1369. CurDirChanged;
  1370. {$ifndef Windows}
  1371. if (oldH<>ScreenHeight) or (oldW<>ScreenWidth) then
  1372. begin
  1373. { acknowledge new screen dimensions }
  1374. { prevents to draw out of boundaries of new video buffer }
  1375. ResizeApplication(ScreenWidth,ScreenHeight);
  1376. end else
  1377. Message(Application,evBroadcast,cmUpdate,nil);
  1378. {$endif Windows}
  1379. {$ifdef Windows}
  1380. // WindowsShowMouse;
  1381. {$endif Windows}
  1382. if Assigned(UserScreen) then
  1383. {$ifdef unix}
  1384. if (oldH=ScreenHeight) and (oldW=ScreenWidth) then
  1385. {$endif unix}
  1386. UserScreen^.SwitchBackToIDEScreen;
  1387. {$ifdef Windows}
  1388. { This message was sent when the VideoBuffer was smaller
  1389. than was the IdeApp thought => writes to random memory and random crashes... PM }
  1390. Message(Application,evBroadcast,cmUpdate,nil);
  1391. {$endif Windows}
  1392. {$ifdef Unix}
  1393. SetKnownKeys;
  1394. {$endif Unix}
  1395. {$ifndef Windows}
  1396. {$ifndef go32v2}
  1397. UpdateScreen(true);
  1398. {$endif go32v2}
  1399. {$endif Windows}
  1400. displaymode:=dmIDE;
  1401. end;
  1402. function TIDEApp.AutoSave: boolean;
  1403. var IOK,SOK,DOK: boolean;
  1404. begin
  1405. IOK:=true; SOK:=true; DOK:=true;
  1406. if (AutoSaveOptions and asEnvironment)<>0 then
  1407. begin
  1408. IOK:=WriteINIFile(false);
  1409. if IOK=false then
  1410. ErrorBox(error_saving_cfg_file,nil);
  1411. end;
  1412. if (AutoSaveOptions and asEditorFiles)<>0 then { was a typo here ("=0") - Gabor }
  1413. SOK:=SaveAll;
  1414. if (AutoSaveOptions and asDesktop)<>0 then
  1415. begin
  1416. { destory all help & browser windows - we don't want to store them }
  1417. { UserScreenWindow is also not registered PM }
  1418. DoCloseUserScreenWindow;
  1419. {$IFNDEF NODEBUG}
  1420. DoneDisassemblyWindow;
  1421. {$ENDIF}
  1422. CloseHelpWindows;
  1423. CloseAllBrowsers;
  1424. DOK:=SaveDesktop;
  1425. if DOK=false then
  1426. ErrorBox(error_saving_dsk_file,nil);
  1427. end;
  1428. AutoSave:=IOK and SOK and DOK;
  1429. end;
  1430. function TIDEApp.DoExecute(ProgramPath, Params, InFile,OutFile,ErrFile: string; ExecType: TExecType): boolean;
  1431. var CanRun: boolean;
  1432. ConsoleMode : TConsoleMode;
  1433. {$ifndef Unix}
  1434. PosExe: sw_integer;
  1435. {$endif Unix}
  1436. begin
  1437. SaveCancelled:=false;
  1438. CanRun:=AutoSave;
  1439. if (CanRun=false) and (SaveCancelled=false) then
  1440. CanRun:=true; { do not care about .DSK or .INI saving problems - just like TP }
  1441. if CanRun then
  1442. begin
  1443. if UserScreen=nil then
  1444. begin
  1445. ErrorBox(error_user_screen_not_avail,nil);
  1446. Exit;
  1447. end;
  1448. if ExecType<>exNoSwap then
  1449. ShowUserScreen;
  1450. SaveConsoleMode(ConsoleMode);
  1451. if ExecType=exDosShell then
  1452. WriteShellMsg
  1453. else if ExecType<>exNoSwap then
  1454. Writeln('Running "'+ProgramPath+' '+Params+'"');
  1455. { DO NOT use COMSPEC for exe files as the
  1456. ExitCode is lost in those cases PM }
  1457. {$ifdef HASAMIGA}
  1458. DosExecute(ProgramPath, Params);
  1459. {$else}
  1460. {$ifndef Unix}
  1461. posexe:=Pos('.EXE',UpCaseStr(ProgramPath));
  1462. { if programpath was three AnsiChar long => bug }
  1463. if (posexe>0) and (posexe=Length(ProgramPath)-3) then
  1464. begin
  1465. {$endif Unix}
  1466. if (InFile='') and (OutFile='') and (ErrFile='') then
  1467. DosExecute(ProgramPath,Params)
  1468. else
  1469. begin
  1470. if ErrFile='' then
  1471. ErrFile:='stderr';
  1472. ExecuteRedir(ProgramPath,Params,InFile,OutFile,ErrFile);
  1473. end;
  1474. {$ifndef Unix}
  1475. end
  1476. else if (InFile='') and (OutFile='') and (ErrFile='') then
  1477. DosExecute(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params)
  1478. else
  1479. begin
  1480. if ErrFile='' then
  1481. ErrFile:='stderr';
  1482. ExecuteRedir(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params,
  1483. InFile,OutFile,ErrFile);
  1484. end;
  1485. {$endif Unix}
  1486. {$endif HASAMIGA}
  1487. {$ifdef Unix}
  1488. if (DebuggeeTTY='') and (OutFile='') and (ExecType<>exDosShell) then
  1489. begin
  1490. Write(' Press any key to return to IDE');
  1491. InitKeyBoard;
  1492. Keyboard.GetKeyEvent;
  1493. while (Keyboard.PollKeyEvent<>0) do
  1494. Keyboard.GetKeyEvent;
  1495. DoneKeyboard;
  1496. end;
  1497. {$endif}
  1498. RestoreConsoleMode(ConsoleMode);
  1499. if ExecType<>exNoSwap then
  1500. ShowIDEScreen;
  1501. end;
  1502. DoExecute:=CanRun;
  1503. end;
  1504. procedure TIDEApp.Update;
  1505. begin
  1506. SetCmdState([cmSaveAll],IsThereAnyEditor);
  1507. SetCmdState([cmCloseAll,cmWindowList],IsThereAnyWindow);
  1508. SetCmdState([cmTile,cmCascade],IsThereAnyVisibleEditorWindow);
  1509. SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals,cmSymbol],IsSymbolInfoAvailable);
  1510. {$ifndef NODEBUG}
  1511. SetCmdState([cmResetDebugger,cmUntilReturn],assigned(debugger) and debugger^.debuggee_started);
  1512. {$endif}
  1513. SetCmdState([cmToolsMsgNext,cmToolsMsgPrev],MessagesWindow<>nil);
  1514. UpdateTools;
  1515. UpdateRecentFileList;
  1516. UpdatePrimaryFile;
  1517. UpdateINIFile;
  1518. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  1519. application^.redraw;
  1520. end;
  1521. procedure TIDEApp.SourceWindowClosed;
  1522. begin
  1523. if not IsClosing then
  1524. Update;
  1525. end;
  1526. procedure TIDEApp.CurDirChanged;
  1527. begin
  1528. Message(Application,evBroadcast,cmUpdateTitle,nil);
  1529. UpdatePrimaryFile;
  1530. UpdateINIFile;
  1531. UpdateMenu(MenuBar^.Menu);
  1532. end;
  1533. procedure TIDEApp.UpdatePrimaryFile;
  1534. begin
  1535. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmPrimaryFile),SmartPath(PrimaryFile));
  1536. SetCmdState([cmClearPrimary],PrimaryFile<>'');
  1537. if PrimaryFile<>'' then
  1538. SetCmdState(CompileCmds,true);
  1539. UpdateMenu(MenuBar^.Menu);
  1540. end;
  1541. procedure TIDEApp.UpdateINIFile;
  1542. begin
  1543. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(IniFileName));
  1544. end;
  1545. procedure TIDEApp.UpdateRecentFileList;
  1546. var P: PMenuItem;
  1547. {ID,}I: word;
  1548. FileMenu: PMenuItem;
  1549. R: TRect;
  1550. AdjustRecentCount : word;
  1551. begin
  1552. if not assigned(MenuBar) then exit;
  1553. { ID:=cmRecentFileBase;}
  1554. FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
  1555. repeat
  1556. { Inc(ID);
  1557. P:=SearchMenuItem(FileMenu^.SubMenu,ID);
  1558. if FileMenu^.SubMenu^.Default=P then
  1559. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  1560. if P<>nil then RemoveMenuItem(FileMenu^.SubMenu,P);}
  1561. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  1562. if (P<>nil) then
  1563. begin
  1564. if (cmRecentFileBase<P^.Command) and (P^.Command<=cmRecentFileBase+MaxRecentFileCount) then
  1565. begin
  1566. RemoveMenuItem(FileMenu^.SubMenu,P);
  1567. if FileMenu^.SubMenu^.Default=P then
  1568. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  1569. end
  1570. else
  1571. P:=nil;
  1572. end;
  1573. until P=nil;
  1574. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  1575. if (P<>nil) and IsSeparator(P) then
  1576. RemoveMenuItem(FileMenu^.SubMenu,P);
  1577. GetExtent(R);
  1578. AdjustRecentCount :=0;
  1579. {calculate how much lines on screen for reacent files can be used }
  1580. if r.b.y-r.a.y -19 > 0 then AdjustRecentCount:=r.b.y-r.a.y -19;
  1581. {only if there is enough space then show all reacent files }
  1582. {else cut list shorter }
  1583. if RecentFileCount < AdjustRecentCount then
  1584. AdjustRecentCount:=RecentFileCount;
  1585. if AdjustRecentCount>0 then
  1586. begin
  1587. AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
  1588. for I:=1 to AdjustRecentCount do
  1589. begin
  1590. P:=NewItem('~'+IntToStr(I)+'~ '+ShrinkPath(SmartPath(RecentFiles[I].FileName),27),' ',
  1591. kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
  1592. AppendMenuItem(FileMenu^.SubMenu,P);
  1593. end;
  1594. end;
  1595. end;
  1596. procedure TIDEApp.UpdateTools;
  1597. var P: PMenuItem;
  1598. { ID,}I: word;
  1599. ToolsMenu: PMenuItem;
  1600. S1,S2,S3: string;
  1601. W: word;
  1602. begin
  1603. { ID:=cmToolsBase;}
  1604. ToolsMenu:=SearchSubMenu(MenuBar^.Menu,menuTools);
  1605. repeat
  1606. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  1607. if (P<>nil) then
  1608. begin
  1609. if (cmToolsBase<P^.Command) and (P^.Command<=cmToolsBase+MaxToolCount) then
  1610. begin
  1611. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  1612. if ToolsMenu^.SubMenu^.Default=P then
  1613. ToolsMenu^.SubMenu^.Default:=ToolsMenu^.SubMenu^.Items;
  1614. end
  1615. else
  1616. P:=nil;
  1617. end;
  1618. until P=nil;
  1619. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  1620. if (P<>nil) and IsSeparator(P) then
  1621. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  1622. if GetToolCount>0 then
  1623. AppendMenuItem(ToolsMenu^.SubMenu,NewLine(nil));
  1624. for I:=1 to GetToolCount do
  1625. begin
  1626. GetToolParams(I-1,S1,S2,S3,W);
  1627. P:=NewItem(S1,KillTilde(GetHotKeyName(W)),W,cmToolsBase+I,hcToolsBase+I,nil);
  1628. AppendMenuItem(ToolsMenu^.SubMenu,P);
  1629. end;
  1630. end;
  1631. procedure TIDEApp.DosShell;
  1632. var
  1633. s : string;
  1634. begin
  1635. {$ifdef HASAMIGA}
  1636. s := 'C:NewShell';
  1637. {$else}
  1638. {$ifdef Unix}
  1639. s:=GetEnv('SHELL');
  1640. if s='' then
  1641. if ExistsFile('/bin/sh') then
  1642. s:='/bin/sh';
  1643. {$else}
  1644. s:=GetEnv('COMSPEC');
  1645. if s='' then
  1646. if ExistsFile('c:\command.com') then
  1647. s:='c:\command.com'
  1648. else
  1649. begin
  1650. s:='command.com';
  1651. if Not LocateExeFile(s) then
  1652. s:='';
  1653. end;
  1654. {$endif}
  1655. {$endif}
  1656. if s='' then
  1657. ErrorBox(msg_errorexecutingshell,nil)
  1658. else
  1659. DoExecute(s, '', '', '', '', exDosShell);
  1660. { In case we have something that the compiler touched }
  1661. AskToReloadAllModifiedFiles;
  1662. end;
  1663. procedure TIDEApp.ShowReadme;
  1664. var R,R2: TRect;
  1665. D: PCenterDialog;
  1666. M: PFPMemo;
  1667. VSB: PScrollBar;
  1668. S: PFastBufStream;
  1669. begin
  1670. New(S, Init(ReadmeName, stOpenRead, 4096));
  1671. if S^.Status=stOK then
  1672. begin
  1673. R.Assign(0,0,63,18);
  1674. New(D, Init(R, 'Free Pascal IDE'));
  1675. with D^ do
  1676. begin
  1677. GetExtent(R);
  1678. R.Grow(-2,-2); Inc(R.B.Y);
  1679. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  1680. New(VSB, Init(R2)); VSB^.GrowMode:=0; Insert(VSB);
  1681. New(M, Init(R,nil,VSB,nil));
  1682. M^.LoadFromStream(S);
  1683. M^.ReadOnly:=true;
  1684. Insert(M);
  1685. end;
  1686. InsertOK(D);
  1687. ExecuteDialog(D,nil);
  1688. end;
  1689. Dispose(S, Done);
  1690. end;
  1691. {$I FPMFILE.INC}
  1692. {$I FPMEDIT.INC}
  1693. {$I FPMSRCH.INC}
  1694. {$I FPMRUN.INC}
  1695. {$I FPMCOMP.INC}
  1696. {$I FPMDEBUG.INC}
  1697. {$I FPMTOOLS.INC}
  1698. {$I FPMOPTS.INC}
  1699. {$I FPMWND.INC}
  1700. {$I FPMHELP.INC}
  1701. {$I fpmansi.inc}
  1702. procedure TIDEApp.AddRecentFile(AFileName: string; CurX, CurY: sw_integer);
  1703. begin
  1704. if SearchRecentFile(AFileName)<>-1 then Exit;
  1705. if RecentFileCount>0 then
  1706. Move(RecentFiles[1],RecentFiles[2],SizeOf(RecentFiles[1])*Min(RecentFileCount,High(RecentFiles)-1));
  1707. if RecentFileCount<High(RecentFiles) then Inc(RecentFileCount);
  1708. with RecentFiles[1] do
  1709. begin
  1710. FileName:=AFileName;
  1711. LastPos.X:=CurX; LastPos.Y:=CurY;
  1712. end;
  1713. UpdateRecentFileList;
  1714. end;
  1715. function TIDEApp.SearchRecentFile(AFileName: string): integer;
  1716. var Idx,I: integer;
  1717. begin
  1718. Idx:=-1;
  1719. for I:=1 to RecentFileCount do
  1720. if UpcaseStr(AFileName)=UpcaseStr(RecentFiles[I].FileName) then
  1721. begin Idx:=I; Break; end;
  1722. SearchRecentFile:=Idx;
  1723. end;
  1724. procedure TIDEApp.RemoveRecentFile(Index: integer);
  1725. begin
  1726. if Index<RecentFileCount then
  1727. Move(RecentFiles[Index+1],RecentFiles[Index],SizeOf(RecentFiles[1])*(RecentFileCount-Index));
  1728. Dec(RecentFileCount);
  1729. UpdateRecentFileList;
  1730. end;
  1731. function TIDEApp.GetPalette: PPalette;
  1732. begin
  1733. GetPalette:=@AppPalette;
  1734. end;
  1735. function TIDEApp.IsClosing: Boolean;
  1736. begin
  1737. IsClosing:=InsideDone;
  1738. end;
  1739. destructor TIDEApp.Done;
  1740. begin
  1741. InsideDone:=true;
  1742. IsRunning:=false;
  1743. inherited Done;
  1744. Desktop:=nil;
  1745. RemoveBrowsersCollection;
  1746. DoneHelpSystem;
  1747. end;
  1748. end.