/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51083 - (show annotations)
Sat May 14 10:52:10 2005 UTC (14 years, 9 months ago) by alexk
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 101363 byte(s)
Added line highlighting for CL_SYNTAX_STONE.

1 indexing
2 description : "Window holding a project tool"
3 date : "$Date$"
4 revision : "$Revision$"
5 author : "Arnaud PICHERY [ aranud@mail.dotcom.fr ]"
6
7 class
8 EB_DEVELOPMENT_WINDOW
9
10 inherit
11 EB_TOOL_MANAGER
12 redefine
13 make,
14 init_size_and_position,
15 window_displayed,
16 init_commands,
17 build_menu_bar,
18 build_menus,
19 build_file_menu,
20 build_edit_menu,
21 build_view_menu,
22 build_tools_menu,
23 build_favorites_menu,
24 refresh,
25 recycle,
26 destroy_imp,
27 destroy
28 end
29
30 EB_FILEABLE
31 redefine
32 set_stone,
33 reset,
34 stone,
35 on_text_saved,
36 perform_check_before_save,
37 check_passed,
38 update_save_symbol
39 select
40 set_stone
41 end
42
43 EB_FILEABLE
44 rename
45 set_stone as old_set_stone
46 export {NONE}
47 old_set_stone
48 redefine
49 reset,
50 stone,
51 on_text_saved,
52 perform_check_before_save,
53 check_passed,
54 update_save_symbol
55 end
56
57
58 -- Shared tools & contexts
59 SHARED_APPLICATION_EXECUTION
60
61 SHARED_EIFFEL_PROJECT
62
63 PROJECT_CONTEXT
64
65 EB_SHARED_MANAGERS
66
67 EB_SHARED_GRAPHICAL_COMMANDS
68
69 EB_SHARED_PREFERENCES
70 export
71 {NONE} all
72 end
73
74 EV_STOCK_PIXMAPS
75
76 EB_CONFIRM_SAVE_CALLBACK
77
78 -- Errors
79 EB_GRAPHICAL_ERROR_MANAGER
80
81 TEXT_OBSERVER
82 redefine
83 on_text_reset, on_text_edited,
84 on_text_back_to_its_last_saved_state,
85 on_text_fully_loaded, on_cursor_moved
86 end
87
88 EV_KEY_CONSTANTS
89 export
90 {NONE} All
91 end
92
93 EIFFEL_ENV
94 export
95 {NONE} All
96 end
97
98 SHARED_TEXT_ITEMS
99 export
100 {NONE} All
101 end
102
103 create {EB_WINDOW_MANAGER}
104 make,
105 make_as_context_tool,
106 make_as_editor
107
108 feature {NONE} -- Initialization
109
110 make_as_context_tool is
111 -- Create a new development window and expand the context tool.
112 do
113 make
114 -- Perform window setting from `show_actions', as the
115 -- resizing executed as a result only works correctly
116 -- while the window is displayed.
117 window.show_actions.extend (agent set_context_mode)
118 end
119
120 set_context_mode is
121 -- Set `current' into context mode, that is the context tool
122 -- maximized, and the non editor panel is hidden.
123 do
124 if not context_tool.shown then
125 context_tool.show
126 end
127 if not unified_stone then
128 toggle_stone_cmd.execute
129 end
130 context_tool.explorer_bar_item.maximize
131 close_all_bars_except (right_panel)
132 end
133
134 make_as_editor is
135 -- Create a new development window and expand the editor tool.
136 do
137 make
138 -- Perform window setting from `show_actions', as the resizing executed
139 -- must be performed after `current' is displayed.
140 window.show_actions.extend (agent (editor_tool.explorer_bar_item).maximize)
141 window.show_actions.extend (agent close_all_bars_except (right_panel))
142 end
143
144 make is
145 -- Create a new development window.
146 do
147 unified_stone := preferences.development_window_data.context_unified_stone
148 -- Build the history manager, the address manager, ...
149 create history_manager.make (Current)
150 create address_manager.make (Current, False)
151 build_formatters
152 address_manager.set_formatters (managed_main_formatters)
153
154 -- Init commands, build interface, build menus, ...
155 Precursor
156
157 initialized := False -- Reset the flag since initialization is not yet complete.
158 set_up_accelerators
159
160 -- Create the toolbars.
161 build_toolbars_area
162 container.put_front (toolbars_area)
163 container.disable_item_expand (toolbars_area)
164
165 -- Update widgets visibilities
166 window.show_actions.extend (agent update)
167 status_bar.remove_cursor_position
168 address_manager.set_output_line (status_bar.label)
169
170 -- Finish initializing the main editor formatters
171 end_build_formatters
172
173 address_manager.disable_formatters
174 if Eiffel_project.manager.is_project_loaded then
175 on_project_created
176 on_project_loaded
177 elseif Eiffel_project.manager.is_created then
178 on_project_unloaded
179 on_project_created
180 else
181 on_project_unloaded
182 end
183
184 -- Create feature position table
185 create feature_positions.make (1)
186 feature_positions.compare_objects
187
188 window.move_actions.force_extend (agent window_moved)
189
190 initialized := True
191 is_destroying := False
192 end
193
194 init_size_and_position is
195 -- Initialize window size.
196 local
197 default_width, default_height: INTEGER
198 screen: EV_SCREEN
199 do
200 create screen
201 default_width := preferences.development_window_data.width.min (screen.width)
202 default_height := preferences.development_window_data.height.min (screen.height)
203 window.set_size (default_width, default_height)
204 end
205
206 window_displayed is
207 -- `Current' has been displayed on screen.
208 do
209 -- Maximize window if needed.
210 if preferences.development_window_data.is_maximized then
211 window.maximize
212 end
213 end
214
215 init_commands is
216 -- Initialize commands.
217 local
218 accel: EV_ACCELERATOR
219 do
220 Precursor
221 create toolbarable_commands.make (15)
222
223 -- Open, save, ...
224 toolbarable_commands.extend (new_editor_cmd)
225
226 toolbarable_commands.extend (new_context_tool_cmd)
227
228 create open_cmd.make (Current)
229 toolbarable_commands.extend (open_cmd)
230
231 create save_cmd.make (Current)
232 toolbarable_commands.extend (save_cmd)
233
234 create save_as_cmd.make (Current)
235 if editor_tool = Void or else editor_tool.text_area.is_empty then
236 save_as_cmd.disable_sensitive
237 else
238 save_as_cmd.enable_sensitive
239 end
240
241 create shell_cmd.make (Current)
242 toolbarable_commands.extend (shell_cmd)
243
244 create print_cmd.make (Current)
245 if is_empty then
246 print_cmd.disable_sensitive
247 else
248 print_cmd.enable_sensitive
249 end
250 toolbarable_commands.extend (print_cmd)
251
252 -- Compilation
253 create c_workbench_compilation_cmd.make_workbench (Current)
254 create c_finalized_compilation_cmd.make_finalized (Current)
255 if has_dll_generation then
256 create show_dynamic_lib_tool.make
257 show_dynamic_lib_tool.set_menu_name (Interface_names.m_New_dynamic_lib)
258 show_dynamic_lib_tool.add_agent (agent show_dynamic_library_dialog)
259 end
260 if has_profiler then
261 create show_profiler
262 end
263
264 -- Undo/redo, cut, copy, paste.
265 create undo_cmd.make (Current)
266 toolbarable_commands.extend (undo_cmd)
267
268 create redo_cmd.make (Current)
269 toolbarable_commands.extend (redo_cmd)
270
271 create editor_paste_cmd.make (Current)
272 toolbarable_commands.extend (editor_paste_cmd)
273
274 create new_cluster_cmd.make (Current)
275 toolbarable_commands.extend (new_cluster_cmd)
276
277 create new_class_cmd.make (Current)
278 toolbarable_commands.extend (new_class_cmd)
279
280 create delete_class_cluster_cmd.make (Current)
281 toolbarable_commands.extend (delete_class_cluster_cmd)
282
283 create new_feature_cmd.make (Current)
284 toolbarable_commands.extend (new_feature_cmd)
285
286 create toggle_feature_signature_cmd.make (Current)
287 toolbarable_commands.extend (toggle_feature_signature_cmd)
288
289 create toggle_stone_cmd.make (Current)
290 toolbarable_commands.extend (toggle_stone_cmd)
291
292 create send_stone_to_context_cmd.make
293 send_stone_to_context_cmd.set_pixmaps (Pixmaps.Icon_send_stone_down)
294 send_stone_to_context_cmd.set_tooltip (Interface_names.e_Send_stone_to_context)
295 send_stone_to_context_cmd.set_menu_name (Interface_names.m_Send_stone_to_context)
296 send_stone_to_context_cmd.set_name ("Send_to_context")
297 send_stone_to_context_cmd.set_tooltext (Interface_names.b_Send_stone_to_context)
298 send_stone_to_context_cmd.add_agent (agent send_stone_to_context)
299 create accel.make_with_key_combination (
300 create {EV_KEY}.make_with_code (Kcst.Key_down), False, True, False
301 )
302 accel.actions.extend (agent send_stone_to_context)
303 send_stone_to_context_cmd.set_accelerator (accel)
304 send_stone_to_context_cmd.disable_sensitive
305 toolbarable_commands.extend (send_stone_to_context_cmd)
306
307 toolbarable_commands.extend (window_manager.minimize_all_cmd)
308 window_manager.minimize_all_cmd.enable_sensitive
309 toolbarable_commands.extend (window_manager.raise_all_cmd)
310 window_manager.raise_all_cmd.enable_sensitive
311
312 toolbarable_commands.extend (New_development_window_cmd)
313 -- Show tool/toolbar commands (will be filled when tools will
314 -- be created)
315 create show_tool_commands.make (7)
316 create show_toolbar_commands.make (3)
317
318 new_feature_cmd.disable_sensitive
319 toggle_feature_signature_cmd.disable_sensitive
320
321 create editors.make (5)
322 end
323
324 set_up_accelerators is
325 -- Fill the accelerator of `window' with the accelerators of the `toolbarable_commands'.
326 do
327 from
328 toolbarable_commands.start
329 until
330 toolbarable_commands.after
331 loop
332 if toolbarable_commands.item.accelerator /= Void then
333 window.accelerators.extend (toolbarable_commands.item.accelerator)
334 end
335 toolbarable_commands.forth
336 end
337
338 from
339 debugger_manager.toolbarable_commands.start
340 until
341 debugger_manager.toolbarable_commands.after
342 loop
343 if
344 debugger_manager.toolbarable_commands.item.accelerator /= Void
345 then
346 window.accelerators.extend (debugger_manager.toolbarable_commands.item.accelerator)
347 end
348 debugger_manager.toolbarable_commands.forth
349 end
350 end
351
352 build_formatters is
353 -- Build all formatters used.
354 local
355 form: EB_CLASS_TEXT_FORMATTER
356 accel: EV_ACCELERATOR
357 do
358 create managed_class_formatters.make (17)
359 managed_class_formatters.extend (create {EB_CLICKABLE_FORMATTER}.make (Current))
360 managed_class_formatters.extend (create {EB_FLAT_FORMATTER}.make (Current))
361 managed_class_formatters.extend (create {EB_SHORT_FORMATTER}.make (Current))
362 managed_class_formatters.extend (create {EB_FLAT_SHORT_FORMATTER}.make (Current))
363 managed_class_formatters.extend (Void)
364 managed_class_formatters.extend (create {EB_ANCESTORS_FORMATTER}.make (Current))
365 managed_class_formatters.extend (create {EB_DESCENDANTS_FORMATTER}.make (Current))
366 managed_class_formatters.extend (create {EB_CLIENTS_FORMATTER}.make (Current))
367 managed_class_formatters.extend (create {EB_SUPPLIERS_FORMATTER}.make (Current))
368 managed_class_formatters.extend (Void)
369 managed_class_formatters.extend (create {EB_ATTRIBUTES_FORMATTER}.make (Current))
370 managed_class_formatters.extend (create {EB_ROUTINES_FORMATTER}.make (Current))
371 managed_class_formatters.extend (create {EB_DEFERREDS_FORMATTER}.make (Current))
372 managed_class_formatters.extend (create {EB_ONCES_FORMATTER}.make (Current))
373 managed_class_formatters.extend (create {EB_EXTERNALS_FORMATTER}.make (Current))
374 managed_class_formatters.extend (create {EB_EXPORTED_FORMATTER}.make (Current))
375
376 create managed_feature_formatters.make (12)
377 managed_feature_formatters.extend (create {EB_BASIC_FEATURE_FORMATTER}.make (Current))
378 managed_feature_formatters.extend (create {EB_ROUTINE_FLAT_FORMATTER}.make (Current))
379 managed_feature_formatters.extend (Void)
380 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current, 0))
381 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current,
382 {DEPEND_UNIT}.is_in_assignment_flag))
383 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current,
384 {DEPEND_UNIT}.is_in_creation_flag))
385 managed_feature_formatters.extend (Void)
386 managed_feature_formatters.extend (create {EB_IMPLEMENTERS_FORMATTER}.make (Current))
387 managed_feature_formatters.extend (create {EB_ROUTINE_ANCESTORS_FORMATTER}.make (Current))
388 managed_feature_formatters.extend (create {EB_ROUTINE_DESCENDANTS_FORMATTER}.make (Current))
389 managed_feature_formatters.extend (Void)
390 managed_feature_formatters.extend (create {EB_HOMONYMS_FORMATTER}.make (Current))
391
392
393 create managed_main_formatters.make (6)
394
395
396 create {EB_BASIC_TEXT_FORMATTER} form.make (Current)
397 create accel.make_with_key_combination (
398 create {EV_KEY}.make_with_code (Kcst.Key_t),
399 True, False, True)
400 accel.actions.extend (agent form.execute)
401 form.set_accelerator (accel)
402 managed_main_formatters.extend (form)
403
404 create {EB_CLICKABLE_FORMATTER} form.make (Current)
405 create accel.make_with_key_combination (
406 create {EV_KEY}.make_with_code (Kcst.Key_c),
407 True, False, True)
408 accel.actions.extend (agent form.execute)
409 form.set_accelerator (accel)
410 managed_main_formatters.extend (form)
411
412 create {EB_FLAT_FORMATTER} form.make (Current)
413 create accel.make_with_key_combination (
414 create {EV_KEY}.make_with_code (Kcst.Key_f),
415 True, False, True)
416 accel.actions.extend (agent form.execute)
417 form.set_accelerator (accel)
418 managed_main_formatters.extend (form)
419
420 create {EB_SHORT_FORMATTER} form.make (Current)
421 create accel.make_with_key_combination (
422 create {EV_KEY}.make_with_code (Kcst.Key_o),
423 True, False, True)
424 accel.actions.extend (agent form.execute)
425 form.set_accelerator (accel)
426 managed_main_formatters.extend (form)
427
428 create {EB_FLAT_SHORT_FORMATTER} form.make (Current)
429 create accel.make_with_key_combination (
430 create {EV_KEY}.make_with_code (Kcst.Key_i),
431 True, False, True)
432 accel.actions.extend (agent form.execute)
433 form.set_accelerator (accel)
434 managed_main_formatters.extend (form)
435 end
436
437 end_build_formatters is
438 -- Finish initialization of formatters (associate them with editor
439 -- and select a formatter).
440 local
441 f_ind: INTEGER
442 do
443 from
444 managed_class_formatters.start
445 until
446 managed_class_formatters.after
447 loop
448 if managed_class_formatters.item /= Void then
449 managed_class_formatters.item.set_manager (context_tool)
450 end
451 managed_class_formatters.forth
452 end
453 from
454 managed_feature_formatters.start
455 until
456 managed_feature_formatters.after
457 loop
458 if managed_feature_formatters.item /= Void then
459 managed_feature_formatters.item.set_manager (context_tool)
460 end
461 managed_feature_formatters.forth
462 end
463 from
464 managed_main_formatters.start
465 until
466 managed_main_formatters.after
467 loop
468 managed_main_formatters.item.set_editor (editor_tool.text_area)
469 managed_main_formatters.item.on_shown
470 if managed_main_formatters.item.accelerator /= Void then
471 window.accelerators.extend (managed_main_formatters.item.accelerator)
472 end
473 managed_main_formatters.forth
474 end
475
476 (managed_main_formatters @ 1).enable_select;
477
478 -- We now select the correct class formatter.
479 f_ind := preferences.formatter_data.default_class_formatter_index
480 --| This takes the formatter separators in consideration.
481 if f_ind > 4 then
482 f_ind := f_ind + 1
483 end
484 if f_ind > 8 then
485 f_ind := f_ind + 1
486 end
487 if f_ind < 1 or f_ind > managed_class_formatters.count then
488 f_ind := 6
489 end
490 (managed_class_formatters @ f_ind).enable_select;
491 -- We now select the correct feature formatter.
492 f_ind := preferences.formatter_data.default_feature_formatter_index
493 if f_ind > 2 then
494 f_ind := f_ind + 1
495 end
496 if f_ind < 1 or f_ind > managed_feature_formatters.count then
497 f_ind := 2
498 end
499 managed_class_formatters.i_th (f_ind).enable_select
500 end
501
502 build_tools is
503 -- Build all tools that can take place in this window and put them
504 -- in `left_tools' or `bottom_tools'.
505 local
506 show_cmd: EB_SHOW_TOOL_COMMAND
507 do
508 lock_update
509 -- Build the features tool
510 create features_tool.make (Current)
511 features_tool.attach_to_explorer_bar (left_panel)
512 left_tools.extend (features_tool.explorer_bar_item)
513 create show_cmd.make (Current, features_tool.explorer_bar_item)
514 show_tool_commands.extend (show_cmd)
515 toolbarable_commands.extend (show_cmd)
516 add_recyclable (features_tool)
517
518 -- Build the cluster tool
519 create cluster_tool.make (Current, Current)
520 cluster_tool.attach_to_explorer_bar (left_panel)
521 left_tools.extend (cluster_tool.explorer_bar_item)
522 create show_cmd.make (Current, cluster_tool.explorer_bar_item)
523 show_tool_commands.extend (show_cmd)
524 toolbarable_commands.extend (show_cmd)
525 add_recyclable (cluster_tool)
526
527 -- Build the favorites tool
528 create favorites_tool.make (Current, favorites_manager)
529 favorites_tool.attach_to_explorer_bar (left_panel)
530 left_tools.extend (favorites_tool.explorer_bar_item)
531 create show_cmd.make (Current, favorites_tool.explorer_bar_item)
532 show_tool_commands.extend (show_cmd)
533 toolbarable_commands.extend (show_cmd)
534 add_recyclable (favorites_tool)
535
536 -- Build the windows tool (formerly known as Selector tool)
537 create windows_tool.make (Current)
538 windows_tool.attach_to_explorer_bar (left_panel)
539 left_tools.extend (windows_tool.explorer_bar_item)
540 create show_cmd.make (Current, windows_tool.explorer_bar_item)
541 show_tool_commands.extend (show_cmd)
542 toolbarable_commands.extend (show_cmd)
543 add_recyclable (windows_tool)
544
545 -- Build the search tool
546 create search_tool.make (Current)
547 search_tool.attach_to_explorer_bar (left_panel)
548 left_tools.extend (search_tool.explorer_bar_item)
549 create show_cmd.make (Current, search_tool.explorer_bar_item)
550 show_tool_commands.extend (show_cmd)
551 toolbarable_commands.extend (show_cmd)
552 add_recyclable (search_tool)
553
554 -- Build the editor tool
555 create editor_tool.make (Current)
556 editor_tool.attach_to_explorer_bar (right_panel)
557 bottom_tools.extend (editor_tool.explorer_bar_item)
558 editor_tool.text_area.add_edition_observer(save_cmd)
559 editor_tool.text_area.add_edition_observer(save_as_cmd)
560 editor_tool.text_area.add_edition_observer(print_cmd)
561 editor_tool.text_area.add_edition_observer(Current)
562 editor_tool.text_area.drop_actions.set_veto_pebble_function (agent can_drop)
563 editor_tool.text_area.add_cursor_observer (Current)
564
565 -- The minimim height masks a bug on windows to do with the sizing of the editors
566 -- scroll bars, which were affecting the resizing although they should not have done so.
567 -- Having a default minimum height on the editor is perfectly reasonable.
568 editor_tool.widget.set_minimum_height (20)
569 add_recyclable (editor_tool)
570
571 -- Build the context tool
572 create context_tool.make (Current)
573 context_tool.attach_to_explorer_bar (right_panel)
574 bottom_tools.extend (context_tool.explorer_bar_item)
575 create show_cmd.make (Current, context_tool.explorer_bar_item)
576 show_tool_commands.extend (show_cmd)
577 toolbarable_commands.extend (show_cmd)
578 add_recyclable (context_tool)
579
580 -- Set the flag "Tools initialized"
581 tools_initialized := True
582
583 -- Initialize undo / redo accelerators
584 create undo_accelerator.make_with_key_combination (create {EV_KEY}.make_with_code (Key_z), True, False, False)
585 if has_case then
586 undo_accelerator.actions.extend (agent (context_tool.editor.undo_cmd).on_ctrl_z)
587 end
588 undo_accelerator.actions.extend (agent undo_cmd.accelerator_execute)
589 create redo_accelerator.make_with_key_combination (create {EV_KEY}.make_with_code (Key_y), True, False, False)
590 if has_case then
591 redo_accelerator.actions.extend (agent (context_tool.editor.redo_cmd).on_ctrl_y)
592 end
593 redo_accelerator.actions.extend (agent redo_cmd.accelerator_execute)
594 window.accelerators.extend (undo_accelerator)
595 window.accelerators.extend (redo_accelerator)
596 unlock_update
597 end
598
599 feature -- Access
600
601 cluster: CLUSTER_I is
602 -- Cluster for current class. Void if none.
603 local
604 classi_stone: CLASSI_STONE
605 cluster_stone: CLUSTER_STONE
606 do
607 classi_stone ?= stone
608 if classi_stone /= Void then
609 Result := classi_stone.cluster
610 end
611 cluster_stone ?= stone
612 if cluster_stone /= Void then
613 Result := cluster_stone.cluster_i
614 end
615 end
616
617 class_name: STRING is
618 -- Name of the current class, Void if none.
619 local
620 class_stone: CLASSI_STONE
621 do
622 class_stone ?= stone
623 if class_stone /= Void then
624 Result := class_stone.class_name
625 end
626 end
627
628 feature_name: STRING is
629 -- Name of the current feature, Void if none.
630 local
631 feature_stone: FEATURE_STONE
632 do
633 feature_stone ?= stone
634 if feature_stone /= Void then
635 Result := feature_stone.feature_name
636 end
637 end
638
639 feature -- Status setting
640
641 disable_sensitive is
642 -- Disable sensitivity of all widgets.
643 do
644 window.disable_sensitive
645 end
646
647 enable_sensitive is
648 -- Enable sensitivity of all widgets.
649 do
650 window.enable_sensitive
651 end
652
653 feature -- Window Settings
654
655 set_initialized is
656 -- Set `initialized' to True.
657 do
658 initialized := True
659 end
660
661 set_text (a_text: STRING) is
662 -- Assign `a_text' to `text'.
663 require
664 a_text_not_void: a_text /= Void
665 do
666 editor_tool.text_area.set_editor_text (a_text)
667 ensure
668 --| FIXME This needs to work: text_assigned: text.is_equal (a_text)
669 --| FIXME changed_flag_set: changed
670 end
671
672 feature -- Window Properties
673
674 changed: BOOLEAN is
675 -- Has something been changed and not yet been saved?
676 do
677 Result := editor_tool.changed
678 end
679
680 is_empty: BOOLEAN is
681 -- Does `Current's text is empty?
682 do
683 Result := editor_tool = Void or else editor_tool.text_area.is_empty
684 end
685
686 text: STRING is
687 -- Text representing Current
688 do
689 Result := editor_tool.text_area.text
690 end
691
692 pixmap: EV_PIXMAP is
693 -- Pixmap representing Current window.
694 do
695 Result := Pixmaps.Icon_development_window
696 end
697
698 preference_tool_is_hidden: BOOLEAN
699 -- Is the preference tool hidden?
700
701 profile_tool_is_hidden: BOOLEAN
702 -- Is the profile tool hidden?
703
704 has_argument_dialog: BOOLEAN is
705 -- Does Current have an associted arguments dialog?
706 do
707 Result := arguments_dialog /= Void
708 end
709
710 feature -- Pulldown Menus
711
712 metric_menu: EV_MENU
713 -- Menu for entries of metric tool.
714
715 format_menu: EV_MENU
716 -- ID Menu for formats.
717 -- Only used during debugging
718
719 compile_menu: EV_MENU
720 -- Compile ID menu.
721
722 debug_menu: EV_MENU
723 -- Debug ID menu.
724
725 active_menus (erase: BOOLEAN) is
726 -- Enable all the menus and if `erase' clean
727 -- the content of the Project tool.
728 do
729 compile_menu.enable_sensitive
730 if erase then
731 output_manager.clear
732 end
733 end
734
735 disable_menus is
736 -- Disable all the menus.
737 do
738 compile_menu.disable_sensitive
739 end
740
741 feature -- Modifiable menus
742
743 melt_menu_item: EV_MENU_ITEM
744 -- Melt menu entry
745
746 freeze_menu_item: EV_MENU_ITEM
747 -- Freeze menu entry
748
749 finalize_menu_item: EV_MENU_ITEM
750 -- Finalize menu entry
751
752 feature -- Update
753
754 synchronize is
755 -- Synchronize stones.
756 local
757 st: STONE
758 do
759 during_synchronization := True
760 favorites_manager.refresh
761 context_tool.synchronize
762 cluster_tool.synchronize
763 history_manager.synchronize
764 features_tool.synchronize
765 if stone /= Void then
766 st := stone.synchronized_stone
767 end
768 editor_tool.text_area.update_click_list (False)
769 set_stone (st)
770 update_save_symbol
771 address_manager.refresh
772 during_synchronization := False
773 end
774
775 synchronize_routine_tool_to_default is
776 -- Synchronize the editor tool to the debug format.
777 do
778 --| FIXME ARNAUD: To be implemented
779 end
780
781 clear_object_tool is
782 -- Clear the contents of the object tool if shown.
783 do
784 --| FIXME ARNAUD: To be implemented
785 end
786
787 build_menus is
788 -- Build all menus displayed in the development window.
789 do
790 -- Build each menu
791 build_file_menu
792 build_edit_menu
793 build_view_menu
794 build_favorites_menu
795 build_project_menu
796 build_debug_menu
797 build_tools_menu
798 build_window_menu
799 build_help_menu
800 -- Build the menu bar.
801 build_menu_bar
802 end
803
804 build_debug_menu is
805 -- Build the `Debug' menu through the debugger_manager.
806 local
807 conv_mit: EB_COMMAND_MENU_ITEM
808 do
809 debug_menu := debugger_manager.new_debug_menu
810 from
811 debug_menu.start
812 until
813 debug_menu.after
814 loop
815 conv_mit ?= debug_menu.item
816 if conv_mit /= Void then
817 add_recyclable (conv_mit)
818 end
819 debug_menu.forth
820 end
821 end
822
823 build_menu_bar is
824 -- Build the menu bar
825 local
826 mb: EV_MENU_BAR
827 do
828 check
829 window.menu_bar /= Void implies not window.menu_bar.is_empty
830 -- If a menu bar was already present, it shouldn't be empty.
831 end
832 if window.menu_bar /= Void then
833 mb := window.menu_bar
834 from
835 mb.start
836 mb.forth
837 until
838 mb.after
839 loop
840 mb.remove
841 end
842 else
843 create mb
844 window.set_menu_bar (mb)
845 mb.extend (file_menu)
846 end
847
848 if Eiffel_project.manager.is_created then
849 mb.extend (edit_menu)
850 mb.extend (view_menu)
851 mb.extend (favorites_menu)
852 mb.extend (project_menu)
853 mb.extend (debug_menu)
854 else
855 mb.extend (view_menu)
856 end
857 mb.extend (tools_menu)
858 mb.extend (window_menu)
859 mb.extend (help_menu)
860 end
861
862 feature -- Graphical Interface
863
864 build_general_toolbar is
865 -- Set up the general toolbar (New, Save, Search, Shell, Undo, Redo, ...)
866 local
867 cell: EV_CELL
868 hsep: EV_HORIZONTAL_SEPARATOR
869 hbox: EV_HORIZONTAL_BOX
870 do
871 -- Create the toolbar.
872 create general_toolbar
873 general_customizable_toolbar := preferences.development_window_data.retrieve_general_toolbar (toolbarable_commands)
874 if preferences.development_window_data.show_text_in_general_toolbar then
875 general_customizable_toolbar.enable_important_text
876 elseif preferences.development_window_data.show_all_text_in_general_toolbar then
877 general_customizable_toolbar.enable_text_displayed
878 end
879
880 create hbox
881 hbox.extend (general_customizable_toolbar.widget)
882 hbox.disable_item_expand (general_customizable_toolbar.widget)
883
884 -- Generate the toolbar.
885 general_customizable_toolbar.update_toolbar
886
887 -- Cell to fill in empty space and receive the right click menu holder.
888 create cell
889 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
890 hbox.extend (cell)
891
892 -- Create the vertical layout (separator + toolbar)
893 create hsep
894 general_toolbar.set_padding (2)
895 general_toolbar.extend (hsep)
896 general_toolbar.disable_item_expand (hsep)
897 general_toolbar.extend (hbox)
898
899 -- Create the command to show/hide this toolbar.
900 create show_general_toolbar_command.make (general_toolbar, Interface_names.m_General_toolbar)
901 show_toolbar_commands.extend (show_general_toolbar_command)
902 if preferences.development_window_data.show_general_toolbar then
903 show_general_toolbar_command.enable_visible
904 else
905 show_general_toolbar_command.disable_visible
906 end
907
908 end
909
910 build_address_toolbar is
911 -- Set up the address toolbar (Back, Forward, Current, Class name, feature name, ...)
912 local
913 tb: EV_TOOL_BAR
914 -- address_bar: EV_HORIZONTAL_BOX -- Contains "Class" + Combobox + "Feature" + Combobox + "Format" + Combobox
915 hsep: EV_HORIZONTAL_SEPARATOR
916 hbox: EV_HORIZONTAL_BOX -- Contains HistoryToolbar (back, forth, current) + `address_bar'
917 cell: EV_CELL
918 accel: EV_ACCELERATOR
919 do
920 -- Create the toolbar
921 create address_toolbar
922 create hsep
923 create hbox
924 -- create address_bar
925 create tb
926 address_toolbar.set_padding (2)
927 address_toolbar.extend (hsep)
928 address_toolbar.disable_item_expand (hsep)
929 address_toolbar.extend (hbox)
930
931 hbox.extend (tb)
932 hbox.disable_item_expand (tb)
933 -- hbox.extend (address_bar)
934 -- hbox.disable_item_expand (address_bar)
935
936 -- Back icon
937 tb.extend (history_manager.back_command.new_toolbar_item (False, False))
938
939 -- Forward icon
940 tb.extend (history_manager.forth_command.new_toolbar_item (False, False))
941
942 -- Set up the accelerators.
943 create accel.make_with_key_combination (
944 create {EV_KEY}.make_with_code (Kcst.Key_right), False, True, False
945 )
946 accel.actions.extend (agent on_forth)
947 window.accelerators.extend (accel)
948
949 create accel.make_with_key_combination (
950 create {EV_KEY}.make_with_code (Kcst.Key_left), False, True, False
951 )
952 accel.actions.extend (agent on_back)
953 window.accelerators.extend (accel)
954
955 ------------------------------------------
956 -- Address bar (Class name & feature name)
957 ------------------------------------------
958 hbox.extend (address_manager.widget)
959 -- editor_tool.text_area.add_cursor_observer (address_manager)
960
961 -- Create the command to show/hide this toolbar.
962 create show_address_toolbar_command.make (address_toolbar, Interface_names.m_Address_toolbar)
963 show_toolbar_commands.extend (show_address_toolbar_command)
964
965 if preferences.development_window_data.show_address_toolbar then
966 show_address_toolbar_command.enable_visible
967 else
968 show_address_toolbar_command.disable_visible
969 end
970
971 -- Cell to fill in empty space and receive the right click menu holder.
972 create cell
973 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
974 hbox.extend (cell)
975 end
976
977 build_project_toolbar is
978 -- Build toolbar corresponding to the project options bar
979 local
980 cell: EV_CELL
981 hsep: EV_HORIZONTAL_SEPARATOR
982 hbox: EV_HORIZONTAL_BOX
983 do
984 create project_toolbar
985 create hsep
986 project_toolbar.extend (hsep)
987 project_toolbar.disable_item_expand (hsep)
988
989 -- Generate the toolbar.
990 create hbox
991 project_customizable_toolbar := debugger_manager.new_toolbar
992 hbox.extend (project_customizable_toolbar.widget)
993 hbox.disable_item_expand (project_customizable_toolbar.widget)
994
995 project_customizable_toolbar.update_toolbar
996
997 -- Create the command to show/hide this toolbar.
998 create show_project_toolbar_command.make (project_toolbar, Interface_names.m_Project_toolbar)
999 show_toolbar_commands.extend (show_project_toolbar_command)
1000 if preferences.development_window_data.show_project_toolbar then
1001 show_project_toolbar_command.enable_visible
1002 else
1003 show_project_toolbar_command.disable_visible
1004 end
1005
1006 -- Cell to fill in empty space and receive the right click menu holder.
1007 create cell
1008 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
1009 hbox.extend (cell)
1010 project_toolbar.extend (hbox)
1011 end
1012
1013 feature {NONE} -- Menu Building
1014
1015 build_file_menu is
1016 -- Build the file menu.
1017 local
1018 new_project_cmd: EB_NEW_PROJECT_COMMAND
1019 open_project_cmd: EB_OPEN_PROJECT_COMMAND
1020 send_to_menu: EV_MENU
1021 menu_item: EV_MENU_ITEM
1022 command_menu_item: EB_COMMAND_MENU_ITEM
1023 do
1024 create file_menu.make_with_text (Interface_names.m_File)
1025
1026 -- New
1027 command_menu_item := New_development_window_cmd.new_menu_item
1028 add_recyclable (command_menu_item)
1029 file_menu.extend (command_menu_item)
1030
1031 -- New editor
1032 command_menu_item := New_editor_cmd.new_menu_item
1033 add_recyclable (command_menu_item)
1034 file_menu.extend (command_menu_item)
1035
1036 -- New context tool
1037 command_menu_item := New_context_tool_cmd.new_menu_item
1038 add_recyclable (command_menu_item)
1039 file_menu.extend (command_menu_item)
1040
1041 -- Open
1042 command_menu_item := open_cmd.new_menu_item
1043 add_recyclable (command_menu_item)
1044 file_menu.extend (command_menu_item)
1045
1046 -- Close
1047 create menu_item.make_with_text (Interface_names.m_Close)
1048 menu_item.select_actions.extend (agent destroy)
1049 file_menu.extend (menu_item)
1050
1051 -- Separator --------------------------------------
1052 file_menu.extend (create {EV_MENU_SEPARATOR})
1053
1054 -- Save
1055 command_menu_item := save_cmd.new_menu_item
1056 add_recyclable (command_menu_item)
1057 file_menu.extend (command_menu_item)
1058
1059 -- Save as
1060 command_menu_item := save_as_cmd.new_menu_item
1061 add_recyclable (command_menu_item)
1062 file_menu.extend (command_menu_item)
1063
1064 -- Sent to
1065 create send_to_menu.make_with_text (Interface_names.m_Send_to)
1066 -- External editor
1067 command_menu_item := shell_cmd.new_menu_item
1068 add_recyclable (command_menu_item)
1069 send_to_menu.extend (command_menu_item)
1070 file_menu.extend (send_to_menu)
1071
1072 -- Separator --------------------------------------
1073 file_menu.extend (create {EV_MENU_SEPARATOR})
1074 command_menu_item := print_cmd.new_menu_item
1075 add_recyclable (command_menu_item)
1076 file_menu.extend (command_menu_item)
1077
1078 -- Separator --------------------------------------
1079 file_menu.extend (create {EV_MENU_SEPARATOR})
1080
1081 -- New Project
1082 create new_project_cmd.make_with_parent (window)
1083 create menu_item.make_with_text (Interface_names.m_New_project)
1084 menu_item.select_actions.extend (agent new_project_cmd.execute)
1085 file_menu.extend (menu_item)
1086
1087 -- Open Project
1088 create open_project_cmd.make_with_parent (window)
1089 create menu_item.make_with_text (Interface_names.m_Open_project)
1090 menu_item.select_actions.extend (agent open_project_cmd.execute)
1091 file_menu.extend (menu_item)
1092
1093 -- Recent Projects
1094 recent_projects_menu := recent_projects_manager.new_menu
1095 add_recyclable (recent_projects_menu)
1096 file_menu.extend (recent_projects_menu)
1097
1098 -- Separator --------------------------------------
1099 file_menu.extend (create {EV_MENU_SEPARATOR})
1100
1101 -- Exit
1102 command_menu_item := Exit_application_cmd.new_menu_item
1103 add_recyclable (Command_menu_item)
1104 file_menu.extend (command_menu_item)
1105 end
1106
1107 build_class_info_menu: EV_MENU is
1108 -- Build the class format sub-menu.
1109 local
1110 form: EB_CLASS_INFO_FORMATTER
1111 empty_menu: EV_MENU_ITEM
1112 i: INTEGER
1113 do
1114 create Result.make_with_text (Interface_names.m_Class_info)
1115 i := 1
1116
1117 create empty_menu.make_with_text (Interface_names.m_Formatter_separators @ i)
1118 i := i + 1
1119 empty_menu.disable_sensitive
1120 Result.extend (empty_menu)
1121 from
1122 managed_class_formatters.start
1123 until
1124 managed_class_formatters.after
1125 loop
1126 form := managed_class_formatters.item
1127 if form /= Void then
1128 Result.extend (form.new_menu_item)
1129 else
1130 create empty_menu.make_with_text (Interface_names.m_Formatter_separators @ i)
1131 i := i + 1
1132 empty_menu.disable_sensitive
1133 Result.extend (empty_menu)
1134 end
1135 managed_class_formatters.forth
1136 end
1137 end
1138
1139 build_feature_info_menu: EV_MENU is
1140 -- Build the feature format sub-menu.
1141 local
1142 form: EB_FEATURE_INFO_FORMATTER
1143 do
1144 create Result.make_with_text (Interface_names.m_Feature_info)
1145 from
1146 managed_feature_formatters.start
1147 until
1148 managed_feature_formatters.after
1149 loop
1150 form := managed_feature_formatters.item
1151 if form /= Void then
1152 Result.extend (form.new_menu_item)
1153 end
1154 managed_feature_formatters.forth
1155 end
1156 end
1157
1158 build_edit_menu is
1159 -- Create and build `edit_menu'
1160 local
1161 command_menu_item: EB_COMMAND_MENU_ITEM
1162 sub_menu: EV_MENU
1163 cmd: EB_EDITOR_COMMAND
1164 os_cmd: EB_ON_SELECTION_COMMAND
1165 editor: EB_SMART_EDITOR
1166 do
1167 editor := editor_tool.text_area
1168 create command_controller.make
1169
1170 create edit_menu.make_with_text (Interface_names.m_Edit)
1171
1172 -- Undo
1173 command_menu_item := undo_cmd.new_menu_item
1174 add_recyclable (command_menu_item)
1175 edit_menu.extend (command_menu_item)
1176
1177 -- Redo
1178 command_menu_item := redo_cmd.new_menu_item
1179 add_recyclable (command_menu_item)
1180 edit_menu.extend (command_menu_item)
1181
1182 -- Separator --------------------------------------
1183 edit_menu.extend (create {EV_MENU_SEPARATOR})
1184
1185 -- Cut
1186 create os_cmd.make (Current)
1187 os_cmd.set_menu_name (Interface_names.M_cut)
1188 os_cmd.set_pixmaps (pixmaps.icon_cut)
1189 os_cmd.set_name ("Editor_cut")
1190 os_cmd.set_tooltip (interface_names.f_cut)
1191 os_cmd.add_agent (agent cut_selection)
1192 os_cmd.set_tooltext (Interface_names.b_Cut)
1193 toolbarable_commands.extend (os_cmd)
1194 os_cmd.set_needs_editable (True)
1195 command_controller.add_selection_command (os_cmd)
1196 command_menu_item := os_cmd.new_menu_item
1197 add_recyclable (command_menu_item)
1198 edit_menu.extend (command_menu_item)
1199
1200 -- Copy
1201 create os_cmd.make (Current)
1202 os_cmd.set_menu_name (Interface_names.M_copy)
1203 os_cmd.set_pixmaps (pixmaps.icon_copy)
1204 os_cmd.set_name ("Editor_copy")
1205 os_cmd.set_tooltip (interface_names.f_copy)
1206 os_cmd.set_tooltext (Interface_names.b_Copy)
1207 os_cmd.add_agent (agent copy_selection)
1208 toolbarable_commands.extend (os_cmd)
1209 os_cmd.set_needs_editable (False)
1210 command_controller.add_selection_command (os_cmd)
1211 command_menu_item := os_cmd.new_menu_item
1212 add_recyclable (command_menu_item)
1213 edit_menu.extend (command_menu_item)
1214
1215 -- Paste
1216 command_menu_item := editor_paste_cmd.new_menu_item
1217 add_recyclable (command_menu_item)
1218 edit_menu.extend (command_menu_item)
1219
1220 -- Separator --------------------------------------
1221 edit_menu.extend (create {EV_MENU_SEPARATOR})
1222
1223 -- Select all
1224 create cmd.make
1225 cmd.set_menu_name (Interface_names.m_select_all)
1226 cmd.add_agent (agent select_all)
1227 command_menu_item := cmd.new_menu_item
1228 command_controller.add_edition_command (cmd)
1229 add_recyclable (command_menu_item)
1230 edit_menu.extend (command_menu_item)
1231
1232 -- Separator --------------------------------------
1233 edit_menu.extend (create {EV_MENU_SEPARATOR})
1234
1235 -- Line numbers
1236 create cmd.make
1237 cmd.set_menu_name (Interface_names.m_line_numbers)
1238 cmd.add_agent (agent toggle_line_number_display)
1239 cmd.set_needs_editable (True)
1240 command_menu_item := cmd.new_menu_item
1241 command_controller.add_edition_command (cmd)
1242 add_recyclable (command_menu_item)
1243 edit_menu.extend (command_menu_item)
1244
1245 -- Separator --------------------------------------
1246 edit_menu.extend (create {EV_MENU_SEPARATOR})
1247
1248 -- Search
1249 create cmd.make
1250 cmd.set_menu_name (Interface_names.m_Search + "%T" + preferences.editor_data.shortcut_name_for_action (3))
1251 cmd.add_agent (agent search)
1252 command_menu_item := cmd.new_menu_item
1253 command_controller.add_edition_command (cmd)
1254 add_recyclable (command_menu_item)
1255 edit_menu.extend (command_menu_item)
1256
1257 -- Go to
1258 create cmd.make
1259 cmd.set_menu_name (Interface_names.m_Go_to)
1260 cmd.add_agent (agent goto)
1261 cmd.set_needs_editable (True)
1262 command_menu_item := cmd.new_menu_item
1263 command_controller.add_edition_command (cmd)
1264 add_recyclable (command_menu_item)
1265 edit_menu.extend (command_menu_item)
1266
1267 -- Replace
1268 create cmd.make
1269 cmd.set_menu_name (Interface_names.m_Replace + "%T" + preferences.editor_data.shortcut_name_for_action (4))
1270 cmd.add_agent (agent editor.replace)
1271 cmd.set_needs_editable (True)
1272 command_menu_item := cmd.new_menu_item
1273 command_controller.add_edition_command (cmd)
1274 add_recyclable (command_menu_item)
1275 edit_menu.extend (command_menu_item)
1276
1277 -- Find sub menu
1278
1279 create sub_menu.make_with_text (Interface_names.m_Find)
1280
1281 -- Find next
1282 create cmd.make
1283 cmd.set_menu_name (Interface_names.m_Find_next + "%T" + preferences.editor_data.shortcut_name_for_action (6))
1284 cmd.add_agent (agent find_next)
1285 command_menu_item := cmd.new_menu_item
1286 command_controller.add_edition_command (cmd)
1287 add_recyclable (command_menu_item)
1288 sub_menu.extend (command_menu_item)
1289
1290 -- Find previous
1291 create cmd.make
1292 cmd.set_menu_name (Interface_names.m_Find_previous + "%T" + preferences.editor_data.shortcut_name_for_action (7))
1293 cmd.add_agent (agent find_previous)
1294 command_menu_item := cmd.new_menu_item
1295 command_controller.add_edition_command (cmd)
1296 add_recyclable (command_menu_item)
1297 sub_menu.extend (command_menu_item)
1298
1299 -- Find selection
1300 create os_cmd.make (Current)
1301 os_cmd.set_menu_name (Interface_names.m_Find_selection + "%T" + preferences.editor_data.shortcut_name_for_action (5))
1302 os_cmd.add_agent (agent find_selection)
1303 command_menu_item := os_cmd.new_menu_item
1304 command_controller.add_selection_command (os_cmd)
1305 add_recyclable (command_menu_item)
1306 sub_menu.extend (command_menu_item)
1307
1308 edit_menu.extend (sub_menu)
1309
1310
1311 -- Separator --------------------------------------
1312 edit_menu.extend (create {EV_MENU_SEPARATOR})
1313
1314 create sub_menu.make_with_text (Interface_names.m_Advanced)
1315
1316 create os_cmd.make (Current)
1317 os_cmd.set_needs_editable (True)
1318 command_controller.add_selection_command (os_cmd)
1319 os_cmd.set_menu_name (Interface_names.m_Indent)
1320 os_cmd.add_agent (agent editor.indent_selection)
1321 command_menu_item := os_cmd.new_menu_item
1322 add_recyclable (command_menu_item)
1323 sub_menu.extend (command_menu_item)
1324
1325 create os_cmd.make (Current)
1326 os_cmd.set_needs_editable (True)
1327 command_controller.add_selection_command (os_cmd)
1328 os_cmd.set_menu_name (Interface_names.m_Unindent)
1329 os_cmd.add_agent (agent editor.unindent_selection)
1330 command_menu_item := os_cmd.new_menu_item
1331 add_recyclable (command_menu_item)
1332 sub_menu.extend (command_menu_item)
1333
1334 create os_cmd.make (Current)
1335 os_cmd.set_needs_editable (True)
1336 command_controller.add_selection_command (os_cmd)
1337 os_cmd.set_menu_name (Interface_names.m_To_lower)
1338 os_cmd.add_agent (agent editor.set_selection_case (True))
1339 command_menu_item := os_cmd.new_menu_item
1340 add_recyclable (command_menu_item)
1341 sub_menu.extend (command_menu_item)
1342
1343 create os_cmd.make (Current)
1344 os_cmd.set_needs_editable (True)
1345 command_controller.add_selection_command (os_cmd)
1346 os_cmd.set_menu_name (Interface_names.m_To_upper)
1347 os_cmd.add_agent (agent editor.set_selection_case (False))
1348 command_menu_item := os_cmd.new_menu_item
1349 add_recyclable (command_menu_item)
1350 sub_menu.extend (command_menu_item)
1351
1352 create cmd.make
1353 cmd.set_needs_editable (True)
1354 cmd.set_menu_name (Interface_names.m_Comment)
1355 cmd.add_agent (agent editor.comment_selection)
1356 command_menu_item := cmd.new_menu_item
1357 command_controller.add_edition_command (cmd)
1358 add_recyclable (command_menu_item)
1359 sub_menu.extend (command_menu_item)
1360
1361 create cmd.make
1362 cmd.set_needs_editable (True)
1363 cmd.set_menu_name (Interface_names.m_Uncomment)
1364 cmd.add_agent (agent editor.uncomment_selection)
1365 command_menu_item := cmd.new_menu_item
1366 command_controller.add_edition_command (cmd)
1367 add_recyclable (command_menu_item)
1368 sub_menu.extend (command_menu_item)
1369
1370 -- Separator --------------------------------------
1371 sub_menu.extend (create {EV_MENU_SEPARATOR})
1372
1373 -- Insert if block
1374 create cmd.make
1375 cmd.set_needs_editable (True)
1376 cmd.set_menu_name (Interface_names.m_If_block)
1377 cmd.add_agent (agent editor.embed_in_block("if then", 3))
1378 command_menu_item := cmd.new_menu_item
1379 command_controller.add_edition_command (cmd)
1380 add_recyclable (command_menu_item)
1381 sub_menu.extend (command_menu_item)
1382
1383 -- Insert debug block
1384 create cmd.make
1385 cmd.set_needs_editable (True)
1386 cmd.set_menu_name (Interface_names.m_debug_block)
1387 cmd.add_agent (agent editor.embed_in_block("debug", 5))
1388 command_menu_item := cmd.new_menu_item
1389 command_controller.add_edition_command (cmd)
1390 add_recyclable (command_menu_item)
1391 sub_menu.extend (command_menu_item)
1392
1393
1394 -- Separator --------------------------------------
1395 sub_menu.extend (create {EV_MENU_SEPARATOR})
1396
1397 -- Complete word
1398 create cmd.make
1399 cmd.set_needs_editable (True)
1400 cmd.set_menu_name (Interface_names.m_Complete_word + "%T" + preferences.editor_data.shortcut_name_for_action (1))
1401 command_menu_item := cmd.new_menu_item
1402 command_controller.add_edition_command (cmd)
1403 cmd.add_agent (agent editor.complete_feature_name)
1404
1405 add_recyclable (command_menu_item)
1406 sub_menu.extend (command_menu_item)
1407
1408 -- Complete class name
1409 create cmd.make
1410 cmd.set_needs_editable (True)
1411 cmd.set_menu_name (Interface_names.m_Complete_class_name + "%T" + preferences.editor_data.shortcut_name_for_action (2))
1412 command_menu_item := cmd.new_menu_item
1413 command_controller.add_edition_command (cmd)
1414 cmd.add_agent (agent editor.complete_class_name)
1415
1416 add_recyclable (command_menu_item)
1417 sub_menu.extend (command_menu_item)
1418
1419 sub_menu.extend (create {EV_MENU_SEPARATOR})
1420
1421 -- show/hide formatting marks.
1422 create cmd.make
1423 if editor_tool.text_area.view_invisible_symbols then
1424 cmd.set_menu_name (Interface_names.m_Hide_formatting_marks)
1425 else
1426 cmd.set_menu_name (Interface_names.m_Show_formatting_marks)
1427 end
1428 formatting_marks_command_menu_item := cmd.new_menu_item
1429 command_controller.add_edition_command (cmd)
1430 cmd.add_agent (agent toggle_formatting_marks)
1431
1432 add_recyclable (formatting_marks_command_menu_item)
1433 sub_menu.extend (formatting_marks_command_menu_item)
1434
1435 edit_menu.extend (sub_menu)
1436 end
1437
1438 build_view_menu is
1439 -- Build the view menu.
1440 local
1441 form: EB_CLASS_INFO_FORMATTER
1442 new_menu_item: EB_COMMAND_MENU_ITEM
1443 new_basic_item: EV_MENU_ITEM
1444 do
1445 Precursor
1446
1447 new_menu_item := toggle_stone_cmd.new_menu_item
1448 view_menu.extend (new_menu_item)
1449 add_recyclable (new_menu_item)
1450
1451 new_menu_item := send_stone_to_context_cmd.new_menu_item
1452 view_menu.extend (new_menu_item)
1453 add_recyclable (new_menu_item)
1454 -- Go to menu
1455 new_basic_item := history_manager.new_menu
1456 view_menu.extend (new_basic_item)
1457
1458 -- Separator --------------------------------------
1459 view_menu.extend (create {EV_MENU_SEPARATOR})
1460 view_menu.extend (build_class_info_menu)
1461 view_menu.extend (build_feature_info_menu)
1462
1463 -- Separator --------------------------------------
1464 view_menu.extend (create {EV_MENU_SEPARATOR})
1465
1466 from
1467 managed_main_formatters.start
1468 until
1469 managed_main_formatters.after
1470 loop
1471 form := managed_main_formatters.item
1472 new_basic_item := form.new_menu_item
1473 new_basic_item.select_actions.put_front (agent form.invalidate)
1474 view_menu.extend (new_basic_item)
1475 --add_recyclable (new_basic_item)
1476 managed_main_formatters.forth
1477 end
1478 end
1479
1480 build_favorites_menu is
1481 -- Build the favorites menu
1482 do
1483 Precursor {EB_TOOL_MANAGER}
1484
1485 create show_favorites_menu_item
1486 update_show_favorites_menu_item
1487 show_favorites_menu_item.select_actions.extend (agent execute_show_favorites)
1488
1489 favorites_menu.start
1490 favorites_menu.put_right (show_favorites_menu_item)
1491 favorites_menu.select_actions.extend (agent update_show_favorites_menu_item)
1492 end
1493
1494 build_project_menu is
1495 -- Build the project menu.
1496 local
1497 command_menu_item: EB_COMMAND_MENU_ITEM
1498 do
1499 create project_menu.make_with_text (Interface_names.m_Project)
1500
1501 -- Melt
1502 command_menu_item := Melt_project_cmd.new_menu_item
1503 add_recyclable (command_menu_item)
1504 project_menu.extend (command_menu_item)
1505
1506 -- Quick melt
1507 command_menu_item := Quick_melt_project_cmd.new_menu_item
1508 add_recyclable (command_menu_item)
1509 project_menu.extend (command_menu_item)
1510
1511 -- Freeze
1512 command_menu_item := Freeze_project_cmd.new_menu_item
1513 add_recyclable (command_menu_item)
1514 project_menu.extend (command_menu_item)
1515
1516 -- Finalize
1517 command_menu_item := Finalize_project_cmd.new_menu_item
1518 add_recyclable (command_menu_item)
1519 project_menu.extend (command_menu_item)
1520
1521 -- Precompile
1522 command_menu_item := precompilation_cmd.new_menu_item
1523 add_recyclable (command_menu_item)
1524 project_menu.extend (command_menu_item)
1525
1526 -- Separator -------------------------------------------------
1527 project_menu.extend (create {EV_MENU_SEPARATOR})
1528
1529 -- Compile Workbench C code
1530 command_menu_item := c_workbench_compilation_cmd.new_menu_item
1531 add_recyclable (command_menu_item)
1532 project_menu.extend (command_menu_item)
1533
1534 -- Compile Finalized C code
1535 command_menu_item := c_finalized_compilation_cmd.new_menu_item
1536 add_recyclable (command_menu_item)
1537 project_menu.extend (command_menu_item)
1538
1539 -- Execute Finalized code
1540 command_menu_item := run_finalized_cmd.new_menu_item
1541 add_recyclable (command_menu_item)
1542 project_menu.extend (command_menu_item)
1543
1544 -- Separator -------------------------------------------------
1545 project_menu.extend (create {EV_MENU_SEPARATOR})
1546
1547 -- System Tool window
1548 command_menu_item := system_cmd.new_menu_item
1549 add_recyclable (command_menu_item)
1550 project_menu.extend (command_menu_item)
1551
1552 -- System information
1553 command_menu_item := system_info_cmd.new_menu_item
1554 add_recyclable (command_menu_item)
1555 project_menu.extend (command_menu_item)
1556
1557 -- Error information
1558 command_menu_item := display_error_help_cmd.new_menu_item
1559 add_recyclable (command_menu_item)
1560 project_menu.extend (command_menu_item)
1561
1562 if has_documentation_generation or has_xmi_generation then
1563 -- Separator -------------------------------------------------
1564 project_menu.extend (create {EV_MENU_SEPARATOR})
1565 end
1566
1567 if has_documentation_generation then
1568 -- Generate Documentation
1569 command_menu_item := document_cmd.new_menu_item
1570 add_recyclable (command_menu_item)
1571 project_menu.extend (command_menu_item)
1572 end
1573
1574 if has_xmi_generation then
1575 -- Export XMI
1576 command_menu_item := export_cmd.new_menu_item
1577 add_recyclable (command_menu_item)
1578 project_menu.extend (command_menu_item)
1579 end
1580 end
1581
1582 build_tools_menu is
1583 -- Create and build `tools_menu'
1584 local
1585 command_menu_item: EB_COMMAND_MENU_ITEM
1586 menu_item: EV_MENU_ITEM
1587 do
1588 create tools_menu.make_with_text (Interface_names.m_Tools)
1589
1590 -- New Cluster command.
1591 command_menu_item := new_cluster_cmd.new_menu_item
1592 add_recyclable (command_menu_item)
1593 tools_menu.extend (command_menu_item)
1594
1595 -- New Class command.
1596 command_menu_item := new_class_cmd.new_menu_item
1597 add_recyclable (command_menu_item)
1598 tools_menu.extend (command_menu_item)
1599
1600 -- New Feature command.
1601 command_menu_item := new_feature_cmd.new_menu_item
1602 add_recyclable (command_menu_item)
1603 tools_menu.extend (command_menu_item)
1604
1605 -- Delete class/cluster command.
1606 command_menu_item := delete_class_cluster_cmd.new_menu_item
1607 add_recyclable (command_menu_item)
1608 tools_menu.extend (command_menu_item)
1609
1610 -- Separator --------------------------------------
1611 tools_menu.extend (create {EV_MENU_SEPARATOR})
1612
1613
1614 if has_metrics then
1615 -- Metric tool
1616 create metric_menu.make_with_text (interface_names.metric_metrics)
1617 create menu_item.make_with_text (interface_names.metric_calculate)
1618 metric_menu.extend (menu_item)
1619 create menu_item.make_with_text (interface_names.metric_add)
1620 metric_menu.extend (menu_item)
1621 create menu_item.make_with_text (interface_names.metric_delete)
1622 metric_menu.extend (menu_item)
1623 create menu_item.make_with_text (interface_names.metric_details)
1624 metric_menu.extend (menu_item)
1625 create menu_item.make_with_text (interface_names.metric_new_metrics)
1626 metric_menu.extend (menu_item)
1627 create menu_item.make_with_text (interface_names.metric_management)
1628 metric_menu.extend (menu_item)
1629 create menu_item.make_with_text (interface_names.metric_archive)
1630 metric_menu.extend (menu_item)
1631 metric_menu.disable_sensitive
1632 tools_menu.extend (metric_menu)
1633 end
1634
1635 if has_profiler then
1636 -- Profiler Window
1637 command_menu_item := show_profiler.new_menu_item
1638 add_recyclable (command_menu_item)
1639 tools_menu.extend (command_menu_item)
1640 end
1641
1642 -- Precompile Wizard
1643 command_menu_item := wizard_precompile_cmd.new_menu_item
1644 add_recyclable (command_menu_item)
1645 tools_menu.extend (command_menu_item)
1646
1647 if has_dll_generation then
1648 -- Dynamic Library Window
1649 command_menu_item := show_dynamic_lib_tool.new_menu_item
1650 add_recyclable (command_menu_item)
1651 tools_menu.extend (command_menu_item)
1652 end
1653
1654 -- Separator -------------------------------------------------
1655 tools_menu.extend (create {EV_MENU_SEPARATOR})
1656
1657 -- Preferences
1658 command_menu_item := Show_preferences_cmd.new_menu_item
1659 add_recyclable (command_menu_item)
1660 tools_menu.extend (command_menu_item)
1661
1662 -- External commands editor
1663 command_menu_item := Edit_external_commands_cmd.new_menu_item
1664 add_recyclable (command_menu_item)
1665 tools_menu.extend (command_menu_item)
1666
1667 -- Separator -------------------------------------------------
1668 tools_menu.extend (create {EV_MENU_SEPARATOR})
1669
1670 rebuild_tools_menu
1671 end
1672
1673 feature -- Stone process
1674
1675 stone: STONE
1676 -- Current stone
1677
1678 toggle_unified_stone is
1679 -- Change the stone management mode.
1680 do
1681 unified_stone := not unified_stone
1682 if unified_stone then
1683 send_stone_to_context
1684 send_stone_to_context_cmd.disable_sensitive
1685 context_tool.link_to_development_window
1686 else
1687 if stone /= Void then
1688 send_stone_to_context_cmd.enable_sensitive
1689 end
1690 context_tool.cut_from_development_window
1691 end
1692 end
1693
1694 set_stone (a_stone: STONE) is
1695 -- Change the currently focused stone.
1696 local
1697 cd: STANDARD_DISCARDABLE_CONFIRMATION_DIALOG
1698 cv_cst: CLASSI_STONE
1699 ef_stone: EXTERNAL_FILE_STONE
1700 l: LIST [EB_DEVELOPMENT_WINDOW]
1701 l_filename: STRING
1702 do
1703 cv_cst ?= a_stone
1704 if cv_cst /= Void then
1705 l_filename := cv_cst.class_i.name
1706 else
1707 ef_stone ?= a_stone
1708 if ef_stone /= Void then
1709 l_filename := ef_stone.file_name.string
1710 end
1711 end
1712
1713 if cv_cst /= Void or ef_stone /= Void then
1714 l := Window_manager.development_windows_with_class (l_filename)
1715 if l.is_empty or else l.has (Current) then
1716 -- We're not editing the class in another window.
1717 set_stone_after_first_check (a_stone)
1718 else
1719 create cd.make_initialized (2, preferences.dialog_data.already_editing_class_string, warning_messages.w_Class_already_edited, Interface_names.L_do_not_show_again, preferences.preferences)
1720 cd.set_ok_action (agent set_stone_after_first_check (a_stone))
1721 cd.show_modal_to_window (window)
1722 end
1723 else
1724 set_stone_after_first_check (a_stone)
1725 end
1726 end
1727
1728 set_stone_after_first_check (a_stone: STONE) is
1729 -- Display text associated with `a_stone', if any and if possible
1730 local
1731 feature_stone: FEATURE_STONE
1732 old_class_stone: CLASSI_STONE
1733 test_stone: CLASSI_STONE
1734 same_class: BOOLEAN
1735 conv_ferrst: FEATURE_ERROR_STONE
1736 ef_stone: EXTERNAL_FILE_STONE
1737 do
1738 old_class_stone ?= stone
1739 feature_stone ?= a_stone
1740 ef_stone ?= a_stone
1741 if old_class_stone /= Void then
1742 create test_stone.make (old_class_stone.class_i)
1743 same_class := test_stone.same_as (a_stone)
1744 -- We need to compare classes. If `old_class_stone' is a FEATURE_STONE
1745 -- `same_as' will compare features. Therefore, we need `test_stone' to be sure
1746 -- we have a CLASSI_STONE.
1747 if same_class and then feature_stone /= Void then
1748 same_class := False
1749 -- if the stone corresponding to a feature of currently opened class is dropped
1750 -- we attempt to scroll to the feature without asking to save the file
1751 -- except if it is during a resynchronization, in which case we do not scroll at all.
1752 if editor_tool.text_area.text_is_fully_loaded then
1753 if not during_synchronization then
1754 editor_tool.text_area.find_feature_named (feature_stone.feature_name)
1755 feature_stone_already_processed := editor_tool.text_area.found_feature
1756 else
1757 feature_stone_already_processed := True
1758 end
1759 conv_ferrst ?= feature_stone
1760 if feature_stone_already_processed and conv_ferrst /= Void then
1761 -- Scroll to the line of the error.
1762 if not during_synchronization then
1763 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
1764 end
1765 end
1766 end
1767 end
1768 elseif ef_stone /= Void then
1769
1770
1771 end
1772
1773 -- first, let's check if there is already something in this window
1774 -- if there's nothing, there's no need to save anything...
1775 if stone = Void or else not changed or else feature_stone_already_processed or else same_class then
1776 set_stone_after_check (a_stone)
1777 feature_stone_already_processed := False
1778 else
1779 -- there is something to be saved
1780 -- if user chooses to save, current file will be parsed
1781 -- if there is a syntax_error, new file is not loaded
1782 save_and (agent set_stone_after_check (a_stone))
1783 if text_saved and then not syntax_is_correct then
1784 text_saved := False
1785 during_synchronization := True
1786 set_stone_after_check (stone)
1787 during_synchronization := False
1788 address_manager.refresh
1789 end
1790 end
1791 end
1792
1793 force_stone (s: STONE) is
1794 -- make `s' the new value of `stone', and
1795 -- change the display accordingly. Try to
1796 -- extract a class from `s' whenever possible.
1797 do
1798 if s.is_storable then
1799 set_stone (s)
1800 if not unified_stone then
1801 context_tool.advanced_set_stone (s)
1802 end
1803 end
1804 end
1805
1806 process_class (s: CLASSI_STONE) is
1807 -- Process class stone
1808 do
1809 set_stone (s)
1810 end
1811
1812 process_feature_error (s: FEATURE_ERROR_STONE) is
1813 -- Process feature error stone.
1814 local
1815 cl_stone: CLASSC_STONE
1816 e_class: CLASS_C
1817 do
1818 set_default_format
1819 e_class := s.e_feature.written_class
1820 create cl_stone.make (e_class)
1821 set_stone (cl_stone)
1822 editor_tool.text_area.deselect_all
1823 if s.line_number > 0 then
1824 editor_tool.text_area.highlight_selected (s.line_number, s.line_number)
1825 end
1826 end
1827
1828
1829 process_class_syntax (s: CL_SYNTAX_STONE) is
1830 -- Process class syntax.
1831 local
1832 cl_stone: CLASSC_STONE
1833 do
1834 -- call set_stone to ensure the proper class is displayed
1835 create cl_stone.make (s.e_class)
1836 set_stone (cl_stone)
1837 editor_tool.text_area.deselect_all
1838 editor_tool.text_area.highlight_when_ready (s.line, s.line)
1839 end
1840
1841 refresh is
1842 -- Synchronize clickable elements with text, if possible.
1843 do
1844 --| FIXME ARNAUD
1845 -- synchronise_stone
1846 --| END FIXME
1847 --| FIXME XR: Refresh current display in the editor.
1848 editor_tool.text_area.update_click_list (False)
1849 update_save_symbol
1850 address_manager.refresh
1851 -- The cluster manager should already be refreshed by the window manager.
1852 -- cluster_manager.refresh
1853 -- context_tool.refresh
1854 end
1855
1856 quick_refresh is
1857 -- Redraw the main editor's drawing area.
1858 do
1859 editor_tool.text_area.refresh
1860 context_tool.quick_refresh
1861 end
1862
1863 set_default_format is
1864 -- Default format of windows.
1865 --| FIXME ARNAUD: To be implemented.
1866 -- local
1867 -- f: EB_FORMATTER
1868 do
1869 -- if stone /= Void then
1870 -- if stone.class_i.hide_implementation then
1871 -- f := format_list.precompiled_default_format
1872 -- else
1873 -- f := format_list.default_format
1874 -- end
1875 -- else
1876 -- f := format_list.default_format
1877 -- end
1878 -- set_last_format (f)
1879 --| END FIXME
1880 end
1881
1882 feature -- Resource Update
1883
1884 update is
1885 -- Update Current with the registered resources.
1886 do
1887 lock_update
1888 -- Show/hide general toolbar
1889 if preferences.development_window_data.show_general_toolbar then
1890 show_general_toolbar_command.enable_visible
1891 else
1892 show_general_toolbar_command.disable_visible
1893 end
1894
1895 -- Show/hide address toolbar
1896 if preferences.development_window_data.show_address_toolbar then
1897 show_address_toolbar_command.enable_visible
1898 else
1899 show_address_toolbar_command.disable_visible
1900 end
1901
1902 -- Show/hide project toolbar
1903 if preferences.development_window_data.show_project_toolbar then
1904 show_project_toolbar_command.enable_visible
1905 else
1906 show_project_toolbar_command.disable_visible
1907 end
1908
1909 left_panel.load_from_resource (preferences.development_window_data.left_panel_layout)
1910 right_panel.load_from_resource (preferences.development_window_data.right_panel_layout)
1911 splitter_position := preferences.development_window_data.left_panel_width
1912 update_splitters
1913 unlock_update
1914 end
1915
1916 update_splitters is
1917 -- Refresh the position of the splitter on screen according to
1918 -- our internal values.
1919 do
1920 -- Set the interior layout
1921 if panel.full then
1922 panel.set_split_position (splitter_position.max (panel.minimum_split_position))
1923 end
1924 end
1925
1926 register is
1927 -- Register to preferences we want notification of.
1928 do
1929 end
1930
1931 unregister is
1932 -- unregister to preferences we want notification of.
1933 do
1934 end
1935
1936 reset is
1937 -- Reset the window contents
1938 do
1939 Precursor
1940 address_manager.reset
1941
1942 --| FIXME ARNAUD, multiformat not yet implemented.
1943 -- format_list.enable_imp_formats_sensitive
1944 --| END FIXME
1945 end
1946
1947 rebuild_tools_menu is
1948 -- Refresh the list of external commands.
1949 local
1950 ms: LIST [EB_COMMAND_MENU_ITEM]
1951 do
1952 -- Remove all the external commands, which are at the end of the menu.
1953 from
1954 tools_menu.go_i_th (tools_menu.count + 1 - number_of_displayed_external_commands)
1955 until
1956 tools_menu.after
1957 loop
1958 tools_menu.remove
1959 end
1960 ms := Edit_external_commands_cmd.menus
1961 number_of_displayed_external_commands := ms.count
1962 from
1963 ms.start
1964 until
1965 ms.after
1966 loop
1967 tools_menu.extend (ms.item)
1968 add_recyclable (ms.item)
1969 ms.forth
1970 end
1971 end
1972
1973 syntax_is_correct: BOOLEAN is
1974 -- file was successfully parsed.
1975 do
1976 Result := editor_tool.text_area.syntax_is_correct
1977 end
1978
1979 on_project_created is
1980 -- Inform tools that the current project has been loaded or re-loaded.
1981 do
1982 build_menu_bar
1983 enable_commands_on_project_created
1984 context_tool.on_project_created
1985 address_manager.on_project_created
1986 if has_dll_generation then
1987 show_dynamic_lib_tool.enable_sensitive
1988 end
1989 if has_profiler then
1990 show_profiler.enable_sensitive
1991 end
1992 end
1993
1994 on_project_loaded is
1995 -- Inform tools that the current project has been loaded or re-loaded.
1996 do
1997 -- cluster_manager.on_project_loaded
1998 enable_commands_on_project_loaded
1999 cluster_tool.on_project_loaded
2000 context_tool.on_project_loaded
2001 end
2002
2003 on_project_unloaded is
2004 -- Inform tools that the current project will soon been unloaded.
2005 do
2006 -- cluster_manager.on_project_unloaded
2007 disable_commands_on_project_unloaded
2008 cluster_tool.on_project_unloaded
2009 context_tool.on_project_unloaded
2010 address_manager.on_project_unloaded
2011 build_menu_bar
2012 if has_dll_generation then
2013 show_dynamic_lib_tool.disable_sensitive
2014 end
2015 if has_profiler then
2016 show_profiler.disable_sensitive
2017 end
2018 end
2019
2020 save_before_compiling is
2021 -- save the text but do not update clickable positions
2022 do
2023 save_only := True
2024 save_text
2025 end
2026
2027 perform_check_before_save is
2028 -- Perform any pre-save operations/checks
2029 local
2030 dial: EV_CONFIRMATION_DIALOG
2031 do
2032 debug ("EDITOR")
2033 if editor_tool.text_area.current_text /= Void and then changed then
2034 io.error.put_string ("%N Warning: Attempting to save a non editable format%N")
2035 end
2036 end
2037 if changed then
2038 editor_tool.text_area.strip_unwanted_indentation
2039 end
2040 if editor_tool.text_area.open_backup then
2041 create dial.make_with_text(Warning_messages.w_Save_backup)
2042 dial.set_buttons_and_actions(<<"Continue", "Cancel">>, <<agent continue_save, agent cancel_save>>)
2043 dial.set_default_push_button(dial.button("Continue"))
2044 dial.set_default_cancel_button(dial.button("Cancel"))
2045 dial.set_title ("Save Backup")
2046 dial.show_modal_to_window (window)
2047 else
2048 check_passed := True
2049 end
2050 end
2051
2052 continue_save is
2053 -- continue saving
2054 do
2055 check_passed := True
2056 end
2057
2058 cancel_save is
2059 -- cancel saving
2060 do
2061 check_passed := False
2062 end
2063
2064 process is
2065 -- process the user entry in the address bar
2066 do
2067 save_canceled := False
2068 end
2069
2070 on_text_saved is
2071 -- Notify the editor that the text has been saved
2072 local
2073 str: STRING
2074 do
2075 Precursor
2076 editor_tool.on_text_saved
2077 text_saved := True
2078 if not save_only then
2079 editor_tool.text_area.update_click_list (True)
2080 end
2081 save_only := False
2082 str := title.twin
2083 if str @ 1 = '*' then
2084 str.keep_tail (str.count - 2)
2085 set_title (str)
2086 end
2087 update_formatters
2088 if editor_tool.text_area.syntax_is_correct then
2089 status_bar.display_message ("")
2090 else
2091 status_bar.display_message (Interface_names.L_syntax_error)
2092 end
2093 text_edited := False
2094 end
2095
2096 save_and (an_action: PROCEDURE [ANY, TUPLE]) is
2097 local
2098 save_dialog: EB_CONFIRM_SAVE_DIALOG
2099 do
2100 save_canceled := True
2101 text_saved := False
2102 create save_dialog.make_and_launch (Current,Current)
2103 if not save_canceled and then syntax_is_correct then
2104 an_action.call(Void)
2105 end
2106 end
2107
2108 feature -- Window management
2109
2110 show_window is
2111 -- Show the window
2112 do
2113 show
2114 end
2115
2116 raise_window is
2117 -- Show the window and set the focus to it.
2118 do
2119 show
2120 --| FIXME, set the focus.
2121 end
2122
2123 hide_window is
2124 -- Hide the window
2125 do
2126 hide
2127 end
2128
2129 destroy_window is
2130 -- Destroy the window.
2131 do
2132 destroy
2133 end
2134
2135 give_focus is
2136 -- Give the focus to the address manager.
2137 do
2138 address_manager.set_focus
2139 end
2140
2141 save_layout is
2142 -- Store layout of `current'.
2143 do
2144 -- Now save the windows's layout, but only if the
2145 -- debugger is not displayed in `Current'. By saving the layout,
2146 -- we ensure that future windows may use exactly the same layout.
2147 -- If the debugger is displayed, the previopus layout is already saved,
2148 -- and this is the one that must be used, as only one debugger is ever displayed.
2149 if (Application.is_running and debugger_manager.debugging_window /= Current) or not application.is_running then
2150 preferences.development_window_data.save_left_panel_layout (left_panel.save_to_resource)
2151 preferences.development_window_data.save_right_panel_layout (right_panel.save_to_resource)
2152 preferences.development_window_data.save_left_panel_width (panel.split_position)
2153 -- Save width & height.
2154 preferences.development_window_data.save_size (window.width, window.height, window.is_maximized)
2155 end
2156 preferences.development_window_data.save_search_tool_options (search_tool)
2157 -- Commit saves
2158 -- save_resources
2159 end
2160
2161 feature -- Tools & Controls
2162
2163 editor_tool: EB_EDITOR_TOOL
2164
2165 favorites_tool: EB_FAVORITES_TOOL
2166
2167 cluster_tool: EB_CLUSTER_TOOL
2168
2169 search_tool: EB_SEARCH_TOOL
2170
2171 features_tool: EB_FEATURES_TOOL
2172
2173 windows_tool: EB_WINDOWS_TOOL
2174
2175 context_tool: EB_CONTEXT_TOOL
2176 -- Context explorer for current class and system.
2177
2178 address_manager: EB_ADDRESS_MANAGER
2179 -- Text field in the toolbar
2180 -- Allow user to enter the name
2181 -- of the class he wants to edit.
2182
2183 project_manager: EB_PROJECT_MANAGER is
2184 -- Project manager associated to the project the user is working on.
2185 do
2186 Result := Eiffel_project.manager
2187 end
2188
2189 managed_class_formatters: ARRAYED_LIST [EB_CLASS_INFO_FORMATTER]
2190 -- All formatters that operate on a class.
2191
2192 managed_feature_formatters: ARRAYED_LIST [EB_FEATURE_INFO_FORMATTER]
2193 -- All formatters that operate on a class.
2194
2195 managed_main_formatters: ARRAYED_LIST [EB_CLASS_TEXT_FORMATTER]
2196 -- All formatters that can be displayed in the main editor frame.
2197
2198 unified_stone: BOOLEAN
2199 -- Is the stone common with the context tool or not?
2200
2201 arguments_dialog: EB_ARGUMENT_DIALOG
2202 -- The arguments dialog for current, if any
2203
2204 goto_dialog: EB_GOTO_DIALOG
2205 -- The goto dialog for line number access
2206
2207 feature -- Multiple editor management
2208
2209 add_editor_to_list (an_editor: EB_EDITOR) is
2210 -- adds `an_editor' to `editors'
2211 do
2212 editors.extend (an_editor)
2213 end
2214
2215 current_editor: EB_EDITOR is
2216 -- current editor, if none, main editor
2217 do
2218 if current_editor_index /= 0 then
2219 Result := editors @ current_editor_index
2220 else
2221 Result := editors.first
2222 end
2223 end
2224
2225 set_current_editor (an_editor: EB_EDITOR) is
2226 -- set `an_editor' as main editor
2227 local
2228 old_index: INTEGER
2229 new_index: INTEGER
2230 do
2231 old_index := current_editor_index
2232 new_index := editors.index_of (an_editor, 1)
2233 if
2234 editors.valid_index (new_index) and
2235 old_index /= new_index
2236 then
2237 current_editor_index := new_index
2238 from
2239 editors.start
2240 until
2241 editors.after
2242 loop
2243 if editors.index /= current_editor_index and then editors.item.has_selection then
2244 editors.item.disable_selection
2245 end
2246 editors.forth
2247 end
2248 update_paste_cmd
2249 -- Last thing, update the menu entry for the formatting marks.
2250 if current_editor.view_invisible_symbols then
2251 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
2252 else
2253 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
2254 end
2255 command_controller.set_current_editor (an_editor)
2256 end
2257 end
2258
2259 update_paste_cmd is
2260 -- Update `editor_paste_cmd'. To be performed when an editor grabs the focus.
2261 do
2262 if
2263 not current_editor.is_empty and then
2264 current_editor.is_editable and then
2265 current_editor.clipboard.has_text
2266 then
2267 editor_paste_cmd.enable_sensitive
2268 else
2269 editor_paste_cmd.disable_sensitive
2270 end
2271 end
2272
2273 feature {NONE} -- Multiple editor management
2274
2275 editors: ARRAYED_LIST [EB_EDITOR]
2276 -- editor contained in `Current'
2277
2278 current_editor_index: INTEGER
2279 -- Index in `editors' of the editor that has the focus.
2280
2281 feature {EB_FEATURES_TOOL, EB_FEATURES_TREE, DOTNET_CLASS_AS, DOTNET_CLASS_CONTEXT} -- Feature Clauses
2282
2283 set_feature_clauses (a_features: ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]]; a_type: STRING) is
2284 -- Set 'features' to 'a_features' and store in hash table with key 'a_type' denoting name of consumed
2285 -- type pertinent to 'a_features'.
2286 require
2287 a_features_not_void: a_features /= Void
2288 do
2289 if feature_clauses = Void then
2290 create feature_clauses.make (5)
2291 end
2292 feature_clauses.put (a_features, a_type)
2293 end
2294
2295 get_feature_clauses (a_type: STRING): ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]] is
2296 -- Get list of feature clauses relevant to .NET type with name 'a_type'.
2297 require
2298 a_type_not_void: a_type /= Void
2299 has_type_clauses: feature_clauses.has (a_type)
2300 do
2301 Result := feature_clauses.item (a_type)
2302 ensure
2303 result_not_void: Result /= Void
2304 end
2305
2306 feature_clauses: HASH_TABLE [ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]], STRING]
2307 -- List of features clauses for Current window hashed by the .NET name of the consumed_type.
2308
2309 feature_positions: HASH_TABLE [INTEGER, E_FEATURE]
2310 -- Features indexed by line position in class text (for .NET features).
2311
2312 feature {EB_WINDOW_MANAGER} -- Window management / Implementation
2313
2314 destroy_imp is
2315 -- Destroy window.
2316 do
2317 -- To avoid reentrance
2318 if not is_destroying then
2319 is_destroying := True
2320 -- If a launched application is still running, kill it.
2321 if Application.is_running and then debugger_manager.debugging_window = Current then
2322 Application.kill
2323 else
2324 preferences.development_window_data.save_left_panel_layout (left_panel.save_to_resource)
2325 preferences.development_window_data.save_right_panel_layout (right_panel.save_to_resource)
2326 end
2327 preferences.development_window_data.save_left_panel_width (panel.split_position)
2328 -- Save width & height.
2329 preferences.development_window_data.save_size (window.width, window.height, window.is_maximized)
2330 left_panel.wipe_out
2331 right_panel.wipe_out
2332 preferences.development_window_data.save_search_tool_options (search_tool)
2333 hide
2334
2335 -- Commit saves
2336 -- save_resources
2337
2338 toolbars_area.wipe_out
2339 address_manager.recycle
2340 project_customizable_toolbar.recycle
2341 Precursor {EB_TOOL_MANAGER}
2342
2343 managed_class_formatters.wipe_out
2344 managed_feature_formatters.wipe_out
2345 managed_main_formatters.wipe_out
2346 toolbarable_commands.wipe_out
2347 editors.wipe_out
2348 stone := Void
2349 end
2350 end
2351
2352 feature {NONE} -- Implementation
2353
2354 set_stone_after_check (a_stone: STONE) is
2355 local
2356 old_stone: STONE
2357 new_class_stone: CLASSI_STONE
2358 old_class_stone: CLASSI_STONE
2359 conv_classc: CLASSC_STONE
2360 conv_brkstone: BREAKABLE_STONE
2361 cluster_st: CLUSTER_STONE
2362 feature_stone: FEATURE_STONE
2363 conv_ferrst: FEATURE_ERROR_STONE
2364
2365 ef_stone: EXTERNAL_FILE_STONE
2366 f: FILE
2367
2368 l_format_context: FORMAT_CONTEXT
2369 l_indexes: EIFFEL_LIST [INDEX_AS]
2370 conv_errst: ERROR_STONE
2371 cl_syntax_stone: CL_SYNTAX_STONE
2372 error_line: INTEGER
2373 class_file: RAW_FILE
2374 class_text_exists: BOOLEAN
2375 same_class: BOOLEAN
2376 test_stone: CLASSI_STONE
2377 conv_ace: ACE_SYNTAX_STONE
2378 externali: EXTERNAL_CLASS_I
2379 l_reader: EIFFEL_XML_DESERIALIZER
2380 external_cons: CONSUMED_TYPE
2381 str: STRING
2382 dotnet_class: BOOLEAN
2383 l_short_formatter: EB_SHORT_FORMATTER
2384 l_flat_formatter: EB_FLAT_SHORT_FORMATTER
2385 do
2386 -- the text does not change if the text was saved with syntax errors
2387 cur_wid := window
2388 if cur_wid = Void then
2389 --| Do nothing.
2390 else
2391 if old_cur = Void then
2392 old_cur := cur_wid.pointer_style
2393 end
2394 -- cur_wid.enable_capture
2395 cur_wid.set_pointer_style (Wait_cursor)
2396 end
2397
2398 conv_brkstone ?= a_stone
2399 conv_errst ?= a_stone
2400 conv_ace ?= a_stone
2401 ef_stone ?= a_stone
2402 if conv_brkstone /= Void then
2403 if Application.is_breakpoint_enabled (conv_brkstone.routine, conv_brkstone.index) then
2404 Application.remove_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2405 else
2406 Application.set_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2407 end
2408 output_manager.display_stop_points
2409 window_manager.quick_refresh_all
2410 elseif conv_errst /= Void then
2411 display_error_help_cmd.execute_with_stone (conv_errst)
2412 elseif conv_ace /= Void then
2413 --| FIXME XR: What should we do?!
2414 elseif ef_stone /= Void then
2415 f := ef_stone.file
2416 f.make_open_read (f.name)
2417 f.read_stream (f.count)
2418 f.close
2419 editor_tool.text_area.load_text (f.last_string)
2420 else
2421
2422 -- Remember previous stone.
2423 old_stone := stone
2424 old_class_stone ?= stone
2425
2426 -- New stone properties
2427 new_class_stone ?= a_stone
2428
2429 -- Set the stone.
2430 old_set_stone (a_stone)
2431 cluster_st ?= a_stone
2432
2433 new_feature_cmd.disable_sensitive
2434 toggle_feature_signature_cmd.disable_sensitive
2435
2436 -- We update the state of the `Add to Favorites' command.
2437 if new_class_stone /= Void then
2438 favorites_menu.first.enable_sensitive
2439 else
2440 favorites_menu.first.disable_sensitive
2441 end
2442
2443 -- Update the history.
2444 if
2445 new_class_stone /= Void
2446 then
2447 history_manager.extend (new_class_stone)
2448 elseif
2449 cluster_st /= Void
2450 then
2451 history_manager.extend (cluster_st)
2452 end
2453 -- Update the address manager if needed.
2454 address_manager.refresh
2455 if new_class_stone /= Void then
2456 -- class stone was dropped
2457 create class_file.make (new_class_stone.class_i.file_name)
2458 class_text_exists := class_file.exists
2459 feature_stone ?= a_stone
2460 --| We have to create a classi_stone to check whether the stones are really similar.
2461 --| Otherwise a redefinition of same_as may be called.
2462 create test_stone.make (new_class_stone.class_i)
2463 if test_stone.same_as (old_class_stone) then
2464 same_class := True
2465 end
2466 if not feature_stone_already_processed then
2467 if
2468 same_class and then text_saved
2469 then
2470 -- nothing changed in the editor
2471 -- we only have to update click_list
2472 if editor_tool.text_area.is_editable then
2473 editor_tool.text_area.update_click_list (False)
2474 end
2475 else
2476 if changed then
2477 -- user has already chosen not to save the file
2478 -- do not ask again
2479 Feature_positions.wipe_out
2480 editor_tool.text_area.no_save_before_next_load
2481 end
2482 end
2483 end
2484
2485 conv_classc ?= new_class_stone
2486 if conv_classc = Void or else
2487 conv_classc.e_class.is_external or else
2488 feature_stone /= Void and not
2489 feature_stone_already_processed and not
2490 (same_class and context_tool.sending_stone) then
2491 -- If a classi_stone or a feature_stone or a external call
2492 -- has been dropped, check to see if a .NET class.
2493 if class_text_exists then
2494 if new_class_stone.class_i.is_external_class then
2495 create l_reader
2496 externali ?= new_class_stone.class_i
2497 external_cons ?= l_reader.new_object_from_file (externali.file_name)
2498 if external_cons /= Void then
2499 -- A .NET class.
2500 dotnet_class := True
2501 l_short_formatter ?= managed_main_formatters.i_th (4)
2502 l_flat_formatter ?= managed_main_formatters.i_th (5)
2503 if l_short_formatter /= Void then
2504 l_short_formatter.set_dotnet_mode (True)
2505 end
2506 if l_flat_formatter /= Void then
2507 l_flat_formatter.set_dotnet_mode (True)
2508 end
2509 end
2510 else
2511 managed_main_formatters.first.set_stone (new_class_stone)
2512 managed_main_formatters.first.execute
2513 end
2514 else
2515 editor_tool.text_area.clear_window
2516 editor_tool.text_area.display_message (
2517 Warning_messages.w_file_not_exist (
2518 new_class_stone.class_i.file_name))
2519 end
2520 end
2521 if conv_classc = Void then
2522 --| The dropped class is not compiled.
2523 --| Display only the textual formatter.
2524 if dotnet_class then
2525 managed_main_formatters.i_th (4).set_stone (new_class_stone)
2526 managed_main_formatters.i_th (5).set_stone (new_class_stone)
2527 managed_main_formatters.i_th (4).execute
2528 end
2529 address_manager.disable_formatters
2530 else
2531 --| We have a compiled class.
2532 if
2533 class_text_exists and then
2534 Eiffel_project.Workbench.last_reached_degree <= 2
2535 then
2536 new_feature_cmd.enable_sensitive
2537 toggle_feature_signature_cmd.enable_sensitive
2538 end
2539
2540 --address_manager.enable_formatters
2541 update_formatters
2542 if not class_text_exists then
2543 --| Disable the textual formatter.
2544 managed_main_formatters.first.disable_sensitive
2545 from
2546 managed_main_formatters.start
2547 until
2548 managed_main_formatters.after
2549 loop
2550 managed_main_formatters.item.set_stone (new_class_stone)
2551 managed_main_formatters.forth
2552 end
2553 managed_main_formatters.i_th (2).execute
2554 else
2555 if not changed or not same_class then
2556 --| Enable all formatters.
2557 if
2558 not feature_stone_already_processed or
2559 not managed_main_formatters.first.selected
2560 then
2561 from
2562 managed_main_formatters.start
2563 until
2564 managed_main_formatters.after
2565 loop
2566 managed_main_formatters.item.set_stone (new_class_stone)
2567 managed_main_formatters.forth
2568 end
2569 end
2570 else
2571 address_manager.disable_formatters
2572 from
2573 managed_main_formatters.start
2574 until
2575 managed_main_formatters.after
2576 loop
2577 managed_main_formatters.item.set_stone (new_class_stone)
2578 managed_main_formatters.forth
2579 end
2580 end
2581 end
2582 end
2583 else
2584 -- not a class text : cannot be edited
2585 editor_tool.text_area.disable_editable
2586 address_manager.disable_formatters
2587
2588 --| Disable all formatters.
2589 from
2590 managed_main_formatters.start
2591 until
2592 managed_main_formatters.after
2593 loop
2594 managed_main_formatters.item.set_stone (Void)
2595 managed_main_formatters.forth
2596 end
2597 if cluster_st /= Void then
2598 --| FIXME XR: Really manage cluster display in the main editor
2599 create l_format_context.make_for_case
2600 l_format_context.put_text_item (ti_indexing_keyword)
2601 l_format_context.put_new_line
2602 l_format_context.indent
2603 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster"))
2604 l_format_context.put_text_item_without_tabs (ti_colon)
2605 l_format_context.put_space
2606 l_format_context.put_string ("%"" + cluster_st.cluster_i.cluster_name + "%"")
2607 l_format_context.put_new_line
2608 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster_path"))
2609 l_format_context.put_text_item_without_tabs (ti_colon)
2610 l_format_context.put_space
2611 l_format_context.put_string ("%"" + cluster_st.cluster_i.path + "%"")
2612 l_format_context.put_new_line
2613 l_indexes := cluster_st.cluster_i.indexes
2614 if l_indexes /= Void then
2615 l_format_context.set_new_line_between_tokens
2616 l_format_context.format_ast (l_indexes)
2617 l_format_context.exdent
2618 end
2619 l_format_context.put_new_line
2620 editor_tool.text_area.process_text (l_format_context.text)
2621 --| END FIXME
2622 end
2623 end
2624 if class_text_exists then
2625 if feature_stone /= Void and not feature_stone_already_processed and not (same_class and context_tool.sending_stone) then
2626 conv_ferrst ?= feature_stone
2627 if conv_ferrst /= Void then
2628 error_line := conv_ferrst.line_number
2629 else
2630 -- if a feature_stone has been dropped
2631 -- scroll to the corresponding feature in the basic text format
2632 if not during_synchronization then
2633 scroll_to_feature (feature_stone.e_feature, new_class_stone.class_i)
2634 end
2635 end
2636 else
2637 cl_syntax_stone ?= a_stone
2638 if cl_syntax_stone /= Void then
2639 error_line := cl_syntax_stone.line
2640 end
2641 end
2642 if error_line > 0 then
2643 -- Scroll to the line of the error.
2644 editor_tool.text_area.display_line_when_ready (error_line, True)
2645 end
2646 end
2647 -- Update the title of the window
2648 if a_stone /= Void then
2649 if changed then
2650 str := a_stone.header.twin
2651 str.prepend ("* ")
2652 set_title (str)
2653 else
2654 set_title (a_stone.header)
2655 end
2656 else
2657 set_title (Interface_names.t_Empty_development_window)
2658 end
2659
2660 -- Refresh the tools.
2661 features_tool.set_stone (a_stone)
2662 cluster_tool.set_stone (a_stone)
2663 -- Update the context tool.
2664 if unified_stone then
2665 context_tool.set_stone (a_stone)
2666 end
2667
2668 end
2669 if
2670 stone /= Void and then
2671 not unified_stone
2672 then
2673 send_stone_to_context_cmd.enable_sensitive
2674 else
2675 send_stone_to_context_cmd.disable_sensitive
2676 end
2677 if cur_wid = Void then
2678 --| Do nothing.
2679 else
2680 cur_wid.set_pointer_style (old_cur)
2681 old_cur := Void
2682 -- cur_wid.disable_capture
2683 cur_wid := Void
2684 end
2685 end
2686
2687 scroll_to_feature (feat_as: E_FEATURE; displayed_class: CLASS_I) is
2688 -- highlight the feature correspnding to `feat_as' in the class represented by `displayed_class'
2689 require
2690 class_is_not_void: displayed_class /= Void
2691 feat_as_is_not_void: feat_as /= Void
2692 local
2693 begin_index, offset: INTEGER
2694 tmp_text: STRING
2695 do
2696 if not feat_as.is_il_external then
2697 if feat_as.ast /= Void then
2698 begin_index := feat_as.ast.start_position
2699 if platform_constants.is_windows then
2700 tmp_text := displayed_class.text.substring (1, begin_index)
2701 offset := tmp_text.occurrences('%R')
2702 end
2703 editor_tool.text_area.scroll_to_when_ready (begin_index.item - offset)
2704 end
2705 else
2706 -- FIXME NC: Doesn't work properly for .NET features
2707 -- .NET formatted feature.
2708 begin_index := feature_positions.item (feat_as)
2709 if platform_constants.is_windows then
2710 tmp_text := displayed_class.text.substring (1, begin_index)
2711 offset := tmp_text.occurrences('%N')
2712 end
2713 editor_tool.text_area.scroll_to_when_ready (begin_index // 2) -- - offset)
2714 end
2715 end
2716
2717 check_passed: BOOLEAN
2718
2719 save_canceled: BOOLEAN
2720 -- did user cancel save ?
2721
2722 save_only: BOOLEAN
2723 -- skip parse and update after save ?
2724
2725 text_saved: BOOLEAN
2726 -- has the user chosen to save the file
2727
2728 is_destroying: BOOLEAN
2729 -- Is `current' being currently destroyed?
2730
2731 feature_stone_already_processed: BOOLEAN
2732 -- Is the processed stone a feature stone and has it
2733 -- been already processed by the editor ?
2734
2735 feature {NONE} -- Implementation
2736
2737 update_save_symbol is
2738 do
2739 Precursor {EB_FILEABLE}
2740 if changed then
2741 save_cmd.enable_sensitive
2742 address_manager.disable_formatters
2743 else
2744 save_cmd.disable_sensitive
2745 update_formatters
2746 end
2747 if is_empty then
2748 print_cmd.disable_sensitive
2749 save_as_cmd.disable_sensitive
2750 else
2751 print_cmd.enable_sensitive
2752 save_as_cmd.enable_sensitive
2753 end
2754 end
2755
2756 is_stone_external: BOOLEAN
2757 -- Does 'stone' contain a .NET consumed type?
2758
2759 update_formatters is
2760 -- Give a correct sensitivity to formatters.
2761 local
2762 cist: CLASSI_STONE
2763 cst: CLASSC_STONE
2764 type_changed: BOOLEAN
2765 do
2766 cst ?= stone
2767 cist ?= stone
2768 -- Check to if formatting context has changed.
2769 if cst /= Void then
2770 type_changed := (cst.e_class.is_true_external and not is_stone_external) or
2771 (not cst.e_class.is_true_external and is_stone_external)
2772 elseif cist /= Void then
2773 type_changed := (cist.class_i.is_external_class and not is_stone_external) or
2774 (not cist.class_i.is_external_class and is_stone_external)
2775 end
2776
2777 if type_changed then
2778 -- Toggle stone flag.
2779 is_stone_external := not is_stone_external
2780 end
2781
2782 if cst /= Void then
2783 address_manager.enable_formatters
2784 if is_stone_external then
2785 -- Change formatters to .NET sensitivity (from normal).
2786 enable_dotnet_formatters
2787 if type_changed then
2788 managed_main_formatters.i_th (4).enable_select
2789 end
2790 else
2791 if changed then
2792 address_manager.disable_formatters
2793 else
2794 --managed_main_formatters.first.disable_sensitive
2795 end
2796 end
2797 elseif cist /= Void and is_stone_external then
2798 -- Change formatters to .NET sensitivity (from normal).
2799 enable_dotnet_formatters
2800 if type_changed then
2801 managed_main_formatters.i_th (4).enable_select
2802 end
2803 else
2804 address_manager.disable_formatters
2805 if cist /= stone then
2806 managed_main_formatters.first.execute
2807 end
2808 end
2809 end
2810
2811 enable_dotnet_formatters is
2812 -- Enable only the .NET class text formatters.
2813 do
2814 from
2815 managed_main_formatters.start
2816 until
2817 managed_main_formatters.after
2818 loop
2819 if managed_main_formatters.item.is_dotnet_formatter then
2820 managed_main_formatters.item.enable_sensitive
2821 else
2822 managed_main_formatters.item.disable_sensitive
2823 end
2824 managed_main_formatters.forth
2825 end
2826 end
2827
2828
2829 on_text_reset is
2830 -- The main editor has just been wiped out
2831 -- before loading a new file.
2832 local
2833 str: STRING
2834 do
2835 str := title.twin
2836 if str @ 1 = '*' then
2837 str.keep_tail (str.count - 2)
2838 set_title (str)
2839 end
2840 address_manager.disable_formatters
2841 status_bar.display_message ("")
2842 status_bar.remove_cursor_position
2843 text_edited := False
2844 end
2845
2846 on_cursor_moved is
2847 -- The cursor has moved, reflect the change in the status bar.
2848 do
2849 refresh_cursor_position
2850 end
2851
2852 on_text_fully_loaded is
2853 -- The main editor has just been reloaded.
2854 do
2855 update_paste_cmd
2856 update_formatters
2857 if editor_tool.text_area.syntax_is_correct then
2858 status_bar.display_message ("")
2859 else
2860 status_bar.display_message (Interface_names.L_syntax_error)
2861 end
2862 refresh_cursor_position
2863 text_edited := False
2864 end
2865
2866 on_text_back_to_its_last_saved_state is
2867 local
2868 str: STRING
2869 do
2870 str := title.twin
2871 if str @ 1 = '*' then
2872 str.keep_tail (str.count - 2)
2873 set_title (str)
2874 end
2875 update_formatters
2876 text_edited := False
2877 end
2878
2879 text_edited: BOOLEAN
2880 -- Do we know that the text was edited?
2881 -- If so, no need to update the display each time it is edited.
2882
2883 on_text_edited (unused: BOOLEAN) is
2884 -- The text in the editor is modified, add the '*' in the title.
2885 -- Gray out the formatters.
2886 local
2887 str: STRING
2888 cst: CLASSI_STONE
2889 do
2890 if not text_edited then
2891 str := title.twin
2892 if str @ 1 /= '*' then
2893 str.prepend ("* ")
2894 set_title (str)
2895 end
2896 address_manager.disable_formatters
2897 cst ?= stone
2898 if cst /= Void then
2899 Eiffel_project.Manager.class_is_edited (cst.class_i)
2900 end
2901 text_edited := True
2902 end
2903 status_bar.display_message ("")
2904 end
2905
2906 on_back is
2907 -- User pressed Alt+left.
2908 -- Go back in the history (or the context history).
2909 do
2910 if context_tool_has_focus then
2911 if context_tool.history_manager.is_back_possible then
2912 context_tool.history_manager.back_command.execute
2913 end
2914 elseif history_manager.is_back_possible then
2915 history_manager.back_command.execute
2916 end
2917 end
2918
2919 on_forth is
2920 -- User pressed Alt+right.
2921 -- Go forth in the history (or the context history).
2922 do
2923 if context_tool_has_focus then
2924 if context_tool.history_manager.is_forth_possible then
2925 context_tool.history_manager.forth_command.execute
2926 editor_tool.text_area.editor_viewport.enable_sensitive
2927 editor_tool.text_area.set_focus
2928 end
2929 elseif history_manager.is_forth_possible then
2930 history_manager.forth_command.execute
2931 editor_tool.text_area.editor_viewport.enable_sensitive
2932 editor_tool.text_area.set_focus
2933 end
2934 end
2935
2936 context_tool_has_focus: BOOLEAN is
2937 -- Does the context tool or one of its children has the focus?
2938 local
2939 fw: EV_WIDGET
2940 cont: EV_CONTAINER
2941 wid: EV_WIDGET
2942 do
2943 fw := (create {EV_ENVIRONMENT}).application.focused_widget
2944 wid := context_tool.explorer_bar_item.widget
2945 if wid = fw then
2946 Result := True
2947 elseif fw = Void then
2948 Result := False
2949 else
2950 from
2951 cont := fw.parent
2952 until
2953 cont = wid or cont = Void
2954 loop
2955 cont := cont.parent
2956 end
2957 if cont = wid then
2958 Result := True
2959 end
2960 end
2961 end
2962
2963 saved_cursor: CURSOR
2964 -- Saved cursor position for displaying the stack.
2965
2966 can_drop (st: ANY): BOOLEAN is
2967 -- Can the user drop the stone `st'?
2968 local
2969 conv_ace: ACE_SYNTAX_STONE
2970 do
2971 conv_ace ?= st
2972 Result := conv_ace = Void
2973 end
2974
2975 quick_refresh_on_class_drop (unused: CLASSI_STONE) is
2976 -- Quick refresh all windows.
2977 do
2978 window_manager.quick_refresh_all
2979 end
2980
2981 quick_refresh_on_brk_drop (unused: BREAKABLE_STONE) is
2982 -- Quick refresh all windows.
2983 do
2984 window_manager.quick_refresh_all
2985 end
2986
2987 send_stone_to_context is
2988 -- Send current stone to the context tool.
2989 -- Used by `send_stone_to_context_cmd'.
2990 do
2991 if stone /= Void then
2992 context_tool.set_stone (stone)
2993 end
2994 end
2995
2996 destroy is
2997 -- check if current text has been saved and destroy
2998 local
2999 dialog_w: EB_WARNING_DIALOG
3000 do
3001 if editor_tool /= Void and then editor_tool.text_area /= Void and then changed and then not confirmed then
3002 if Window_manager.development_windows_count > 1 then
3003 create dialog_w.make_with_text (Warning_messages.w_Save_before_closing)
3004 dialog_w.set_buttons_and_actions (<<"Yes", "No", "Cancel">>, <<agent save_and_destroy, agent force_destroy, agent do_nothing>>)
3005 dialog_w.set_default_push_button (dialog_w.button("Yes"))
3006 dialog_w.set_default_cancel_button (dialog_w.button("Cancel"))
3007 dialog_w.show_modal_to_window (window)
3008 else
3009 -- We let the window manager handle the saving, along with other windows
3010 -- (not development windows)
3011 force_destroy
3012 end
3013 else
3014 Precursor {EB_TOOL_MANAGER}
3015 end
3016 end
3017
3018 save_and_destroy is
3019 do
3020 save_text
3021 destroy
3022 end
3023
3024 force_destroy is
3025 -- Destroy without asking.
3026 do
3027 confirmed := True
3028 destroy
3029 confirmed := False
3030 end
3031
3032 confirmed: BOOLEAN
3033 -- Did the user say he wanted to exit?
3034
3035 show_dynamic_library_dialog is
3036 -- Create a new dynamic library window and display it.
3037 do
3038 Window_manager.create_dynamic_lib_window
3039 end
3040
3041 recycle is
3042 -- Call the precursors.
3043 do
3044 Precursor {EB_TOOL_MANAGER}
3045 command_controller.recycle
3046 end
3047
3048 feature {NONE} -- Implementation: Editor commands
3049
3050 refresh_cursor_position is
3051 -- Display the current cursor position in the status bar.
3052 require
3053 text_loaded: not is_empty
3054 local
3055 l, c: INTEGER
3056 do
3057 l := editor_tool.text_area.cursor_y_position
3058 c := editor_tool.text_area.cursor_x_position
3059 status_bar.set_cursor_position (l, c)
3060 end
3061
3062 select_all is
3063 -- Select the whole text in the focused editor.
3064 do
3065 current_editor.select_all
3066 end
3067
3068 search is
3069 -- Search some text in the focused editor.
3070 local
3071 cv_ced: EB_CLICKABLE_EDITOR
3072 do
3073 cv_ced ?= current_editor
3074 if cv_ced /= Void then
3075 cv_ced.search
3076 end
3077 end
3078
3079 goto is
3080 -- Display a dialog to select a line to go to in the editor.
3081 local
3082 ed: EB_EDITOR
3083 do
3084 ed ?= current_editor
3085 if ed /= Void then
3086 create goto_dialog.make (ed)
3087 goto_dialog.show_modal_to_window (Current.window)
3088 end
3089 end
3090
3091 toggle_line_number_display is
3092 -- Toggle line number display on/off in editor
3093 local
3094 ed: EB_EDITOR
3095 do
3096 ed ?= current_editor
3097 if ed /= Void then
3098 ed.toggle_line_number_display
3099 end
3100 end
3101
3102 find_next is
3103 -- Find the next occurrence of the search text.
3104 local
3105 cv_ced: EB_CLICKABLE_EDITOR
3106 do
3107 if search_tool.currently_searched /= Void then
3108 cv_ced ?= current_editor
3109 if cv_ced /= Void then
3110 cv_ced.find_next
3111 end
3112 else
3113 search_tool.show_and_set_focus
3114 end
3115 end
3116
3117 find_previous is
3118 -- Find the previous occurrence of the search text.
3119 local
3120 cv_ced: EB_CLICKABLE_EDITOR
3121 do
3122 if search_tool.currently_searched /= Void then
3123 cv_ced ?= current_editor
3124 if cv_ced /= Void then
3125 cv_ced.find_previous
3126 end
3127 else
3128 search_tool.show_and_set_focus
3129 end
3130 end
3131
3132 find_selection is
3133 -- Find the next occurrence of the selection.
3134 local
3135 cv_ced: EB_CLICKABLE_EDITOR
3136 do
3137 cv_ced ?= current_editor
3138 if cv_ced /= Void then
3139 cv_ced.find_selection
3140 end
3141 end
3142
3143 cut_selection is
3144 -- Cut the selection in the current editor.
3145 do
3146 current_editor.cut_selection
3147 end
3148
3149 copy_selection is
3150 -- Cut the selection in the current editor.
3151 do
3152 current_editor.copy_selection
3153 end
3154
3155 toggle_formatting_marks is
3156 -- Show/Hide formatting marks in the editor and update related menu item.
3157 do
3158 current_editor.toggle_view_invisible_symbols
3159 if current_editor.view_invisible_symbols then
3160 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
3161 else
3162 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
3163 end
3164 end
3165
3166 feature {NONE} -- Implementation / Menus
3167
3168 number_of_displayed_external_commands: INTEGER
3169 -- Number of external commands in the tools menu.
3170
3171 old_cur: EV_CURSOR
3172 -- Cursor saved while displaying the hourglass cursor.
3173
3174 cur_wid: EV_WIDGET
3175 -- Widget on which the hourglass cursor was set.
3176
3177 project_menu: EV_MENU
3178 -- Menu for entries relative to the Project.
3179
3180 recent_projects_menu: EB_RECENT_PROJECTS_MANAGER_MENU
3181 -- SubMenu for recent projects.
3182
3183 during_synchronization: BOOLEAN
3184 -- Are we during a resynchronization?
3185
3186 formatting_marks_command_menu_item: EB_COMMAND_MENU_ITEM
3187 -- Menu item used to shw/hide formatting marks.
3188
3189 undo_accelerator: EV_ACCELERATOR
3190 -- Accelerator for Ctrl+Z
3191
3192 redo_accelerator: EV_ACCELERATOR
3193 -- Accelerator for Ctrl+Y
3194
3195 feature {EB_TOOL} -- Implementation / Commands
3196
3197 shell_cmd: EB_OPEN_SHELL_COMMAND
3198 -- Command to use an external editor.
3199
3200 undo_cmd: EB_UNDO_COMMAND
3201 -- Command to undo in the editor.
3202
3203 redo_cmd: EB_REDO_COMMAND
3204 -- Command to redo in the editor.
3205
3206 editor_cut_cmd: EB_ON_SELECTION_COMMAND
3207 -- Command to cut text in the editor.
3208
3209 editor_copy_cmd: EB_ON_SELECTION_COMMAND
3210 -- Command to copy text in the editor.
3211
3212 editor_paste_cmd: EB_EDITOR_PASTE_COMMAND
3213 -- Command to paste text in the editor.
3214
3215 melt_cmd: EB_MELT_PROJECT_COMMAND
3216 -- Command to start compilation.
3217
3218 freeze_cmd: EB_FREEZE_PROJECT_COMMAND
3219 -- Command to Freeze the project.
3220
3221 finalize_cmd: EB_FINALIZE_PROJECT_COMMAND
3222 -- Command to Finalize the project.
3223
3224 c_workbench_compilation_cmd: EB_C_COMPILATION_COMMAND
3225 -- Command to compile the workbench C code.
3226
3227 c_finalized_compilation_cmd: EB_C_COMPILATION_COMMAND
3228 -- Command to compile the finalized C code.
3229
3230 new_cluster_cmd: EB_NEW_CLUSTER_COMMAND
3231 -- Command to create a new cluster.
3232
3233 new_class_cmd: EB_NEW_CLASS_COMMAND
3234 -- Command to create a new class.
3235
3236 new_feature_cmd: EB_NEW_FEATURE_COMMAND
3237 -- Command to execute the feature wizard.
3238
3239 toggle_feature_signature_cmd: EB_TOGGLE_FEATURE_SIGNATURE_COMMAND
3240 -- Show/Hide signature of feature node in eb_feature_tool
3241
3242 toggle_stone_cmd: EB_UNIFY_STONE_CMD
3243 -- Command to toggle between the stone management modes.
3244
3245 delete_class_cluster_cmd: EB_DELETE_CLASS_CLUSTER_COMMAND
3246 -- Command to remove a class or a cluster from the system
3247 -- (permanent deletion).
3248
3249 show_profiler: EB_SHOW_PROFILE_TOOL
3250 -- What allows us to display the profiler window.
3251
3252 toolbarable_commands: ARRAYED_LIST [EB_TOOLBARABLE_COMMAND]
3253 -- All commands that can be put in a toolbar.
3254
3255 command_controller: EB_EDITOR_COMMAND_CONTROLLER
3256 -- Object that takes care of updating the sensitivity of all editor commands.
3257
3258 save_as_cmd: EB_SAVE_FILE_AS_COMMAND
3259 -- Command to save a class with a different file name.
3260
3261 Edit_external_commands_cmd: EB_EXTERNAL_COMMANDS_EDITOR is
3262 -- Command that lets the user add new external commands to the tools menu.
3263 once
3264 create Result.make
3265 Result.enable_sensitive
3266 end
3267
3268 system_info_cmd: EB_STANDARD_CMD is
3269 -- Command to display information about the system (root class,...)
3270 do
3271 Result := debugger_manager.system_info_cmd
3272 end
3273
3274 display_error_help_cmd: EB_ERROR_INFORMATION_CMD is
3275 -- Command to pop up a dialog giving help on compilation errors.
3276 do
3277 Result := debugger_manager.display_error_help_cmd
3278 end
3279
3280 send_stone_to_context_cmd: EB_STANDARD_CMD
3281 -- Command to send the current stone to the context tool.
3282
3283 print_cmd: EB_PRINT_COMMAND
3284 -- Command to print the content of editor with focus
3285
3286 eac_browser_cmd: EB_OPEN_EAC_BROWSER_CMD is
3287 -- Command to display the eac browser
3288 do
3289 Result := Debugger_manager.eac_browser_cmd
3290 end
3291
3292 show_favorites_menu_item: EV_MENU_ITEM
3293 -- Show/Hide favorites menu item.
3294
3295 update_show_favorites_menu_item is
3296 -- Update `show_favorites_menu_item' menu label.
3297 do
3298 if favorites_tool.shown then
3299 show_favorites_menu_item.set_text (Interface_names.m_Hide_favorites)
3300 else
3301 show_favorites_menu_item.set_text (Interface_names.m_Show_favorites)
3302 end
3303 end
3304
3305 execute_show_favorites is
3306 -- Show `favorites_tool' if it is closed, close
3307 -- it in the opposite case.
3308 do
3309 update_show_favorites_menu_item
3310 if favorites_tool.shown then
3311 favorites_tool.close
3312 else
3313 favorites_tool.show
3314 end
3315 end
3316
3317 feature {EB_TOOL_WINDOW, EB_EXPLORER_BAR, EB_DEBUGGER_MANAGER} -- Floating tool handling
3318
3319 all_tool_windows: ARRAYED_LIST [EB_TOOL_WINDOW]
3320 -- All tool windows under the control of `Current'.
3321
3322 add_tool_window (a_tool_window: EB_TOOL_WINDOW) is
3323 -- Add `a_tool_window' to `all_tool_windows', ensuring it is
3324 -- then under the control of `Current'.
3325 require
3326 a_tool_window_not_void: a_tool_window /= Void
3327 do
3328 if all_tool_windows = Void then
3329 create all_tool_windows.make (2)
3330 end
3331 all_tool_windows.extend (a_tool_window)
3332 ensure
3333 extended: all_tool_windows.has (a_tool_window)
3334 end
3335
3336 remove_tool_window (a_widget: EV_WIDGET) is
3337 -- Remove tool window associate with `a_widget'.
3338 require
3339 a_widget_not_void: a_widget /= Void
3340 do
3341 if all_tool_windows /= Void then
3342 from
3343 all_tool_windows.start
3344 until
3345 all_tool_windows.off
3346 loop
3347 if all_tool_windows.item.tool = a_widget then
3348 all_tool_windows.remove
3349 all_tool_windows.finish
3350 end
3351 all_tool_windows.forth
3352 end
3353 end
3354 end
3355
3356 remove_all_tool_windows is
3357 -- Ensure `all_tool_windows' is empty if non Void.
3358 do
3359 if all_tool_windows /= Void then
3360 all_tool_windows.wipe_out
3361 end
3362 ensure
3363 tool_windows_empty: all_tool_windows /= Void implies all_tool_windows.is_empty
3364 end
3365
3366
3367 window_moved (x_pos, y_pos: INTEGER) is
3368 -- `Current' has been moved, so move all associated tool windows within `all_tool_windows'.
3369 local
3370 tool_window: EB_TOOL_WINDOW
3371 do
3372 if all_tool_windows /= Void then
3373 from
3374 all_tool_windows.start
3375 until
3376 all_tool_windows.off
3377 loop
3378 tool_window := all_tool_windows.item
3379 check
3380 not_destroyed: not tool_window.window.is_destroyed
3381 end
3382 if preferences.development_window_data.dock_tracking then
3383 tool_window.window.move_actions.block
3384 tool_window.window.set_x_position (x_pos + tool_window.x_position)
3385 tool_window.window.set_y_position (y_pos + tool_window.y_position)
3386 tool_window.window.move_actions.resume
3387 else
3388 -- If we are not performing dock tracking, we must update the relative position
3389 -- of the tool window, so that if dock tracking is enabled, the relative
3390 -- positions are correct.
3391 tool_window.set_x_position ( tool_window.window.screen_x - x_pos)
3392 tool_window.set_y_position ( tool_window.window.screen_y - y_pos)
3393 end
3394 all_tool_windows.forth
3395 end
3396 end
3397 end
3398
3399 feature {NONE} -- Execution
3400
3401 Kcst: EV_KEY_CONSTANTS is
3402 -- A way to access key constants.
3403 once
3404 create Result
3405 end
3406
3407 toolbar_right_click_action (a_x, a_y, a_button: INTEGER; a_x_tilt, a_y_tilt, a_pressure: DOUBLE; a_screen_x, a_screen_y: INTEGER) is
3408 -- Action called when the user right-click in the toolbar.
3409 -- Display a popup menu to show/hide toolbars and customize the general toolbar.
3410 local
3411 popup_menu: EV_MENU
3412 do
3413 if a_button = 3 then
3414 popup_menu := build_toolbar_menu
3415 popup_menu.show
3416 end
3417 end
3418
3419 enable_commands_on_project_created is
3420 -- Enable commands when a new project has been created (not yet compiled)
3421 do
3422 system_info_cmd.enable_sensitive
3423 if
3424 stone /= Void and then
3425 not unified_stone
3426 then
3427 send_stone_to_context_cmd.enable_sensitive
3428 end
3429 end
3430
3431 enable_commands_on_project_loaded is
3432 -- Enable commands when a new project has been created and compiled
3433 do
3434 if has_profiler then
3435 show_profiler.enable_sensitive
3436 end
3437 if has_dll_generation then
3438 show_dynamic_lib_tool.enable_sensitive
3439 end
3440 open_cmd.enable_sensitive
3441 new_class_cmd.enable_sensitive
3442 new_cluster_cmd.enable_sensitive
3443 system_info_cmd.enable_sensitive
3444 if unified_stone then
3445 send_stone_to_context_cmd.disable_sensitive
3446 elseif stone /= Void then
3447 send_stone_to_context_cmd.enable_sensitive
3448 end
3449 new_class_cmd.enable_sensitive
3450 new_cluster_cmd.enable_sensitive
3451 delete_class_cluster_cmd.enable_sensitive
3452 c_workbench_compilation_cmd.enable_sensitive
3453 c_finalized_compilation_cmd.enable_sensitive
3454 end
3455
3456 disable_commands_on_project_unloaded is
3457 -- Enable commands when a project has been closed.
3458 do
3459 if has_dll_generation then
3460 show_dynamic_lib_tool.disable_sensitive
3461 end
3462 if has_profiler then
3463 show_profiler.disable_sensitive
3464 end
3465 open_cmd.disable_sensitive
3466 new_class_cmd.disable_sensitive
3467 new_cluster_cmd.disable_sensitive
3468 if not project_manager.is_created then
3469 system_info_cmd.disable_sensitive
3470 send_stone_to_context_cmd.disable_sensitive
3471 end
3472 delete_class_cluster_cmd.disable_sensitive
3473 c_workbench_compilation_cmd.disable_sensitive
3474 c_finalized_compilation_cmd.disable_sensitive
3475 end
3476
3477 end -- class EB_DEVELOPMENT_WINDOW
3478

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23