fpide.pas 69 KB

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