/[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 54580 - (hide annotations)
Wed Aug 31 14:26:46 2005 UTC (14 years, 5 months ago) by jfiat
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 109064 byte(s)
added special shortcuts used to display a special debug menu specific to eStudio
when Ctrl+Alt+d is pressed

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