fpide.pas 69 KB

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