]> matita.cs.unibo.it Git - helm.git/commitdiff
snapshot:
authorStefano Zacchiroli <zack@upsilon.cc>
Thu, 11 Nov 2004 13:30:11 +0000 (13:30 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Thu, 11 Nov 2004 13:30:11 +0000 (13:30 +0000)
- changed interaction model

17 files changed:
helm/matita/buildTimeConf.ml.in
helm/matita/matita.glade
helm/matita/matita.ml
helm/matita/matitaConsole.ml
helm/matita/matitaConsole.mli
helm/matita/matitaDisambiguator.ml
helm/matita/matitaGeneratedGui.ml
helm/matita/matitaGeneratedGui.mli
helm/matita/matitaGtkMisc.ml
helm/matita/matitaGtkMisc.mli
helm/matita/matitaGui.ml
helm/matita/matitaGui.mli
helm/matita/matitaInterpreter.ml
helm/matita/matitaMathView.ml
helm/matita/matitaMisc.ml
helm/matita/matitaMisc.mli
helm/matita/matitaTypes.ml

index 249058f8b9d795ebcce09200faa1695def43501c..39efbf62b5864c58a91671e4b3404a6780d12feb 100644 (file)
@@ -29,4 +29,5 @@ let undo_history_size = 10;;
 let console_history_size = 100;;
 let gtkrc = "@MATITA_GTKRC@";;
 let base_uri = "cic:/matita";;
+let phrase_sep = ";;";;
 
index 5aac61297e8e608cc757d4d8adad918a07a23d54..291507c9b4fe0c5364ed618e3afae640ea3d5e78 100644 (file)
@@ -51,7 +51,7 @@
                          <property name="use_underline">True</property>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image128">
+                           <widget class="GtkImage" id="image164">
                              <property name="visible">True</property>
                              <property name="stock">gtk-new</property>
                              <property name="icon_size">1</property>
@@ -70,6 +70,7 @@
                                  <property name="visible">True</property>
                                  <property name="label" translatable="yes">_Proof or definition ...</property>
                                  <property name="use_underline">True</property>
+                                 <accelerator key="n" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                                </widget>
                              </child>
 
@@ -93,7 +94,7 @@
                          <accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image129">
+                           <widget class="GtkImage" id="image165">
                              <property name="visible">True</property>
                              <property name="stock">gtk-open</property>
                              <property name="icon_size">1</property>
                          <accelerator key="s" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image130">
+                           <widget class="GtkImage" id="image166">
                              <property name="visible">True</property>
                              <property name="stock">gtk-save</property>
                              <property name="icon_size">1</property>
                          <property name="use_underline">True</property>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image131">
+                           <widget class="GtkImage" id="image167">
                              <property name="visible">True</property>
                              <property name="stock">gtk-save-as</property>
                              <property name="icon_size">1</property>
                          <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                          <child internal-child="image">
-                           <widget class="GtkImage" id="image132">
+                           <widget class="GtkImage" id="image168">
                              <property name="visible">True</property>
                              <property name="stock">gtk-quit</property>
                              <property name="icon_size">1</property>
                          <accelerator key="F5" modifiers="0" signal="activate"/>
                        </widget>
                      </child>
+
+                     <child>
+                       <widget class="GtkSeparatorMenuItem" id="separator3">
+                         <property name="visible">True</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenuItem" id="ShowConsoleMenuItem">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Show console</property>
+                         <property name="use_underline">True</property>
+                         <accelerator key="x" modifiers="GDK_MOD1_MASK" signal="activate"/>
+                       </widget>
+                     </child>
                    </widget>
                  </child>
                </widget>
              <property name="position">450</property>
 
              <child>
-               <widget class="GtkScrolledWindow" id="ScrolledSequents">
+               <widget class="GtkNotebook" id="SequentsNotebook">
                  <property name="visible">True</property>
-                 <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
-                 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
-                 <property name="shadow_type">GTK_SHADOW_NONE</property>
-                 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
-                 <child>
-                   <widget class="GtkViewport" id="viewport1">
-                     <property name="visible">True</property>
-                     <property name="shadow_type">GTK_SHADOW_IN</property>
-
-                     <child>
-                       <widget class="GtkNotebook" id="SequentsNotebook">
-                         <property name="visible">True</property>
-                         <property name="can_focus">True</property>
-                         <property name="show_tabs">True</property>
-                         <property name="show_border">True</property>
-                         <property name="tab_pos">GTK_POS_TOP</property>
-                         <property name="scrollable">False</property>
-                         <property name="enable_popup">False</property>
-                       </widget>
-                     </child>
-                   </widget>
-                 </child>
+                 <property name="can_focus">True</property>
+                 <property name="show_tabs">True</property>
+                 <property name="show_border">True</property>
+                 <property name="tab_pos">GTK_POS_TOP</property>
+                 <property name="scrollable">False</property>
+                 <property name="enable_popup">False</property>
                </widget>
                <packing>
                  <property name="shrink">True</property>
                  <property name="above_child">False</property>
 
                  <child>
-                   <widget class="GtkScrolledWindow" id="ScrolledConsole">
+                   <widget class="GtkHBox" id="hbox4">
                      <property name="visible">True</property>
-                     <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-                     <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
-                     <property name="shadow_type">GTK_SHADOW_IN</property>
-                     <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
 
                      <child>
-                       <placeholder/>
+                       <widget class="GtkVBox" id="vbox6">
+                         <property name="visible">True</property>
+                         <property name="homogeneous">False</property>
+                         <property name="spacing">0</property>
+
+                         <child>
+                           <widget class="GtkButton" id="HideConsoleButton">
+                             <property name="visible">True</property>
+                             <property name="tooltip" translatable="yes">Hide console</property>
+                             <property name="can_focus">True</property>
+                             <property name="relief">GTK_RELIEF_NORMAL</property>
+                             <property name="focus_on_click">True</property>
+
+                             <child>
+                               <widget class="GtkImage" id="image169">
+                                 <property name="visible">True</property>
+                                 <property name="stock">gtk-close</property>
+                                 <property name="icon_size">4</property>
+                                 <property name="xalign">0.5</property>
+                                 <property name="yalign">0.5</property>
+                                 <property name="xpad">0</property>
+                                 <property name="ypad">0</property>
+                               </widget>
+                             </child>
+                           </widget>
+                           <packing>
+                             <property name="padding">0</property>
+                             <property name="expand">False</property>
+                             <property name="fill">False</property>
+                           </packing>
+                         </child>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkScrolledWindow" id="ScrolledConsole">
+                         <property name="visible">True</property>
+                         <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                         <property name="shadow_type">GTK_SHADOW_IN</property>
+                         <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+                         <child>
+                           <placeholder/>
+                         </child>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
                      </child>
                    </widget>
                  </child>
       <child>
        <widget class="GtkScrolledWindow" id="ScrolledProof">
          <property name="visible">True</property>
-         <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
-         <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
-         <property name="shadow_type">GTK_SHADOW_NONE</property>
+         <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+         <property name="shadow_type">GTK_SHADOW_IN</property>
          <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
 
          <child>
 </widget>
 
 <widget class="GtkWindow" id="ToolBarWin">
-  <property name="width_request">150</property>
+  <property name="width_request">155</property>
   <property name="height_request">450</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Tactics</property>
 
                  <child>
                    <widget class="GtkButton" id="introsButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Intros</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="applyButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Apply</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="exactButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Exact</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="elimButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Elim</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="elimTypeButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">ElimType</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="splitButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Split</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="leftButton">
+                     <property name="width_request">25</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Left</property>
                      <property name="can_focus">True</property>
-                     <property name="label" translatable="yes">left</property>
+                     <property name="label" translatable="yes">L</property>
                      <property name="use_underline">True</property>
                      <property name="relief">GTK_RELIEF_NORMAL</property>
                      <property name="focus_on_click">True</property>
 
                  <child>
                    <widget class="GtkButton" id="rightButton">
+                     <property name="width_request">25</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Right</property>
                      <property name="can_focus">True</property>
-                     <property name="label" translatable="yes">right</property>
+                     <property name="label" translatable="yes">R</property>
                      <property name="use_underline">True</property>
                      <property name="relief">GTK_RELIEF_NORMAL</property>
                      <property name="focus_on_click">True</property>
 
                  <child>
                    <widget class="GtkButton" id="existsButton">
+                     <property name="width_request">25</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Exists</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="reflexivityButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Reflexivity</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="symmetryButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Symmetry</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="transitivityButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Transitivity</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="assumptionButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Assumption</property>
                      <property name="can_focus">True</property>
-                     <property name="label" translatable="yes">assum</property>
+                     <property name="label" translatable="yes">asum</property>
                      <property name="use_underline">True</property>
                      <property name="relief">GTK_RELIEF_NORMAL</property>
                      <property name="focus_on_click">True</property>
                  <property name="visible_vertical">True</property>
                  <property name="is_important">False</property>
 
-                 <child>
-                   <widget class="GtkButton" id="searchButton">
-                     <property name="visible">True</property>
-                     <property name="tooltip" translatable="yes">Search</property>
-                     <property name="can_focus">True</property>
-                     <property name="label" translatable="yes">search</property>
-                     <property name="use_underline">True</property>
-                     <property name="relief">GTK_RELIEF_NORMAL</property>
-                     <property name="focus_on_click">True</property>
-                   </widget>
-                 </child>
-               </widget>
-               <packing>
-                 <property name="expand">False</property>
-                 <property name="homogeneous">False</property>
-               </packing>
-             </child>
-
-             <child>
-               <widget class="GtkToolItem" id="toolitem19">
-                 <property name="visible">True</property>
-                 <property name="visible_horizontal">True</property>
-                 <property name="visible_vertical">True</property>
-                 <property name="is_important">False</property>
-
                  <child>
                    <widget class="GtkButton" id="autoButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Auto</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="cutButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Cut</property>
                      <property name="can_focus">True</property>
 
                  <child>
                    <widget class="GtkButton" id="replaceButton">
+                     <property name="width_request">50</property>
                      <property name="visible">True</property>
                      <property name="tooltip" translatable="yes">Replace</property>
                      <property name="can_focus">True</property>
@@ -1724,9 +1767,9 @@ Copyright (C) 2004,
        <widget class="GtkScrolledWindow" id="ScrolledCheck">
          <property name="visible">True</property>
          <property name="can_focus">True</property>
-         <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
-         <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
-         <property name="shadow_type">GTK_SHADOW_NONE</property>
+         <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+         <property name="shadow_type">GTK_SHADOW_IN</property>
          <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
 
          <child>
index 6a5e2e51debf5c20bedc785d079ffba14e357c60..fad12b563772db8166e0c850c46fae22402211b2 100644 (file)
@@ -72,7 +72,6 @@ let sequents_viewer =
     ~sequent_viewer ~set_goal ()
 
 let new_proof (proof: MatitaTypes.proof) =
-  let xmldump_observer _ _ =  print_endline proof#toString in
   let proof_observer _ (status, ()) =
     let ((uri_opt, _, _, _), _) = status in
     proof_viewer#load_proof status;
@@ -89,10 +88,6 @@ let new_proof (proof: MatitaTypes.proof) =
     sequents_observer);
   ignore (proof#attach_observer ~interested_in:StatefulProofEngine.all_events
     proof_observer);
-(*
-  ignore (proof#attach_observer ~interested_in:StatefulProofEngine.all_events
-    xmldump_observer);
-*)
   proof#notify;
   set_proof (Some proof)
 
@@ -122,22 +117,16 @@ let interpreter =
   let console = gui#console in
   new MatitaInterpreter.interpreter ~disambiguator ~proof_handler ~console ()
 
-  (** prompt the user for the textual input of a term and disambiguate it *)
-let ask_term ?(title = "term input") ?(msg = "insert term") () =
-  match gui#askText ~title ~msg () with
-  | Some t ->
-      let (_, _, term) = disambiguator#disambiguateTerm (Stream.of_string t) in
-      Some term
-  | None -> None
-
 (** {2 Script window handling} *)
 
 let script_forward _ =
   let buf = gui#script#scriptTextView#buffer in
   let locked_iter = buf#get_iter_at_mark (`NAME "locked") in
-  interpreter#evalPhrase
-    (buf#get_text ~start:locked_iter ~stop:buf#end_iter ());
-  gui#lockScript (locked_iter#offset + interpreter#endOffset)
+  if
+    interpreter#evalPhrase
+      (buf#get_text ~start:locked_iter ~stop:buf#end_iter ());
+  then
+    gui#lockScript (locked_iter#offset + interpreter#endOffset)
 
 let script_jump _ =
   let buf = gui#script#scriptTextView#buffer in
@@ -147,16 +136,20 @@ let script_jump _ =
   let len = String.length raw_text in
   let rec parse offset =
     if offset < len then begin
-      interpreter#evalPhrase ~transparent:true
-        (String.sub raw_text offset (len - offset));
-      let new_offset = interpreter#endOffset + offset in
-      gui#lockScript (new_offset + locked_iter#offset);
-      parse new_offset
+      if
+        interpreter#evalPhrase ~transparent:true
+          (String.sub raw_text offset (len - offset));
+      then begin
+        let new_offset = interpreter#endOffset + offset in
+        gui#lockScript (new_offset + locked_iter#offset);
+        parse new_offset
+      end else
+        raise Exit
     end
   in
   try
     parse 0
-  with CicTextualParser2.Parse_error _ -> ()
+  with Exit -> ()
 
 let script_back _ = not_implemented "script_back"
 
@@ -171,20 +164,8 @@ let _ =
   gui#setQuitCallback quit;
   gui#setPhraseCallback interpreter#evalPhrase;
   gui#main#debugMenu#misc#hide ();
-  ignore (gui#main#newProofMenuItem#connect#activate (fun _ ->
-   if has_proof () &&
-      not (ask_confirmation ~gui
-        ~msg:("Proof in progress, are you sure you want to start a new one?")
-        ())
-    then
-      ()  (* abort new proof process *)
-    else
-      let input = ask_text ~gui ~msg:"Insert proof goal" ~multiline:true () in
-      let (env, metasenv, expr) =
-        disambiguator#disambiguateTerm (Stream.of_string input)
-      in
-      let proof = MatitaProof.proof ~typ:expr ~metasenv () in
-      new_proof proof));
+  ignore (gui#main#newProofMenuItem#connect#activate
+    (gui#console#show ~msg:"theorem "));
   ignore (gui#main#openMenuItem#connect#activate (fun _ ->
     match gui#chooseFile () with
     | None -> ()
@@ -193,47 +174,36 @@ let _ =
         gui#console#echo_error (sprintf
           "Don't know what to do with file: %s\nUnrecognized file format."
           f)));
-  ignore (gui#script#scriptWinForwardButton#connect#clicked script_forward);
-  ignore (gui#script#scriptWinBackButton#connect#clicked script_back);
-  ignore (gui#script#scriptWinJumpButton#connect#clicked script_jump);
-  let tac_w_term name tac _ =
-    match ask_term ~title:name ~msg:("term for " ^ name) () with
-    | Some term -> (get_proof ())#apply_tactic (tac ~term)
-    | None -> ()
+  connect_button gui#script#scriptWinForwardButton script_forward;
+  connect_button gui#script#scriptWinBackButton script_back;
+  connect_button gui#script#scriptWinJumpButton script_jump;
+  let module A = TacticAst in
+  let hole = CicAst.UserInput in
+  let tac ast _ = ignore (interpreter#evalAst (A.Tactic ast)) in
+  let tac_w_term ast _ =
+    gui#console#clear ();
+    gui#console#show ~msg:(TacticAstPp.pp_tactic ast) ();
+    gui#main#mainWin#present ()
   in
-  let tac _ tac _ = (get_proof ())#apply_tactic tac in
   let tbar = gui#toolbar in
-  ignore (tbar#introsButton#connect#clicked (tac "intros" (Tactics.intros ())));
-  ignore (tbar#applyButton#connect#clicked (tac_w_term "apply" Tactics.apply));
-  ignore (tbar#exactButton#connect#clicked (tac_w_term "exact" Tactics.exact));
-  ignore (tbar#elimButton#connect#clicked (tac_w_term "elim"
-    Tactics.elim_intros_simpl));
-  ignore (tbar#elimTypeButton#connect#clicked (tac_w_term "elim type"
-    Tactics.elim_type));
-  ignore (tbar#splitButton#connect#clicked (tac "split" Tactics.split));
-  ignore (tbar#leftButton#connect#clicked (tac "left" Tactics.left));
-  ignore (tbar#rightButton#connect#clicked (tac "right" Tactics.right));
-  ignore (tbar#existsButton#connect#clicked (tac "exists" Tactics.exists));
-  ignore (tbar#reflexivityButton#connect#clicked (tac "reflexivity"
-    Tactics.reflexivity));
-  ignore (tbar#symmetryButton#connect#clicked (tac "symmetry"
-    Tactics.symmetry));
-  ignore (tbar#transitivityButton#connect#clicked (tac_w_term "transitivity"
-    Tactics.transitivity));
-  ignore (tbar#assumptionButton#connect#clicked (tac "assumption"
-    Tactics.assumption));
-  ignore (tbar#cutButton#connect#clicked (tac_w_term "cut"
-    (Tactics.cut ?mk_fresh_name_callback:None)));
-  ignore (tbar#autoButton#connect#clicked (tac "auto" (Tactics.auto ~dbd)))
+  connect_button tbar#introsButton (tac (A.Intros (None, [])));
+  connect_button tbar#applyButton (tac_w_term (A.Apply hole));
+  connect_button tbar#exactButton (tac_w_term (A.Exact hole));
+  connect_button tbar#elimButton (tac_w_term (A.Elim (hole, None)));
+  connect_button tbar#elimTypeButton (tac_w_term (A.ElimType hole));
+  connect_button tbar#splitButton (tac A.Split);
+  connect_button tbar#leftButton (tac A.Left);
+  connect_button tbar#rightButton (tac A.Right);
+  connect_button tbar#existsButton (tac A.Exists);
+  connect_button tbar#reflexivityButton (tac A.Reflexivity);
+  connect_button tbar#symmetryButton (tac A.Symmetry);
+  connect_button tbar#transitivityButton (tac_w_term (A.Transitivity hole));
+  connect_button tbar#assumptionButton (tac A.Assumption);
+  connect_button tbar#cutButton (tac_w_term (A.Cut hole));
+  connect_button tbar#autoButton (tac A.Auto)
 
   (** <DEBUGGING> *)
 
-let save_dom =
-  let domImpl = lazy (Gdome.domImplementation ()) in
-  fun ~doc ~dest ->
-    ignore
-      ((Lazy.force domImpl)#saveDocumentToFile ~doc ~name:dest ~indent:true ())
-
 let _ =
   if BuildTimeConf.debug then begin
     gui#main#debugMenu#misc#show ();
@@ -243,26 +213,13 @@ let _ =
       in
       ignore (item#connect#activate callback)
     in
-    addDebugItem "interactive user uri choice" (fun _ ->
-      try
-        let uris =
-          interactive_user_uri_choice ~gui ~selection_mode:`MULTIPLE
-            ~msg:"messaggio" ~nonvars_button:true
-            ["cic:/uno.con"; "cic:/due.var"; "cic:/tre.con"; "cic:/quattro.con";
-            "cic:/cinque.var"]
-        in
-        List.iter prerr_endline uris
-      with MatitaGtkMisc.Cancel -> MatitaTypes.error "no choice");
     addDebugItem "toggle auto disambiguation" (fun _ ->
       Helm_registry.set_bool "matita.auto_disambiguation"
         (not (Helm_registry.get_bool "matita.auto_disambiguation")));
-    addDebugItem "mono line text input" (fun _ ->
-      prerr_endline (ask_text ~gui ~title:"title" ~msg:"message" ()));
-    addDebugItem "multi line text input" (fun _ ->
-      prerr_endline
-        (ask_text ~gui ~title:"title" ~multiline:true ~msg:"message" ()));
     addDebugItem "dump proof status to stdout" (fun _ ->
       print_endline ((get_proof ())#toString));
+    addDebugItem "hide console" gui#console#hide;
+    addDebugItem "show console" gui#console#show;
   end
 
   (** </DEBUGGING> *)
index eb77ffa5d62ac8f95bac2b34ff198cd438f8ceaf..810914393549a720125bcfab14c8d51ab0e024d0 100644 (file)
  * http://helm.cs.unibo.it/
  *)
 
-let default_prompt = "# "
+open Printf
+
+open MatitaTypes
+
+(* let default_prompt = "# " *)
+let default_prompt = ""
 let default_phrase_sep = "."
-let default_callback = fun (phrase: string) -> ()
+let default_callback = fun (phrase: string) -> true
 
 let message_props = [ `STYLE `ITALIC ]
 let error_props = [ `WEIGHT `BOLD ]
@@ -63,7 +68,7 @@ class history size =
 
 class console
   ?(prompt = default_prompt) ?(phrase_sep = default_phrase_sep)
-  ?(callback = default_callback) ?evbox obj
+  ?(callback = default_callback) ?evbox ~(paned:GPack.paned) obj
 =
   object (self)
     inherit GText.view obj
@@ -85,9 +90,12 @@ class console
 
     val history = new history BuildTimeConf.console_history_size
 
+    val mutable handle_position = 450
+
     initializer
       let buf = self#buffer in
       self#set_wrap_mode `CHAR;
+      self#hide ();
         (* create "USER_INPUT_START" mark. This mark will always point to the
         * beginning of user input not yet processed *)
       ignore (buf#create_mark ~name:"USER_INPUT_START"
@@ -135,7 +143,14 @@ class console
       history#add (* do not push trailing phrase separator *)
         (String.sub phrase 0
           (String.length phrase - String.length _phrase_sep));
-      _callback phrase
+      if _callback phrase then
+        self#hide ()
+        (* else callback encountered troubles, don't hide console which
+        probably contains error message *)
+
+    method clear () =
+      let buf = self#buffer in
+      buf#delete ~start:buf#start_iter ~stop:buf#end_iter
 
       (* lock old text and bump USER_INPUT_START mark *)
     method private lock =
@@ -160,13 +175,21 @@ class console
       self#lock
 
     method echo_error msg =
+      self#show ();
       let buf = self#buffer in
       self#ignore_insert_text_signal true;
       buf#insert ~iter:buf#end_iter ~tags:[buf#create_tag error_props]
         (msg ^ "\n");
       self#ignore_insert_text_signal false;
       self#lock
-(*       self#echo_prompt () *)
+
+    method show ?(msg = "") () =
+      self#buffer#insert msg;
+      paned#set_position handle_position;
+      self#misc#grab_focus ()
+    method hide () =
+      self#clear ();
+      paned#set_position max_int
 
       (** navigation methods: history, cursor motion, ... *)
 
@@ -175,11 +198,18 @@ class console
     method private next_phrase =
       try self#set_phrase history#next with History_failure -> ()
 
+    method wrap_exn f =
+      try
+        f ()
+      with exn ->
+        self#echo_error (sprintf "Uncaught exception: %s"
+          (Printexc.to_string exn))
+
   end
 
 let console
   ?(prompt = default_prompt) ?(phrase_sep = default_phrase_sep)
-  ?(callback = default_callback) ?evbox
+  ?(callback = default_callback) ?evbox ~paned
   ?buffer ?editable ?cursor_visible ?justification ?wrap_mode ?border_width
   ?width ?height ?packing ?show ()
 =
@@ -188,5 +218,5 @@ let console
       ?buffer ?editable ?cursor_visible ?justification ?wrap_mode ?border_width
       ?width ?height ?packing ?show ()
   in
-  new console ~prompt ~phrase_sep ~callback ?evbox view#as_view
+  new console ~prompt ~phrase_sep ~callback ?evbox ~paned view#as_view
 
index 950776135426b6b1aa941f0c0aa05d9efebb0351..d591e25e2e43e1c3bad9d43beeacaedbe5924801 100644 (file)
   (** @param evbox event box to which keyboard shortcuts are registered; no
   * shortcut will be registered if evbox is not given *)
 class console:
-  ?prompt:string -> ?phrase_sep:string -> ?callback:(string -> unit) ->
-  ?evbox:GBin.event_box -> Gtk.text_view Gtk.obj ->
+  ?prompt:string -> ?phrase_sep:string -> ?callback:(string -> bool) ->
+  ?evbox:GBin.event_box -> paned:GPack.paned -> Gtk.text_view Gtk.obj ->
   object
     inherit GText.view
 
     method echo_prompt    : unit -> unit
     method echo_message   : string -> unit
     method echo_error     : string -> unit
+    method clear          : unit -> unit
+
+      (* console visibility handling inside VPaned *)
+
+      (** @param msg if given, show the console with a prefeed input, cursor
+      * just after it; defaults to the empty string *)
+    method show           : ?msg:string -> unit -> unit
+    method hide           : unit -> unit
+(*     method toggle         : unit -> unit *)
 
     method prompt         : string
     method set_prompt     : string -> unit
@@ -42,9 +51,13 @@ class console:
     method set_phrase_sep : string -> unit
 
       (** override previous callback definition *)
-    method set_callback   : (string -> unit) -> unit
+    method set_callback   : (string -> bool) -> unit
 
     method ignore_insert_text_signal: bool -> unit
+
+      (** execute a unit -> unit function, if it raises exceptions shows them as
+      * errors in the console *)
+    method wrap_exn       : (unit -> unit) -> unit
   end
 
   (** @param prompt user prompt (default "# ")
@@ -55,8 +68,9 @@ class console:
 val console :
   ?prompt:string ->
   ?phrase_sep:string ->
-  ?callback:(string -> unit) ->
+  ?callback:(string -> bool) ->
   ?evbox:GBin.event_box ->
+  paned:GPack.paned ->
 
   ?buffer:GText.buffer ->
   ?editable:bool ->
index 01e85e0c45c0f4ba42bffa85c6d29902c955a275..bb7f2807dee162fe600850abe176d99dd214a773 100644 (file)
@@ -23,6 +23,8 @@
  * http://helm.cs.unibo.it/
  *)
 
+open MatitaTypes
+
 class parserr () =
   object
     method parseTerm = CicTextualParser2.parse_term
@@ -44,12 +46,12 @@ class disambiguator
             ~nonvars_button:enable_button_for_non_vars uris
 
         let interactive_interpretation_choice = chooseInterp
-        let input_or_locate_uri ~(title:string) =
-          (* TODO Zack: I try to avoid using this callback. I therefore assume
-           * that the presence of an identifier that can't be resolved via
-           * "locate" query is a syntax error *)
-          MatitaTypes.not_implemented
-            "MatitaDisambiguator: input_or_locate_uri callback"
+        let input_or_locate_uri ~(title:string) ?id =
+          (* Zack: I try to avoid using this callback. I therefore assume that
+          * the presence of an identifier that can't be resolved via "locate"
+          * query is a syntax error *)
+          let msg = match id with Some id -> id | _ -> "" in
+          raise (Unbound_identifier msg)
       end
     in
     let module Disambiguator = Disambiguate.Make (Callbacks) in
index a4423041f80fe755d9580187f81d0de06d38de43..afbf9e28873379c9829cb5446894511e558a05ef 100644 (file)
@@ -36,10 +36,10 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GMenu.image_menu_item (GtkMenu.ImageMenuItem.cast
         (Glade.get_widget_msg ~name:"NewMenu" ~info:"GtkImageMenuItem" xmldata))
     method newMenu = newMenu
-    val image128 =
+    val image164 =
       new GMisc.image (GtkMisc.Image.cast
-        (Glade.get_widget_msg ~name:"image128" ~info:"GtkImage" xmldata))
-    method image128 = image128
+        (Glade.get_widget_msg ~name:"image164" ~info:"GtkImage" xmldata))
+    method image164 = image164
     val newMenu_menu =
       new GMenu.menu (GtkMenu.Menu.cast
         (Glade.get_widget_msg ~name:"NewMenu_menu" ~info:"GtkMenu" xmldata))
@@ -56,26 +56,26 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GMenu.image_menu_item (GtkMenu.ImageMenuItem.cast
         (Glade.get_widget_msg ~name:"OpenMenuItem" ~info:"GtkImageMenuItem" xmldata))
     method openMenuItem = openMenuItem
-    val image129 =
+    val image165 =
       new GMisc.image (GtkMisc.Image.cast
-        (Glade.get_widget_msg ~name:"image129" ~info:"GtkImage" xmldata))
-    method image129 = image129
+        (Glade.get_widget_msg ~name:"image165" ~info:"GtkImage" xmldata))
+    method image165 = image165
     val saveMenuItem =
       new GMenu.image_menu_item (GtkMenu.ImageMenuItem.cast
         (Glade.get_widget_msg ~name:"SaveMenuItem" ~info:"GtkImageMenuItem" xmldata))
     method saveMenuItem = saveMenuItem
-    val image130 =
+    val image166 =
       new GMisc.image (GtkMisc.Image.cast
-        (Glade.get_widget_msg ~name:"image130" ~info:"GtkImage" xmldata))
-    method image130 = image130
+        (Glade.get_widget_msg ~name:"image166" ~info:"GtkImage" xmldata))
+    method image166 = image166
     val saveAsMenuItem =
       new GMenu.image_menu_item (GtkMenu.ImageMenuItem.cast
         (Glade.get_widget_msg ~name:"SaveAsMenuItem" ~info:"GtkImageMenuItem" xmldata))
     method saveAsMenuItem = saveAsMenuItem
-    val image131 =
+    val image167 =
       new GMisc.image (GtkMisc.Image.cast
-        (Glade.get_widget_msg ~name:"image131" ~info:"GtkImage" xmldata))
-    method image131 = image131
+        (Glade.get_widget_msg ~name:"image167" ~info:"GtkImage" xmldata))
+    method image167 = image167
     val separator1 =
       new GMenu.menu_item (GtkMenu.MenuItem.cast
         (Glade.get_widget_msg ~name:"separator1" ~info:"GtkSeparatorMenuItem" xmldata))
@@ -84,10 +84,10 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GMenu.image_menu_item (GtkMenu.ImageMenuItem.cast
         (Glade.get_widget_msg ~name:"QuitMenuItem" ~info:"GtkImageMenuItem" xmldata))
     method quitMenuItem = quitMenuItem
-    val image132 =
+    val image168 =
       new GMisc.image (GtkMisc.Image.cast
-        (Glade.get_widget_msg ~name:"image132" ~info:"GtkImage" xmldata))
-    method image132 = image132
+        (Glade.get_widget_msg ~name:"image168" ~info:"GtkImage" xmldata))
+    method image168 = image168
     val editMenu =
       new GMenu.menu_item (GtkMenu.MenuItem.cast
         (Glade.get_widget_msg ~name:"EditMenu" ~info:"GtkMenuItem" xmldata))
@@ -116,6 +116,14 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GMenu.check_menu_item (GtkMenu.CheckMenuItem.cast
         (Glade.get_widget_msg ~name:"ShowScriptMenuItem" ~info:"GtkCheckMenuItem" xmldata))
     method showScriptMenuItem = showScriptMenuItem
+    val separator3 =
+      new GMenu.menu_item (GtkMenu.MenuItem.cast
+        (Glade.get_widget_msg ~name:"separator3" ~info:"GtkSeparatorMenuItem" xmldata))
+    method separator3 = separator3
+    val showConsoleMenuItem =
+      new GMenu.menu_item (GtkMenu.MenuItem.cast
+        (Glade.get_widget_msg ~name:"ShowConsoleMenuItem" ~info:"GtkMenuItem" xmldata))
+    method showConsoleMenuItem = showConsoleMenuItem
     val debugMenu =
       new GMenu.menu_item (GtkMenu.MenuItem.cast
         (Glade.get_widget_msg ~name:"DebugMenu" ~info:"GtkMenuItem" xmldata))
@@ -144,14 +152,6 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GPack.paned (GtkPack.Paned.cast
         (Glade.get_widget_msg ~name:"MainVPanes" ~info:"GtkVPaned" xmldata))
     method mainVPanes = mainVPanes
-    val scrolledSequents =
-      new GBin.scrolled_window (GtkBin.ScrolledWindow.cast
-        (Glade.get_widget_msg ~name:"ScrolledSequents" ~info:"GtkScrolledWindow" xmldata))
-    method scrolledSequents = scrolledSequents
-    val viewport1 =
-      new GBin.viewport (GtkBin.Viewport.cast
-        (Glade.get_widget_msg ~name:"viewport1" ~info:"GtkViewport" xmldata))
-    method viewport1 = viewport1
     val sequentsNotebook =
       new GPack.notebook (GtkPack.Notebook.cast
         (Glade.get_widget_msg ~name:"SequentsNotebook" ~info:"GtkNotebook" xmldata))
@@ -160,6 +160,22 @@ class mainWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GBin.event_box (GtkBin.EventBox.cast
         (Glade.get_widget_msg ~name:"ConsoleEventBox" ~info:"GtkEventBox" xmldata))
     method consoleEventBox = consoleEventBox
+    val hbox4 =
+      new GPack.box (GtkPack.Box.cast
+        (Glade.get_widget_msg ~name:"hbox4" ~info:"GtkHBox" xmldata))
+    method hbox4 = hbox4
+    val vbox6 =
+      new GPack.box (GtkPack.Box.cast
+        (Glade.get_widget_msg ~name:"vbox6" ~info:"GtkVBox" xmldata))
+    method vbox6 = vbox6
+    val hideConsoleButton =
+      new GButton.button (GtkButton.Button.cast
+        (Glade.get_widget_msg ~name:"HideConsoleButton" ~info:"GtkButton" xmldata))
+    method hideConsoleButton = hideConsoleButton
+    val image169 =
+      new GMisc.image (GtkMisc.Image.cast
+        (Glade.get_widget_msg ~name:"image169" ~info:"GtkImage" xmldata))
+    method image169 = image169
     val scrolledConsole =
       new GBin.scrolled_window (GtkBin.ScrolledWindow.cast
         (Glade.get_widget_msg ~name:"ScrolledConsole" ~info:"GtkScrolledWindow" xmldata))
@@ -312,10 +328,6 @@ class toolBarWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       new GButton.button (GtkButton.Button.cast
         (Glade.get_widget_msg ~name:"assumptionButton" ~info:"GtkButton" xmldata))
     method assumptionButton = assumptionButton
-    val searchButton =
-      new GButton.button (GtkButton.Button.cast
-        (Glade.get_widget_msg ~name:"searchButton" ~info:"GtkButton" xmldata))
-    method searchButton = searchButton
     val autoButton =
       new GButton.button (GtkButton.Button.cast
         (Glade.get_widget_msg ~name:"autoButton" ~info:"GtkButton" xmldata))
index 28beebc27bed5ec26ba079c8709b5c4222a85ff8..a85860cfbf784a5cd95b420e88746ca2ac13e653 100644 (file)
@@ -11,13 +11,16 @@ class mainWin :
     val editMenu : GMenu.menu_item
     val fileMenu : GMenu.menu_item
     val fileMenu_menu : GMenu.menu
+    val hbox4 : GPack.box
     val helpMenu : GMenu.menu_item
     val helpMenu_menu : GMenu.menu
-    val image128 : GMisc.image
-    val image129 : GMisc.image
-    val image130 : GMisc.image
-    val image131 : GMisc.image
-    val image132 : GMisc.image
+    val hideConsoleButton : GButton.button
+    val image164 : GMisc.image
+    val image165 : GMisc.image
+    val image166 : GMisc.image
+    val image167 : GMisc.image
+    val image168 : GMisc.image
+    val image169 : GMisc.image
     val mainMenuBar : GMenu.menu_shell
     val mainStatusBar : GMisc.statusbar
     val mainVPanes : GPack.paned
@@ -33,18 +36,19 @@ class mainWin :
     val saveAsMenuItem : GMenu.image_menu_item
     val saveMenuItem : GMenu.image_menu_item
     val scrolledConsole : GBin.scrolled_window
-    val scrolledSequents : GBin.scrolled_window
     val separator1 : GMenu.menu_item
     val separator2 : GMenu.menu_item
+    val separator3 : GMenu.menu_item
     val sequentsNotebook : GPack.notebook
     val showCheckMenuItem : GMenu.check_menu_item
+    val showConsoleMenuItem : GMenu.menu_item
     val showProofMenuItem : GMenu.check_menu_item
     val showScriptMenuItem : GMenu.check_menu_item
     val showToolBarMenuItem : GMenu.check_menu_item
     val toplevel : GWindow.window
+    val vbox6 : GPack.box
     val viewMenu : GMenu.menu_item
     val viewMenu_menu : GMenu.menu
-    val viewport1 : GBin.viewport
     val xml : Glade.glade_xml Gtk.obj
     method aboutMenuItem : GMenu.menu_item
     method bind : name:string -> callback:(unit -> unit) -> unit
@@ -55,13 +59,16 @@ class mainWin :
     method editMenu : GMenu.menu_item
     method fileMenu : GMenu.menu_item
     method fileMenu_menu : GMenu.menu
+    method hbox4 : GPack.box
     method helpMenu : GMenu.menu_item
     method helpMenu_menu : GMenu.menu
-    method image128 : GMisc.image
-    method image129 : GMisc.image
-    method image130 : GMisc.image
-    method image131 : GMisc.image
-    method image132 : GMisc.image
+    method hideConsoleButton : GButton.button
+    method image164 : GMisc.image
+    method image165 : GMisc.image
+    method image166 : GMisc.image
+    method image167 : GMisc.image
+    method image168 : GMisc.image
+    method image169 : GMisc.image
     method mainMenuBar : GMenu.menu_shell
     method mainStatusBar : GMisc.statusbar
     method mainVPanes : GPack.paned
@@ -78,18 +85,19 @@ class mainWin :
     method saveAsMenuItem : GMenu.image_menu_item
     method saveMenuItem : GMenu.image_menu_item
     method scrolledConsole : GBin.scrolled_window
-    method scrolledSequents : GBin.scrolled_window
     method separator1 : GMenu.menu_item
     method separator2 : GMenu.menu_item
+    method separator3 : GMenu.menu_item
     method sequentsNotebook : GPack.notebook
     method showCheckMenuItem : GMenu.check_menu_item
+    method showConsoleMenuItem : GMenu.menu_item
     method showProofMenuItem : GMenu.check_menu_item
     method showScriptMenuItem : GMenu.check_menu_item
     method showToolBarMenuItem : GMenu.check_menu_item
     method toplevel : GWindow.window
+    method vbox6 : GPack.box
     method viewMenu : GMenu.menu_item
     method viewMenu_menu : GMenu.menu
-    method viewport1 : GBin.viewport
     method xml : Glade.glade_xml Gtk.obj
   end
 class proofWin :
@@ -150,7 +158,6 @@ class toolBarWin :
     val reflexivityButton : GButton.button
     val replaceButton : GButton.button
     val rightButton : GButton.button
-    val searchButton : GButton.button
     val splitButton : GButton.button
     val symmetryButton : GButton.button
     val toolBarEventBox : GBin.event_box
@@ -181,7 +188,6 @@ class toolBarWin :
     method reparent : GObj.widget -> unit
     method replaceButton : GButton.button
     method rightButton : GButton.button
-    method searchButton : GButton.button
     method splitButton : GButton.button
     method symmetryButton : GButton.button
     method toolBarEventBox : GBin.event_box
index 874c75c590a8a9ee04d73380dae16ea553cb7152..aebd2dbc9e536859514474c428abd2bdfeca7906 100644 (file)
@@ -27,6 +27,9 @@ open Printf
 
 open MatitaTypes
 
+let connect_button (button: GButton.button) callback =
+  ignore (button#connect#clicked callback)
+
 let toggle_visibility ~(win: GWindow.window) ~(check: GMenu.check_menu_item) =
   ignore (check#connect#toggled (fun _ ->
     if check#active then win#show () else win#misc#hide ()));
@@ -142,8 +145,6 @@ class type gui =
     method newEmptyDialog:        unit -> MatitaGeneratedGui.emptyDialog
   end
 
-exception Cancel
-
 let interactive_user_uri_choice
   ~(gui:#gui) ~(selection_mode:[`SINGLE|`MULTIPLE]) ?(title = "")
   ?(msg = "") ?(nonvars_button=false) uris
@@ -170,16 +171,16 @@ let interactive_user_uri_choice
       GMain.Main.quit ()
     in
     ignore (dialog#uriChoiceDialog#event#connect#delete (fun _ -> true));
-    ignore (dialog#uriChoiceConstantsButton#connect#clicked (fun _ ->
-      return (Some (Lazy.force nonvars_uris))));
-    ignore (dialog#uriChoiceAutoButton#connect#clicked (fun _ ->
+    connect_button dialog#uriChoiceConstantsButton (fun _ ->
+      return (Some (Lazy.force nonvars_uris)));
+    connect_button dialog#uriChoiceAutoButton (fun _ ->
       Helm_registry.set_bool "matita.auto_disambiguation" true;
-      return (Some (Lazy.force nonvars_uris))));
-    ignore (dialog#uriChoiceSelectedButton#connect#clicked (fun _ ->
+      return (Some (Lazy.force nonvars_uris)));
+    connect_button dialog#uriChoiceSelectedButton (fun _ ->
       match model#easy_selection () with
       | [] -> ()
-      | uris -> return (Some uris)));
-    ignore (dialog#uriChoiceAbortButton#connect#clicked (fun _ -> return None));
+      | uris -> return (Some uris));
+    connect_button dialog#uriChoiceAbortButton (fun _ -> return None);
     dialog#uriChoiceDialog#show ();
     GtkThread.main ();
     (match !choices with 
@@ -199,10 +200,11 @@ let interactive_interp_choice ~(gui:#gui) choices =
     dialog#interpChoiceDialog#destroy ();
     GMain.Main.quit ()
   in
+  let fail _ = interp_no := None; return () in
   ignore (dialog#interpChoiceDialog#event#connect#delete (fun _ -> true));
-  ignore (dialog#interpChoiceOkButton#connect#clicked (fun _ ->
-    match !interp_no with None -> () | Some _ -> return ()));
-  ignore (dialog#interpChoiceCancelButton#connect#clicked return);
+  connect_button dialog#interpChoiceOkButton (fun _ ->
+    match !interp_no with None -> () | Some _ -> return ());
+  connect_button dialog#interpChoiceCancelButton fail;
   ignore (dialog#interpChoiceTreeView#connect#row_activated (fun path _ ->
     interp_no := Some (model#get_interp_no path);
     return ()));
@@ -228,8 +230,8 @@ let ask_confirmation ~(gui:#gui) ?(title = "") ?(msg = "") () =
     GMain.Main.quit ()
   in
   ignore (dialog#confirmationDialog#event#connect#delete (fun _ -> true));
-  ignore (dialog#confirmationDialogOkButton#connect#clicked (return true));
-  ignore (dialog#confirmationDialogCancelButton#connect#clicked (return false));
+  connect_button dialog#confirmationDialogOkButton (return true);
+  connect_button dialog#confirmationDialogCancelButton (return false);
   dialog#confirmationDialog#show ();
   GtkThread.main ();
   (match !result with None -> assert false | Some r -> r)
@@ -252,15 +254,15 @@ let ask_text ~(gui:#gui) ?(title = "") ?(msg = "") ?(multiline = false) () =
     in
     let view = GText.view ~wrap_mode:`CHAR ~packing:win#add () in
     view#misc#grab_focus ();
-    ignore (dialog#emptyDialogOkButton#connect#clicked (fun _ ->
-      return (Some (view#buffer#get_text ()))))
+    connect_button dialog#emptyDialogOkButton (fun _ ->
+      return (Some (view#buffer#get_text ())))
   end else begin (* monoline input required: use a TextEntry widget *)
     let entry = GEdit.entry ~packing:dialog#emptyDialogVBox#add () in
     entry#misc#grab_focus ();
-    ignore (dialog#emptyDialogOkButton#connect#clicked (fun _ ->
-      return (Some entry#text)))
+    connect_button dialog#emptyDialogOkButton (fun _ ->
+      return (Some entry#text))
   end;
-  ignore (dialog#emptyDialogCancelButton#connect#clicked (fun _ ->return None));
+  connect_button dialog#emptyDialogCancelButton (fun _ ->return None);
   dialog#emptyDialog#show ();
   GtkThread.main ();
   (match !result with None -> raise Cancel | Some r -> r)
index fa12ab42eb0b5ddee2f985dcdeb63275326e6a20..92606176cfc5c61fa9068b2b3aa790a05b1d989c 100644 (file)
@@ -35,6 +35,8 @@ val toggle_win:
 
 val add_key_binding: Gdk.keysym -> (unit -> 'a) -> GBin.event_box -> unit
 
+val connect_button: GButton.button -> (unit -> unit) -> unit
+
   (** single string column list *)
 class stringListModel:
   GTree.view ->
@@ -58,12 +60,10 @@ class type gui =
 
   (** {3 Dialogs} *)
 
-exception Cancel  (* raised when no answer is given by the user *)
-
-  (** @raise Cancel *)
+  (** @raise MatitaTypes.Cancel *)
 val interactive_user_uri_choice: gui:#gui -> MatitaTypes.choose_uris_callback
 
-  (** @raise Cancel *)
+  (** @raise MatitaTypes.Cancel *)
 val interactive_interp_choice: gui:#gui -> MatitaTypes.choose_interp_callback
 
   (** @return true if user hit "ok" button, false if user hit "cancel" button *)
index 9226ea7b680e78c05eacb771fa179b038a34f52e..0d46bfcfaf621f44fde9f30e9c0650d906f672f3 100644 (file)
@@ -58,11 +58,12 @@ class gui file =
   let script = new scriptWin ~file () in
   let keyBindingBoxes = (* event boxes which should receive global key events *)
     [ toolbar#toolBarEventBox; proof#proofWinEventBox; main#mainWinEventBox;
-      check#checkWinEventBox; script#scriptWinEventBox ]
+      check#checkWinEventBox; script#scriptWinEventBox; main#consoleEventBox ]
   in
   let console =
-    MatitaConsole.console ~evbox:main#consoleEventBox ~phrase_sep:";;"
-      ~packing:main#scrolledConsole#add ()
+    MatitaConsole.console ~evbox:main#consoleEventBox
+      ~phrase_sep:BuildTimeConf.phrase_sep
+      ~packing:main#scrolledConsole#add ~paned:main#mainVPanes ()
   in
   let script_buf = script#scriptTextView#buffer in
   object (self)
@@ -80,11 +81,6 @@ class gui file =
       List.iter (fun w -> w#check_widgets ())
         (let c w = (w :> <check_widgets: unit -> unit>) in
          [ c about; c fileSel; c main; c proof; c toolbar; c check; c script ]);
-        (* show/hide commands *)
-      toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
-      toggle_visibility proof#proofWin main#showProofMenuItem;
-      toggle_visibility check#checkWin main#showCheckMenuItem;
-      toggle_visibility script#scriptWin main#showScriptMenuItem;
         (* "global" key bindings *)
       List.iter (fun (key, callback) -> self#addKeyBinding key callback)
         [ GdkKeysyms._F3,
@@ -93,13 +89,14 @@ class gui file =
             toggle_win ~check:main#showCheckMenuItem check#checkWin;
           GdkKeysyms._F5,
             toggle_win ~check:main#showScriptMenuItem script#scriptWin;
+          GdkKeysyms._x, (fun () -> console#show ());
         ];
         (* about win *)
       ignore (about#aboutWin#event#connect#delete (fun _ -> true));
       ignore (main#aboutMenuItem#connect#activate (fun _ ->
         about#aboutWin#show ()));
-      ignore (about#aboutDismissButton#connect#clicked (fun _ ->
-        about#aboutWin#misc#hide ()));
+      connect_button about#aboutDismissButton (fun _ ->
+        about#aboutWin#misc#hide ());
       about#aboutLabel#set_label (Pcre.replace ~pat:"@VERSION@"
         ~templ:BuildTimeConf.version about#aboutLabel#label);
         (* file selection win *)
@@ -119,14 +116,23 @@ class gui file =
         | `DELETE_EVENT -> return None));
         (* script *)
         (* menus *)
+      toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
+      toggle_visibility proof#proofWin main#showProofMenuItem;
+      toggle_visibility check#checkWin main#showCheckMenuItem;
+      toggle_visibility script#scriptWin main#showScriptMenuItem;
       List.iter (fun w -> w#misc#set_sensitive false)
         [ main#saveMenuItem; main#saveAsMenuItem ];
       main#helpMenu#set_right_justified true;
+      ignore (main#showConsoleMenuItem#connect#activate console#show);
+        (* main *)
+      connect_button main#hideConsoleButton console#hide;
+(*
         (* console *)
       console#echo_message (sprintf "\tMatita version %s\n"
         BuildTimeConf.version);
       console#echo_prompt ();
-      console#misc#grab_focus ()
+      console#misc#grab_focus ();
+*)
 
     method about = about
     method check = check
@@ -184,11 +190,10 @@ class gui file =
         GMain.Main.quit ()
       in
       ignore (dialog#textDialog#event#connect#delete (fun _ -> true));
-      ignore (dialog#textDialogCancelButton#connect#clicked (fun _ ->
-        return None));
-      ignore (dialog#textDialogOkButton#connect#clicked (fun _ ->
+      connect_button dialog#textDialogCancelButton (fun _ -> return None);
+      connect_button dialog#textDialogOkButton (fun _ ->
         let text = dialog#textDialogTextView#buffer#get_text () in
-        return (Some text)));
+        return (Some text));
       dialog#textDialog#show ();
       GtkThread.main ();
       !text
index d3dc10a1dc873b6f9d82070e3564b164321d0dc6..dfb93cd1880248fd8df732a2a395edc950b8055e 100644 (file)
@@ -37,7 +37,7 @@ class gui :
   object
 
     method setQuitCallback    : (unit -> unit) -> unit
-    method setPhraseCallback  : (string -> unit) -> unit
+    method setPhraseCallback  : (string -> bool) -> unit
 
       (** {2 Access to lower-level GTK widgets} *)
 
index 35ec6119d2bf4d781fcf0c7c6e386da915e5dd6a..3a4295f4ac99f94f8d75eca3ff94953f22d8b4ba 100644 (file)
@@ -113,18 +113,12 @@ class virtual interpreterState =
     method virtual evalTactical:
       (CicAst.term, string) TacticAst.tactical -> state_tag
 
-(*
-    method undo ?(steps = 1) () =
-      for i = 1 to steps do
-        match List.hd !history with
-        | `Qed 
-        FINQUI
-*)
-
     method evalPhrase s =
       debug_print (sprintf "evaluating '%s'" s);
       self#evalTactical (self#parsePhrase s)
 
+    method evalAst ast = self#evalTactical ast
+
     method endOffset =
       match !loc with
       | Some (start_pos, end_pos) -> end_pos.Lexing.pos_cnum
@@ -330,6 +324,18 @@ class interpreter
     new commandState ~disambiguator ~proof_handler ~console ()
   in
   let proofState = new proofState ~disambiguator ~proof_handler ~console () in
+  let wrap_exn transparent f =
+    try
+      f ();
+      true
+    with exn ->
+      if transparent then
+        raise exn
+      else
+        console#echo_error (sprintf "Uncaught exception: %s"
+          (Printexc.to_string exn));
+      false
+  in
   object (self)
     val mutable state = commandState
 
@@ -343,14 +349,10 @@ class interpreter
       | None -> ()
 
     method evalPhrase ?(transparent = false) s =
-      try
-        self#updateState (state#evalPhrase s)
-      with exn ->
-        if transparent then
-          raise exn
-        else
-          console#echo_error (sprintf "Uncaught exception: %s"
-            (Printexc.to_string exn))
+      wrap_exn transparent (fun () -> self#updateState (state#evalPhrase s))
+
+    method evalAst ?(transparent = false) s =
+      wrap_exn transparent (fun () -> self#updateState (state#evalAst s))
 
   end
 
index b83c9b37fa9abe3c21fc28bdae1b266581e021b7..cdbc51e41f98488bb1c20a4081be158ec3d3e782 100644 (file)
@@ -44,6 +44,25 @@ let list_map_fail f =
  in
   aux
 
+let choose_selection mmlwidget (element : Gdome.element option) =
+  let rec aux element =
+    if element#hasAttributeNS
+       ~namespaceURI:Misc.helmns
+       ~localName:(Gdome.domString "xref")
+    then
+      mmlwidget#set_selection (Some element)
+    else
+      try
+        match element#get_parentNode with
+        | None -> assert false
+        | Some p -> aux (new Gdome.element_of_node p)
+      with GdomeInit.DOMCastException _ ->
+        debug_print "trying to select above the document root"
+  in
+  match element with
+  | Some x -> aux x
+  | None   -> mmlwidget#set_selection None
+
 class proof_viewer obj =
  object(self)
 
@@ -59,11 +78,7 @@ class proof_viewer obj =
           prerr_endline (gdome_elt#get_nodeName#to_string);
           ignore (self#action_toggle gdome_elt)
       | None -> ()));
-      (* bugfix: until mapping gtkmathview doesn't draw anything *)
-    ignore (self#misc#connect#after#map (fun _ ->
-      match current_mathml with
-      | None -> ()
-      | Some mathml -> self#load_root ~root:mathml#get_documentElement))
+    ignore (self#connect#selection_changed (choose_selection self))
 
   method load_proof ((uri_opt, _, _, _) as proof, (goal_opt: int option)) =
     let (annobj, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
@@ -93,6 +108,9 @@ class sequent_viewer obj =
 
   inherit GMathViewAux.multi_selection_math_view obj
 
+  initializer
+    ignore (self#connect#selection_changed (choose_selection self))
+
   val mutable current_infos = None
 
   method get_selected_terms =
@@ -187,7 +205,7 @@ class sequents_viewer ~(notebook:GPack.notebook)
       let win metano =
         let w =
           GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
-            ~show:true ()
+            ~shadow_type:`IN ~show:true ()
         in
         let reparent () =
           match sequent_viewer#misc#parent with
@@ -206,7 +224,7 @@ class sequents_viewer ~(notebook:GPack.notebook)
           notebook#append_page ~tab_label:(tab_label metano) (win metano))
         metasenv;
       switch_page_callback <-
-        Some (notebook#connect#after#switch_page ~callback:(fun page ->
+        Some (notebook#connect#switch_page ~callback:(fun page ->
           let goal =
             try
               List.assoc page page2goal
@@ -253,11 +271,7 @@ let proof_viewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
 let proof_viewer_instance =
   let instance = lazy (
     let gui = MatitaGui.instance () in
-    let frame =
-      GBin.frame ~packing:(gui#proof#scrolledProof#add_with_viewport)
-        ~show:true ()
-    in
-    proof_viewer ~show:true ~packing:(frame#add) ()
+    proof_viewer ~show:true ~packing:gui#proof#scrolledProof#add ()
   ) in
   fun () -> Lazy.force instance
 
index f332fcbd1e684bce9dbbcca5d3d546bfdc033dbb..83bdeb36f6ea3fcd55f6e7effc7635d00fad9ee2 100644 (file)
@@ -23,6 +23,8 @@
  * http://helm.cs.unibo.it/
  *)
 
+open Printf
+
 let is_dir fname = (Unix.stat fname).Unix.st_kind = Unix.S_DIR
 let is_regular fname = (Unix.stat fname).Unix.st_kind = Unix.S_REG
 
@@ -37,3 +39,9 @@ let input_file fname =
 let is_proof_script fname = true  (** TODO Zack *)
 let is_proof_object fname = true  (** TODO Zack *)
 
+let append_phrase_sep s =
+  if not (Pcre.pmatch ~pat:(sprintf "%s$" BuildTimeConf.phrase_sep) s) then
+    s ^ BuildTimeConf.phrase_sep
+  else
+    s
+
index ae1fc382b5de8a84747f209866ae0e9979fca5bb..f8e8ee40c0c98d533fb996c83f366d8c9c5fe622 100644 (file)
@@ -34,3 +34,7 @@ val is_proof_script: string -> bool
   (** @return true if file is a (binary) proof object *)
 val is_proof_object: string -> bool
 
+  (** given a phrase, if it doesn't end with BuildTimeConf.phrase_sep, append
+  * it *)
+val append_phrase_sep: string -> string
+
index 20ffd350dfd3d1965c8b62e524797d7065367308..9ae5cc7a98f568c978129682e1380a25e8b8b992 100644 (file)
@@ -36,6 +36,7 @@ let debug_print s =
 exception No_proof  (** no current proof is available *)
 
 exception Cancel
+exception Unbound_identifier of string
 
 (*
 let untitled_con_uri = UriManager.uri_of_string "cic:/untitled.con"
@@ -132,20 +133,17 @@ class type interpreter =
       * @param transparent per default the interpreter catch all exceptions ans
       * prints them in the console. When transparent is set to true exceptions
       * are flow through. Defaults to false
+      * @return success value of the interpretation
       *)
-    method evalPhrase: ?transparent:bool -> string -> unit
+    method evalPhrase: ?transparent:bool -> string -> bool
+
+    method evalAst: ?transparent:bool -> DisambiguateTypes.tactical -> bool
 
       (** offset from the starting of the last string parser by evalPhrase where
       * parsing stop.
       * @raise Failure when no offset has been recorded *)
     method endOffset: int
 
-(*
-      (** undo last steps phrases.
-      * @param steps number of phrases to undo; defaults to 1 *)
-    method undo: ?steps:int -> unit -> unit
-*)
-
   end
 
 (** {2 MathML widgets} *)