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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54402 - (hide annotations)
Fri Aug 19 10:44:10 2005 UTC (14 years, 6 months ago) by jfiat
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 107524 byte(s)
minor improvement on cluster display (sorted classes ...)

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