let main () =
Ed_gui.on_last_window_close := GMain.Main.quit;
ignore(Cam_log.get_log_window());
List.iter Cam_commands.eval_command (!Cam_args.init_commands @ !Cam_args.commands);
Ed_view.iter_factories
(fun f -> Ed_misc.catch_print_exceptions (fun () -> f#on_start) ());
begin
try
if Sys.file_exists !Ed_layout.layout_file then
try
let layout = Ed_layout.load_layout !Ed_layout.layout_file in
Ed_layout.create_windows_of_layout layout
with
Failure s
| Sys_error s ->
prerr_endline s;
raise Not_found
else
raise Not_found
with
Not_found ->
match !Ed_gui.gui_windows with
[] -> ignore(Ed_gui.create_window())
| _ -> ()
end;
begin
match !Ed_gui.active_window, !Ed_gui.gui_windows with
None, w :: _ -> Ed_gui.active_window := Some w
| _ -> ()
end;
let on_file file =
Cam_commands.launch_command "open_file" [| file |]
in
List.iter on_file !Cam_args.remaining;
if not (ocaml_syntax_mode_installed ()) then
(
let m = Printf.sprintf
"No objective-caml syntax mode found in directories\n%s\nYou should copy %s into one of these directories and restart Chamo to be able to use the objetive caml syntax mode."
(String.concat "\n" Ed_sourceview.languages_manager#lang_files_dirs)
(Filename.concat Cam_installation.languages_specs_dir "ocaml.lang")
in
Cam_hooks.warning_message (Ed_misc.to_utf8 m);
);
GMain.Main.main ();
Ed_view.iter_factories
(fun f -> Ed_misc.catch_print_exceptions (fun () -> f#on_exit) ())