fpide.pas 69 KB

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