fpide.pas 72 KB

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