fpide.pas 69 KB

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