fpide.pas 69 KB

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