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