]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/matitaMathView.ml
cicNotation* ==> notation*
[helm.git] / matita / matita / matitaMathView.ml
index 770d2a83a5a1118ae4cbd5150ee243af738c7eb8..8a7b8fdcba47988dfbc090223a83422d965bce3f 100644 (file)
@@ -89,6 +89,7 @@ let closed_goal_mathml = lazy "chiuso per side effect..."
 
 (* ids_to_terms should not be passed here, is just for debugging *)
 let find_root_id annobj id ids_to_father_ids ids_to_terms ids_to_inner_types =
+  assert false (* MATITA 1.0
   let find_parent id ids =
     let rec aux id =
 (*       (prerr_endline (sprintf "id %s = %s" id
@@ -128,6 +129,7 @@ let find_root_id annobj id ids_to_father_ids ids_to_terms ids_to_inner_types =
       return_father id (mk_ids (ty::inner_types))
   | Cic.AInductiveDefinition _ ->
       assert false  (* TODO *)
+      *)
 
   (** @return string content of a dom node having a single text child node, e.g.
    * <m:mi xlink:href="...">bool</m:mi> *)
@@ -183,7 +185,9 @@ object (self)
 
   method has_selection = (assert false : bool)
   method strings_of_selection = (assert false : (paste_kind * string) list)
-  method update_font_size = (assert false : unit)
+  method update_font_size =
+   self#misc#modify_font_by_name
+     (sprintf "%s %d" BuildTimeConf.script_font !current_font_size)
   method set_href_callback = (function _ -> () : (string -> unit) option -> unit)
   method private set_cic_info = (function _ -> () : (Cic.conjecture option * (Cic.id, Cic.term) Hashtbl.t *
          (Cic.id, Cic.hypothesis) Hashtbl.t *
@@ -200,6 +204,12 @@ object (self)
    self#misc#modify_font_by_name
      (sprintf "%s %d" BuildTimeConf.script_font font_size)
 
+  initializer
+    self#set_font_size !current_font_size;
+    self#source_buffer#set_language (Some MatitaGtkMisc.matita_lang);
+    self#source_buffer#set_highlight_syntax true;
+    self#set_editable false
+
 (* MATITA1.0
   inherit GMathViewAux.multi_selection_math_view obj
 
@@ -605,27 +615,6 @@ object (self)
 
   val mutable current_mathml = None
 
-  method load_sequent metasenv metano =
-    let sequent = CicUtil.lookup_meta metano metasenv in
-    let (txt, unsh_sequent,
-      (_, (ids_to_terms, ids_to_father_ids, ids_to_hypotheses,_ )))
-    =
-      ApplyTransformation.txt_of_cic_sequent_all
-       ~map_unicode_to_tex:false 80 (*MATITA 1.0??*) metasenv sequent
-    in
-    self#set_cic_info
-      (Some (Some unsh_sequent,
-        ids_to_terms, ids_to_hypotheses, ids_to_father_ids,
-        Hashtbl.create 1, None));
-   (*MATITA 1.0
-    if BuildTimeConf.debug then begin
-      let name =
-       "/tmp/sequent_viewer_" ^ string_of_int (Unix.getuid ()) ^ ".xml" in
-      HLog.debug ("load_sequent: dumping MathML to ./" ^ name);
-      ignore (domImpl#saveDocumentToFile ~name ~doc:txt ())
-    end; *)
-    self#load_root ~root:txt
-
   method nload_sequent:
    'status. #NCicCoercion.status as 'status -> NCic.metasenv ->
      NCic.substitution -> int -> unit
@@ -643,32 +632,6 @@ object (self)
     end;*)
     self#load_root ~root:txt
 
-  method load_object obj =
-    let use_diff = false in (* ZACK TODO use XmlDiff when re-rendering? *)
-    let (txt,
-      (annobj, (ids_to_terms, ids_to_father_ids, _, ids_to_hypotheses, _, ids_to_inner_types)))
-    =
-      ApplyTransformation.txt_of_cic_object_all ~map_unicode_to_tex:false
-       80 [] obj
-    in
-    self#set_cic_info
-      (Some (None, ids_to_terms, ids_to_hypotheses, ids_to_father_ids, ids_to_inner_types, Some annobj));
-    (match current_mathml with
-    | Some current_mathml when use_diff ->
-assert false (*MATITA1.0
-        self#freeze;
-        XmlDiff.update_dom ~from:current_mathml mathml;
-        self#thaw*)
-    |  _ ->
-        (* MATITA1.0 if BuildTimeConf.debug then begin
-          let name =
-           "/tmp/cic_browser_" ^ string_of_int (Unix.getuid ()) ^ ".xml" in
-          HLog.debug ("cic_browser: dumping MathML to ./" ^ name);
-          ignore (domImpl#saveDocumentToFile ~name ~doc:mathml ())
-        end;*)
-        self#load_root ~root:txt;
-        current_mathml <- Some txt);
-
   method load_nobject :
    'status. #NCicCoercion.status as 'status -> NCic.obj -> unit
    = fun status obj ->
@@ -760,86 +723,6 @@ class sequentsViewer ~(notebook:GPack.notebook) ~(cicMathView:cicMathView) () =
       _metasenv <- `Old []; 
       self#script#setGoal None
 
-    method load_sequents : 'status. #NCicCoercion.status as 'status -> 'a
-     = fun status { proof= (_,metasenv,_subst,_,_, _) as proof; stack = stack } 
-     ->
-      _metasenv <- `Old metasenv;
-      pages <- 0;
-      let win goal_switch =
-        let w =
-          GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`ALWAYS
-            ~shadow_type:`IN ~show:true ()
-        in
-        let reparent () =
-          scrolledWin <- Some w;
-          match cicMathView#misc#parent with
-          | None -> w#add cicMathView#coerce
-          | Some parent ->
-             let parent =
-              match cicMathView#misc#parent with
-                 None -> assert false
-               | Some p -> GContainer.cast_container p
-             in
-              parent#remove cicMathView#coerce;
-              w#add cicMathView#coerce
-        in
-        goal2win <- (goal_switch, reparent) :: goal2win;
-        w#coerce
-      in
-      assert (
-        let stack_goals = Stack.open_goals stack in
-        let proof_goals = ProofEngineTypes.goals_of_proof proof in
-        if
-          HExtlib.list_uniq (List.sort Pervasives.compare stack_goals)
-          <> List.sort Pervasives.compare proof_goals
-        then begin
-          prerr_endline ("STACK GOALS = " ^ String.concat " " (List.map string_of_int stack_goals));
-          prerr_endline ("PROOF GOALS = " ^ String.concat " " (List.map string_of_int proof_goals));
-          false
-        end
-        else true
-      );
-      let render_switch =
-        function Stack.Open i ->`Meta i | Stack.Closed i ->`Closed (`Meta i)
-      in
-      let page = ref 0 in
-      let added_goals = ref [] in
-        (* goals can be duplicated on the tack due to focus, but we should avoid
-         * multiple labels in the user interface *)
-      let add_tab markup goal_switch =
-        let goal = Stack.goal_of_switch goal_switch in
-        if not (List.mem goal !added_goals) then begin
-          ignore(notebook#append_page 
-            ~tab_label:(tab_label markup) (win goal_switch));
-          page2goal <- (!page, goal_switch) :: page2goal;
-          goal2page <- (goal_switch, !page) :: goal2page;
-          incr page;
-          pages <- pages + 1;
-          added_goals := goal :: !added_goals
-        end
-      in
-      let add_switch _ _ (_, sw) = add_tab (render_switch sw) sw in
-      Stack.iter  (** populate notebook with tabs *)
-        ~env:(fun depth tag (pos, sw) ->
-          let markup =
-            match depth, pos with
-            | 0, 0 -> `Current (render_switch sw)
-            | 0, _ -> `Shift (pos, `Current (render_switch sw))
-            | 1, pos when Stack.head_tag stack = `BranchTag ->
-                `Shift (pos, render_switch sw)
-            | _ -> render_switch sw
-          in
-          add_tab markup sw)
-        ~cont:add_switch ~todo:add_switch
-        stack;
-      switch_page_callback <-
-        Some (notebook#connect#switch_page ~callback:(fun page ->
-          let goal_switch =
-            try List.assoc page page2goal with Not_found -> assert false
-          in
-          self#script#setGoal (Some (goal_of_switch goal_switch));
-          self#render_page status ~page ~goal_switch))
-
     method nload_sequents : 'status. #NTacStatus.tac_status as 'status -> unit
     = fun status ->
      let _,_,metasenv,subst,_ = status#obj in
@@ -927,7 +810,7 @@ class sequentsViewer ~(notebook:GPack.notebook) ~(cicMathView:cicMathView) () =
       (match goal_switch with
       | Stack.Open goal ->
          (match _metasenv with
-             `Old menv -> cicMathView#load_sequent menv goal
+             `Old menv -> assert false (* MATITA 1.0 *)
            | `New (menv,subst) ->
                cicMathView#nload_sequent status menv subst goal)
       | Stack.Closed goal ->
@@ -1001,8 +884,7 @@ let blank_uri = BuildTimeConf.blank_uri
 let current_proof_uri = BuildTimeConf.current_proof_uri
 
 type term_source =
-  [ `Ast of CicNotationPt.term
-  | `Cic of Cic.term * Cic.metasenv
+  [ `Ast of NotationPt.term
   | `NCic of NCic.term * NCic.context * NCic.metasenv * NCic.substitution
   | `String of string
   ]
@@ -1096,12 +978,6 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
       let status = (MatitaScript.current ())#grafite_status in
       NCicCoercion.generate_dot_file status fmt;
       Pp.trailer fmt;
-      Pp.header 
-        ~name:"OLDCoercions"
-        ~node_attrs:["fontsize", "9"; "width", ".4"; "height", ".4"]
-        ~edge_attrs:["fontsize", "10"] fmt;
-      CoercGraph.generate_dot_file fmt;
-      Pp.trailer fmt;
       Pp.raw "@." fmt;
       close_out oc;
       if tred then
@@ -1115,9 +991,6 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
   object (self)
     inherit scriptAccessor
     
-    (* Whelp bar queries *)
-
-    val mutable gviz_graph = MetadataDeps.DepGraph.dummy
     val mutable gviz_uri = UriManager.uri_of_string "cic:/dummy.con";
 
     val dep_contextual_menu = GMenu.menu ()
@@ -1178,27 +1051,6 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
         | Some uri -> self#load (`Univs uri)
         | None -> ());
 
-      (* fill dep graph contextual menu *)
-      let go_menu_item =
-        GMenu.image_menu_item ~label:"Browse it"
-          ~packing:dep_contextual_menu#append () in
-      let expand_menu_item =
-        GMenu.image_menu_item ~label:"Expand"
-          ~packing:dep_contextual_menu#append () in
-      let collapse_menu_item =
-        GMenu.image_menu_item ~label:"Collapse"
-          ~packing:dep_contextual_menu#append () in
-      dep_contextual_menu#append (go_menu_item :> GMenu.menu_item);
-      dep_contextual_menu#append (expand_menu_item :> GMenu.menu_item);
-      dep_contextual_menu#append (collapse_menu_item :> GMenu.menu_item);
-      connect_menu_item go_menu_item (fun () -> self#load (`Uri gviz_uri));
-      connect_menu_item expand_menu_item (fun () ->
-        MetadataDeps.DepGraph.expand gviz_uri gviz_graph;
-        self#redraw_gviz ~center_on:gviz_uri ());
-      connect_menu_item collapse_menu_item (fun () ->
-        MetadataDeps.DepGraph.collapse gviz_uri gviz_graph;
-        self#redraw_gviz ~center_on:gviz_uri ());
-
       self#_load (`About `Blank);
       toplevel#show ()
 
@@ -1287,14 +1139,13 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
           | `About `TeX -> self#tex ()
           | `About `Grammar -> self#grammar () 
           | `Check term -> self#_loadCheck term
-          | `Cic (term, metasenv) -> self#_loadTermCic term metasenv
           | `NCic (term, ctx, metasenv, subst) -> 
                self#_loadTermNCic term metasenv subst ctx
           | `Dir dir -> self#_loadDir dir
           | `HBugs `Tutors -> self#_loadHBugsTutors
-          | `Uri uri -> self#_loadUriManagerUri uri
+          | `Uri uri -> assert false (* MATITA 1.0 *)
           | `NRef nref -> self#_loadNReference nref
-          | `Univs uri -> self#_loadUnivs uri);
+          | `Univs uri -> assert false (* MATITA 1.0 *));
           self#setEntry entry
         end)
 
@@ -1314,7 +1165,7 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
       if Sys.command "which dot" = 0 then
        let tmpfile, oc = Filename.open_temp_file "matita" ".dot" in
        let fmt = Format.formatter_of_out_channel oc in
-       MetadataDeps.DepGraph.render fmt gviz_graph;
+       (* MATITA 1.0 MetadataDeps.DepGraph.render fmt gviz_graph;*)
        close_out oc;
        gviz#load_graph_from_file ~gviz_cmd:"tred | dot" tmpfile;
        (match center_on with
@@ -1328,6 +1179,7 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
         ~parent:win#toplevel ()
 
     method private dependencies direction uri () =
+      assert false (* MATITA 1.0
       let dbd = LibraryDb.instance () in
       let graph =
         match direction with
@@ -1335,7 +1187,7 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
         | `Back -> MetadataDeps.DepGraph.inverse_deps ~dbd uri in
       gviz_graph <- graph;  (** XXX check this for memory consuption *)
       self#redraw_gviz ~center_on:uri ();
-      self#_showGviz
+      self#_showGviz *)
 
     method private coerchgraph tred () =
       load_coerchgraph tred ();
@@ -1386,49 +1238,16 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
 
     method private home () =
       self#_showMath;
-      match self#script#grafite_status#proof_status with
-      | Proof  (uri, metasenv, _subst, bo, ty, attrs) ->
-         let name = UriManager.name_of_uri (HExtlib.unopt uri) in
-         let obj =
-          Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs)
-         in
-          self#_loadObj obj
-      | Incomplete_proof { proof = (uri, metasenv, _subst, bo, ty, attrs) } ->
-         let name = UriManager.name_of_uri (HExtlib.unopt uri) in
-         let obj =
-          Cic.CurrentProof (name, metasenv, Lazy.force bo, ty, [], attrs)
-         in
-          self#_loadObj obj
-      | _ ->
-        match self#script#grafite_status#ng_mode with
-           `ProofMode ->
-             self#_loadNObj self#script#grafite_status
-             self#script#grafite_status#obj
-         | _ -> self#blank ()
-
-      (** loads a cic uri from the environment
-      * @param uri UriManager.uri *)
-    method private _loadUriManagerUri uri =
-      let uri = UriManager.strip_xpointer uri in
-      let (obj, _) = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
-      self#_loadObj obj
+      match self#script#grafite_status#ng_mode with
+         `ProofMode ->
+           self#_loadNObj self#script#grafite_status
+           self#script#grafite_status#obj
+       | _ -> self#blank ()
 
     method private _loadNReference (NReference.Ref (uri,_)) =
       let obj = NCicEnvironment.get_checked_obj uri in
       self#_loadNObj self#script#grafite_status obj
 
-    method private _loadUnivs uri =
-      let uri = UriManager.strip_xpointer uri in
-      let (_, u) = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
-      let _,us = CicUniv.do_rank u in
-      let l = 
-        List.map 
-          (fun u -> 
-           [ CicUniv.string_of_universe u ; string_of_int (CicUniv.get_rank u)])
-          us 
-      in
-      self#_loadList2 l
-      
     method private _loadDir dir = 
       let content = Http_getter.ls ~local:false dir in
       let l =
@@ -1450,13 +1269,6 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
       win#browserUri#set_text (MatitaTypes.string_of_entry entry);
       current_entry <- entry
 
-    method private _loadObj obj =
-      (* showMath must be done _before_ loading the document, since if the
-       * widget is not mapped (hidden by the notebook) the document is not
-       * rendered *)
-      self#_showMath;
-      mathView#load_object obj
-
     method private _loadNObj status obj =
       (* showMath must be done _before_ loading the document, since if the
        * widget is not mapped (hidden by the notebook) the document is not
@@ -1464,13 +1276,6 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
       self#_showMath;
       mathView#load_nobject status obj
 
-    method private _loadTermCic term metasenv =
-      let context = self#script#proofContext in
-      let dummyno = CicMkImplicit.new_meta metasenv [] in
-      let sequent = (dummyno, context, term) in
-      mathView#load_sequent (sequent :: metasenv) dummyno;
-      self#_showMath
-
     method private _loadTermNCic term m s c =
       let d = 0 in
       let m = (0,([],c,term))::m in