fpide.pas 71 KB

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