]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matita.ml
snapshot
[helm.git] / helm / matita / matita.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 open MatitaGtkMisc
27
28 (** {2 Internal status} *)
29
30   (* TODO Zack: may be current_proofs if we want an MDI interface *)
31 let (current_proof: MatitaProof.proof option ref) = ref None
32
33 (** {2 Settings} *)
34
35 let untitled_con_uri = UriManager.uri_of_string "cic:/untitled.con"
36 let untitled_def_uri = UriManager.uri_of_string "cic:/untitled.def"
37
38 (** {2 Initialization} *)
39
40 let _ = Helm_registry.load_from "matita.conf.xml"
41 let _ = GMain.Main.init ()
42 let gui = new MatitaGui.gui (Helm_registry.get "matita.glade_file")
43 let parserr = new MatitaDisambiguator.parserr ()
44 let mqiconn = MQIConn.init ()
45 let disambiguator =
46   new MatitaDisambiguator.disambiguator ~parserr ~mqiconn
47     ~chooseUris:(interactive_user_uri_choice ~gui)
48     ~chooseInterp:(interactive_interp_choice ~gui)
49     ()
50
51   (** quit program, possibly asking for confirmation *)
52 let quit () = GMain.Main.quit ()
53
54 let _ =
55   gui#setQuitCallback quit;
56   gui#main#debugMenu#misc#hide ();
57   ignore (gui#main#newProofMenuItem#connect#activate (fun _ ->
58    if (!current_proof <> None) &&
59       not (ask_confirmation ~gui
60               ~msg:("Starting a new proof will abort current one,\n" ^
61                 "are you sure you want to continue?")
62               ())
63     then
64       ()  (* abort new proof process *)
65     else
66       let input = ask_text ~gui ~msg:"Insert proof goal" ~multiline:true () in
67       let (env, metasenv, term) =
68         disambiguator#disambiguateTerm (Stream.of_string input)
69       in
70       prerr_endline ("nuova prova: " ^ CicPp.ppterm term)
71       (* TODO Zack: FINQUI *)
72   ))
73
74   (** <DEBUGGING> *)
75 let _ =
76   if BuildTimeConf.debug then begin
77     gui#main#debugMenu#misc#show ();
78     let addDebugItem ~label callback =
79       let item =
80         GMenu.menu_item ~packing:gui#main#debugMenu_menu#append ~label ()
81       in
82       ignore (item#connect#activate callback)
83     in
84     addDebugItem "interactive user uri choice" (fun _ ->
85       try
86         let uris =
87           interactive_user_uri_choice ~gui ~selection_mode:`MULTIPLE
88             ~msg:"messaggio" ~nonvars_button:true
89             ["cic:/uno.con"; "cic:/due.var"; "cic:/tre.con"; "cic:/quattro.con";
90             "cic:/cinque.var"]
91         in
92         List.iter prerr_endline uris
93       with MatitaGtkMisc.Cancel -> MatitaTypes.error "no choice");
94     addDebugItem "toggle auto disambiguation" (fun _ ->
95       Helm_registry.set_bool "matita.auto_disambiguation"
96         (not (Helm_registry.get_bool "matita.auto_disambiguation")));
97     addDebugItem "mono line text input" (fun _ ->
98       prerr_endline (ask_text ~gui ~title:"title" ~msg:"message" ()));
99     addDebugItem "multi line text input" (fun _ ->
100       prerr_endline
101         (ask_text ~gui ~title:"title" ~multiline:true ~msg:"message" ()));
102   end
103   (** </DEBUGGING> *)
104
105 let _ = GtkThread.main ()
106