1 (* Copyright (C) 2004-2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
33 (** {2 Initialization} *)
36 MatitaInit.add_cmdline_spec
37 ["-tptppath",Arg.String
38 (fun s -> Helm_registry.set_string "matita.tptppath" s),
39 "Where to find the Axioms/ and Problems/ directory"];
40 MatitaInit.initialize_all ()
43 (* let _ = Saturation.init () (* ALB to link paramodulation *) *)
45 (** {2 GUI callbacks} *)
47 let gui = MatitaGui.instance ()
52 ~source_view:gui#sourceView
53 ~mathviewer:(MatitaMathView.mathViewer ())
54 ~urichooser:(fun uris ->
56 MatitaGui.interactive_uri_choice ~selection_mode:`SINGLE
57 ~title:"Matita: URI chooser"
58 ~msg:"Select the URI" ~hide_uri_entry:true
59 ~hide_try:true ~ok_label:"_Apply" ~ok_action:`SELECT
60 ~copy_cb:(fun s -> gui#sourceView#buffer#insert ("\n"^s^"\n"))
62 with MatitaTypes.Cancel -> [])
65 (fun ~title ~message ->
66 MatitaGtkMisc.ask_confirmation ~title ~message
67 ~parent:gui#main#toplevel ())
70 Predefined_virtuals.load_predefined_virtuals ();
71 Predefined_virtuals.load_predefined_classes ();
72 gui#sourceView#source_buffer#begin_not_undoable_action ();
75 gui#sourceView#source_buffer#end_not_undoable_action ();
80 let sequents_viewer = MatitaMathView.sequentsViewer_instance () in
81 sequents_viewer#load_logo;
82 let browser_observer _ = MatitaMathView.refresh_all_browsers () in
83 let sequents_observer grafite_status =
84 sequents_viewer#reset;
85 match grafite_status#ng_mode with
87 sequents_viewer#nload_sequents grafite_status;
90 (Some (Continuationals.Stack.find_goal grafite_status#stack));
92 match script#goal with
96 sequents_viewer#goto_sequent grafite_status goal
97 with Failure _ -> script#setGoal None);
98 | `CommandMode -> sequents_viewer#load_logo
100 script#addObserver sequents_observer;
101 script#addObserver browser_observer
105 if BuildTimeConf.debug ||
106 Helm_registry.get_bool "matita.debug_menu"
108 gui#main#debugMenu#misc#show ();
109 let addDebugItem label callback =
111 GMenu.menu_item ~packing:gui#main#debugMenu_menu#append ~label () in
112 ignore (item#connect#activate callback)
114 let addDebugCheckbox label ?(init=false) callback =
116 GMenu.check_menu_item
117 ~packing:gui#main#debugMenu_menu#append ~label () in
118 item#set_active init;
119 ignore (item#connect#toggled (callback item))
121 let addDebugSeparator () =
122 ignore (GMenu.separator_item ~packing:gui#main#debugMenu_menu#append ())
124 addDebugItem "dump aliases" (fun _ ->
125 let status = script#grafite_status in
126 GrafiteDisambiguate.dump_aliases prerr_endline "" status);
128 addDebugItem "dump interpretations" (fun _ ->
129 let status = script#lexicon_status in
131 List.filter (function LexiconAst.Interpretation _ -> true | _ -> false)
133 HLog.debug (String.concat "\n"
135 (fun x l -> (LexiconAstPp.pp_command x)::l)
136 (filter status.LexiconEngine.lexicon_content_rev) [])));
138 addDebugSeparator ();
139 addDebugCheckbox "high level pretty printer" ~init:true
140 (fun mi () -> assert false (* MATITA 1.0 *));
141 addDebugSeparator ();
142 addDebugItem "always show all disambiguation errors"
143 (fun _ -> MatitaGui.all_disambiguation_passes := true);
144 addDebugItem "prune disambiguation errors"
145 (fun _ -> MatitaGui.all_disambiguation_passes := false);
146 addDebugSeparator ();
147 addDebugCheckbox "multiple disambiguation passes" ~init:true
148 (fun mi () -> MultiPassDisambiguator.only_one_pass := mi#active);
149 addDebugCheckbox "tactics logging"
150 (fun mi () -> NTacStatus.debug := mi#active);
151 addDebugCheckbox "disambiguation/refiner/unification/metasubst logging"
152 (fun mi () -> NCicRefiner.debug := mi#active; NCicUnification.debug :=
153 mi#active; MultiPassDisambiguator.debug := mi#active; NCicMetaSubst.debug := mi#active);
154 addDebugCheckbox "reduction logging"
155 (fun mi () -> NCicReduction.debug := mi#active);
156 addDebugSeparator ();
157 addDebugItem "Expand virtuals"
158 (fun _ -> (MatitaScript.current ())#expandAllVirtuals);
165 at_exit (fun () -> print_endline "\nThanks for using Matita!\n");
166 Sys.catch_break true;
167 let args = Helm_registry.get_list Helm_registry.string "matita.args" in
168 (try gui#loadScript (List.hd args) with Failure _ -> ());
169 gui#main#mainWin#show ();
173 Sys.set_signal Sys.sigint
176 prerr_endline "Still cleaning the library: don't be impatient!"));
177 prerr_endline "Matita is cleaning up. Please wait.";
179 (MatitaScript.current ())#grafite_status#baseuri
181 LibraryClean.clean_baseuris [baseuri]
183 (* vim:set foldmethod=marker: *)