fpide.pas 71 KB

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