fpide.pas 71 KB

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