fpide.pas 71 KB

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