]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaMathView.ml
Debugging code commented out.
[helm.git] / helm / matita / matitaMathView.ml
1 (* Copyright (C) 2004-2005, 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://cs.unibo.it/helm/.
24  *)
25
26 open Printf
27
28 open MatitaTypes
29
30 let list_map_fail f =
31   let rec aux = function
32     | [] -> []
33     | he::tl ->
34         try
35           let he' = f he in
36           he'::(aux tl)
37         with Exit ->
38           (aux tl)
39   in
40   aux
41
42 let add_trailing_slash =
43   let rex = Pcre.regexp "/$" in
44   fun s ->
45     if Pcre.pmatch ~rex s then s
46     else s ^ "/"
47
48 let strip_blanks =
49   let rex = Pcre.regexp "^\\s*([^\\s]*)\\s*$" in
50   fun s ->
51     (Pcre.extract ~rex s).(1)
52
53 (** inherit from this class if you want to access current script *)
54 class scriptAccessor =
55 object (self)
56   method private script = MatitaScript.instance ()
57 end
58
59 let cicBrowsers = ref []
60
61 let default_font_size () =
62   Helm_registry.get_opt_default Helm_registry.int
63     ~default:BuildTimeConf.default_font_size "matita.font_size"
64 let current_font_size = ref ~-1
65 let increase_font_size () = incr current_font_size
66 let decrease_font_size () = decr current_font_size
67 let reset_font_size () = current_font_size := default_font_size ()
68
69 class clickableMathView obj =
70   let href = Gdome.domString "href" in
71   let xref = Gdome.domString "xref" in
72   object (self)
73     inherit GMathViewAux.multi_selection_math_view obj
74
75     val mutable href_callback: (string -> unit) option = None
76     method set_href_callback f = href_callback <- f
77
78     initializer
79       self#set_font_size !current_font_size;
80       ignore (self#connect#selection_changed self#choose_selection);
81       ignore (self#connect#click (fun (gdome_elt, _, _, _) ->
82         match gdome_elt with
83         | Some elt  (* element is an hyperlink, use href_callback on it *)
84           when elt#hasAttributeNS ~namespaceURI:DomMisc.xlink_ns ~localName:href ->
85             (match href_callback with
86             | None -> ()
87             | Some f ->
88                 let uri =
89                   elt#getAttributeNS ~namespaceURI:DomMisc.xlink_ns ~localName:href
90                 in
91                 f (uri#to_string))
92         | Some elt -> ignore (self#action_toggle elt)
93         | None -> ()))
94     method private choose_selection gdome_elt =
95       let rec aux elt =
96         if elt#hasAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref then
97           self#set_selection (Some elt)
98         else
99           try
100             (match elt#get_parentNode with
101             | None -> assert false
102             | Some p -> aux (new Gdome.element_of_node p))
103           with GdomeInit.DOMCastException _ -> ()
104 (*             debug_print "trying to select above the document root" *)
105       in
106       match gdome_elt with
107       | Some elt -> aux elt
108       | None   -> self#set_selection None
109
110     method update_font_size = 
111       self#set_font_size !current_font_size
112       
113   end
114
115 let clickableMathView ?hadjustment ?vadjustment ?font_size ?log_verbosity =
116   GtkBase.Widget.size_params
117     ~cont:(OgtkMathViewProps.pack_return (fun p ->
118       OgtkMathViewProps.set_params
119         (new clickableMathView (GtkMathViewProps.MathView_GMetaDOM.create p))
120         ~font_size:None ~log_verbosity:None))
121     []
122
123 class sequentViewer obj =
124   object(self)
125
126     inherit clickableMathView obj
127
128     val mutable current_infos = None
129     
130     method get_selected_terms =
131       let selections = self#get_selections in
132       list_map_fail
133         (fun node ->
134           let xpath =
135             ((node : Gdome.element)#getAttributeNS
136               ~namespaceURI:DomMisc.helm_ns
137               ~localName:(Gdome.domString "xref"))#to_string
138           in
139           if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
140           else
141             match current_infos with
142             | Some (ids_to_terms,_,_) ->
143                 (try Hashtbl.find ids_to_terms xpath with _ -> raise Exit)
144             | None -> assert false) (* "ERROR: No current term!!!" *)
145         selections
146
147     method get_selected_hypotheses =
148       let selections = self#get_selections in
149       list_map_fail
150         (fun node ->
151           let xpath =
152             ((node : Gdome.element)#getAttributeNS
153               ~namespaceURI:DomMisc.helm_ns
154               ~localName:(Gdome.domString "xref"))#to_string
155           in
156           if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
157           else
158             match current_infos with
159             | Some (_,_,ids_to_hypotheses) ->
160                 (try Hashtbl.find ids_to_hypotheses xpath with _ -> raise Exit)
161             | None -> assert false) (* "ERROR: No current term!!!" *)
162         selections
163   
164   method load_sequent metasenv metano =
165     let sequent = CicUtil.lookup_meta metano metasenv in
166     let (mathml,(_,(ids_to_terms, ids_to_father_ids, ids_to_hypotheses,_))) =
167       ApplyTransformation.mml_of_cic_sequent metasenv sequent
168     in
169     current_infos <- Some (ids_to_terms, ids_to_father_ids, ids_to_hypotheses);
170 (*
171     let name = "sequent_viewer.xml" in
172     prerr_endline ("load_sequent: dumping MathML to ./" ^ name);
173     ignore (DomMisc.domImpl#saveDocumentToFile ~name ~doc:mathml ());
174 *)
175     self#load_root ~root:mathml#get_documentElement
176  end
177
178 class sequentsViewer ~(notebook:GPack.notebook)
179   ~(sequentViewer:sequentViewer) ()
180 =
181   object (self)
182     inherit scriptAccessor
183
184     val mutable pages = 0
185     val mutable switch_page_callback = None
186     val mutable page2goal = []  (* associative list: page no -> goal no *)
187     val mutable goal2page = []  (* the other way round *)
188     val mutable goal2win = []   (* associative list: goal no -> scrolled win *)
189     val mutable _metasenv = []
190     val mutable scrolledWin: GBin.scrolled_window option = None
191       (* scrolled window to which the sequentViewer is currently attached *)
192
193     method private tab_label metano =
194       (GMisc.label ~text:(sprintf "?%d" metano) ~show:true ())#coerce
195
196     method reset =
197       (match scrolledWin with
198       | Some w ->
199           (* removing page from the notebook will destroy all contained widget,
200           * we do not want the sequentViewer to be destroyed as well *)
201           w#remove sequentViewer#coerce;
202           scrolledWin <- None
203       | None -> ());
204       for i = 1 to pages do notebook#remove_page 0 done;
205       pages <- 0;
206       page2goal <- [];
207       goal2page <- [];
208       goal2win <- [];
209       _metasenv <- [];
210       self#script#setGoal ~-1;
211       (match switch_page_callback with
212       | Some id ->
213           GtkSignal.disconnect notebook#as_widget id;
214           switch_page_callback <- None
215       | None -> ())
216
217     method load_sequents (status: ProofEngineTypes.status) =
218       let ((_, metasenv, _, _), goal) = status in
219       let sequents_no = List.length metasenv in
220       _metasenv <- metasenv;
221       pages <- sequents_no;
222       self#script#setGoal goal;
223       let win metano =
224         let w =
225           GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
226             ~shadow_type:`IN ~show:true ()
227         in
228         let reparent () =
229           scrolledWin <- Some w;
230           match sequentViewer#misc#parent with
231           | None -> w#add sequentViewer#coerce
232           | Some _ -> sequentViewer#misc#reparent w#coerce
233         in
234         goal2win <- (metano, reparent) :: goal2win;
235         w#coerce
236       in
237       let page = ref 0 in
238       List.iter
239         (fun (metano, _, _) ->
240           page2goal <- (!page, metano) :: page2goal;
241           goal2page <- (metano, !page) :: goal2page;
242           incr page;
243           notebook#append_page ~tab_label:(self#tab_label metano) (win metano))
244         metasenv;
245       switch_page_callback <-
246         Some (notebook#connect#switch_page ~callback:(fun page ->
247           let goal =
248             try
249               List.assoc page page2goal
250             with Not_found -> assert false
251           in
252           self#script#setGoal goal;
253           self#render_page ~page ~goal))
254
255     method private render_page ~page ~goal =
256       sequentViewer#load_sequent _metasenv goal;
257       try
258         List.assoc goal goal2win ();
259         sequentViewer#set_selection None
260       with Not_found -> assert false
261
262     method goto_sequent goal =
263       let page =
264         try
265           List.assoc goal goal2page
266         with Not_found -> assert false
267       in
268       notebook#goto_page page;
269       self#render_page page goal
270
271   end
272
273  (** constructors *)
274
275 type 'widget constructor =
276   ?hadjustment:GData.adjustment ->
277   ?vadjustment:GData.adjustment ->
278   ?font_size:int ->
279   ?log_verbosity:int ->
280   ?width:int ->
281   ?height:int ->
282   ?packing:(GObj.widget -> unit) ->
283   ?show:bool ->
284   unit ->
285     'widget
286
287 let sequentViewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
288   GtkBase.Widget.size_params
289     ~cont:(OgtkMathViewProps.pack_return (fun p ->
290       OgtkMathViewProps.set_params
291         (new sequentViewer (GtkMathViewProps.MathView_GMetaDOM.create p))
292         ~font_size ~log_verbosity))
293     []
294
295 let blank_uri = BuildTimeConf.blank_uri
296 let current_proof_uri = BuildTimeConf.current_proof_uri
297
298 type term_source =
299   [ `Ast of DisambiguateTypes.term
300   | `Cic of Cic.term * Cic.metasenv
301   | `String of string
302   ]
303
304 class type cicBrowser =
305 object
306   method load: MatitaTypes.mathViewer_entry -> unit
307   (* method loadList: string list -> MatitaTypes.mathViewer_entry-> unit *)
308   method loadInput: string -> unit
309 end
310
311 let reloadable = function
312   | `About `Current_proof
313   | `Dir _ ->
314       true
315   | _ -> false
316
317 class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
318   ()
319 =
320   let term_RE = Pcre.regexp "^term:(.*)" in
321   let whelp_RE = Pcre.regexp "^\\s*whelp" in
322   let uri_RE =
323     Pcre.regexp
324       "^cic:/([^/]+/)*[^/]+\\.(con|ind|var)(#xpointer\\(\\d+(/\\d+)+\\))?$"
325   in
326   let dir_RE = Pcre.regexp "^cic:((/([^/]+/)*[^/]+(/)?)|/|)$" in
327   let whelp_query_RE = Pcre.regexp "^\\s*whelp\\s+([^\\s]+)\\s+(.*)$" in
328   let trailing_slash_RE = Pcre.regexp "/$" in
329   let has_xpointer_RE = Pcre.regexp "#xpointer\\(\\d+/\\d+(/\\d+)?\\)$" in
330   let is_whelp txt = Pcre.pmatch ~rex:whelp_RE txt in
331   let is_uri txt = Pcre.pmatch ~rex:uri_RE txt in
332   let is_dir txt = Pcre.pmatch ~rex:dir_RE txt in
333   let gui = MatitaGui.instance () in
334   let win = gui#newBrowserWin () in
335   let queries = ["Locate";"Hint";"Match";"Elim";"Instance"] in
336   let combo,_ = GEdit.combo_box_text ~strings:queries () in
337   let activate_combo_query input q =
338     let q' = String.lowercase q in
339     let rec aux i = function
340       | [] -> failwith ("Whelp query '" ^ q ^ "' not found")
341       | h::_ when String.lowercase h = q' -> i
342       | _::tl -> aux (i+1) tl
343     in
344     combo#set_active (aux 0 queries);
345     win#queryInputText#set_text input
346   in
347   let set_whelp_query txt =
348     let query, arg = 
349       try
350         let q = Pcre.extract ~rex:whelp_query_RE txt in
351         q.(1), q.(2)
352       with Invalid_argument _ -> failwith "Malformed Whelp query"
353     in
354     activate_combo_query arg query
355   in
356   let toplevel = win#toplevel in
357   let mathView = sequentViewer ~packing:win#scrolledBrowser#add () in
358   let fail message = 
359     MatitaGtkMisc.report_error ~title:"Cic browser" ~message 
360       ~parent:toplevel ()  
361   in
362   let tags =
363     [ "dir", GdkPixbuf.from_file (MatitaMisc.image_path "matita-folder.png");
364       "obj", GdkPixbuf.from_file (MatitaMisc.image_path "matita-object.png") ]
365   in
366   let handle_error f =
367     try
368       f ()
369     with exn -> fail (MatitaExcPp.to_string exn)
370   in
371   let handle_error' f = (fun () -> handle_error (fun () -> f ())) in
372   object (self)
373     inherit scriptAccessor
374     
375     (* Whelp bar queries *)
376
377     initializer
378       activate_combo_query "" "locate";
379       win#whelpBarComboVbox#add combo#coerce;
380       let start_query () = 
381         let query = String.lowercase (List.nth queries combo#active) in
382         let input = win#queryInputText#text in
383         let statement = "whelp " ^ query ^ " " ^ input ^ "." in
384         (MatitaScript.instance ())#advance ~statement ()
385       in
386       ignore(win#queryInputText#connect#activate ~callback:start_query);
387       ignore(combo#connect#changed ~callback:start_query);
388       win#whelpBarImage#set_file (MatitaMisc.image_path "whelp.png");
389       win#mathOrListNotebook#set_show_tabs false;
390
391       win#browserForwardButton#misc#set_sensitive false;
392       win#browserBackButton#misc#set_sensitive false;
393       ignore (win#browserUri#entry#connect#activate (handle_error' (fun () ->
394         self#loadInput win#browserUri#entry#text)));
395       ignore (win#browserHomeButton#connect#clicked (handle_error' (fun () ->
396         self#load (`About `Current_proof))));
397       ignore (win#browserRefreshButton#connect#clicked
398         (handle_error' self#refresh));
399       ignore (win#browserBackButton#connect#clicked (handle_error' self#back));
400       ignore (win#browserForwardButton#connect#clicked
401         (handle_error' self#forward));
402       ignore (win#toplevel#event#connect#delete (fun _ ->
403         let my_id = Oo.id self in
404         cicBrowsers := List.filter (fun b -> Oo.id b <> my_id) !cicBrowsers;
405         if !cicBrowsers = [] &&
406           Helm_registry.get "matita.mode" = "cicbrowser"
407         then
408           GMain.quit ();
409         false));
410       ignore(win#whelpResultTreeview#connect#row_activated 
411         ~callback:(fun _ _ ->
412           handle_error (fun () -> self#loadInput (self#_getSelectedUri ()))));
413       mathView#set_href_callback (Some (fun uri ->
414         handle_error (fun () ->
415           self#load (`Uri (UriManager.uri_of_string uri)))));
416       self#_load (`About `Blank);
417       toplevel#show ()
418
419     val mutable current_entry = `About `Blank 
420     val mutable current_infos = None
421     val mutable current_mathml = None
422
423     val model =
424       new MatitaGtkMisc.taggedStringListModel tags win#whelpResultTreeview
425
426     val mutable lastDir = ""  (* last loaded "directory" *)
427
428     method private _getSelectedUri () =
429       match model#easy_selection () with
430       | [sel] when is_uri sel -> sel  (* absolute URI selected *)
431 (*       | [sel] -> win#browserUri#entry#text ^ sel  |+ relative URI selected +| *)
432       | [sel] -> lastDir ^ sel
433       | _ -> assert false
434
435     (** history RATIONALE 
436      *
437      * All operations about history are done using _historyFoo.
438      * Only toplevel functions (ATM load and loadInput) call _historyAdd.
439      *)
440           
441     method private _historyAdd item = 
442       history#add item;
443       win#browserBackButton#misc#set_sensitive true;
444       win#browserForwardButton#misc#set_sensitive false
445
446     method private _historyPrev () =
447       let item = history#previous in
448       if history#is_begin then win#browserBackButton#misc#set_sensitive false;
449       win#browserForwardButton#misc#set_sensitive true;
450       item
451     
452     method private _historyNext () =
453       let item = history#next in
454       if history#is_end then win#browserForwardButton#misc#set_sensitive false;
455       win#browserBackButton#misc#set_sensitive true;
456       item
457
458     (** notebook RATIONALE 
459      * 
460      * Use only these functions to switch between the tabs
461      *)
462     method private _showList = win#mathOrListNotebook#goto_page 1
463     method private _showMath = win#mathOrListNotebook#goto_page 0
464     
465     method private back () =
466       try
467         self#_load (self#_historyPrev ())
468       with MatitaMisc.History_failure -> ()
469
470     method private forward () =
471       try
472         self#_load (self#_historyNext ())
473       with MatitaMisc.History_failure -> ()
474
475       (* loads a uri which can be a cic uri or an about:* uri
476       * @param uri string *)
477     method private _load entry =
478       try
479         if entry <> current_entry || reloadable entry then begin
480           (match entry with
481           | `About `Current_proof -> self#home ()
482           | `About `Blank -> self#blank ()
483           | `About `Us -> () (* TODO implement easter egg here :-] *)
484           | `Check term -> self#_loadCheck term
485           | `Cic (term, metasenv) -> self#_loadTermCic term metasenv
486           | `Dir dir -> self#_loadDir dir
487           | `Uri uri -> self#_loadUriManagerUri uri
488           | `Whelp (query, results) -> 
489               set_whelp_query query;
490               self#_loadList (List.map (fun r -> "obj",
491                 UriManager.string_of_uri r) results));
492           self#setEntry entry
493         end
494       with exn -> fail (MatitaExcPp.to_string exn)
495
496     method private blank () =
497       self#_showMath;
498       mathView#load_root (MatitaMisc.empty_mathml ())#get_documentElement
499
500     method private _loadCheck term =
501       failwith "not implemented _loadCheck";
502       self#_showMath
503
504     method private home () =
505       self#_showMath;
506       match self#script#status.proof_status with
507       | Proof  (uri, metasenv, bo, ty) ->
508           let name = UriManager.name_of_uri (MatitaMisc.unopt uri) in
509           let obj = Cic.CurrentProof (name, metasenv, bo, ty, [], []) in
510           self#_loadObj obj
511       | Incomplete_proof ((uri, metasenv, bo, ty), _) -> 
512           let name = UriManager.name_of_uri (MatitaMisc.unopt uri) in
513           let obj = Cic.CurrentProof (name, metasenv, bo, ty, [], []) in
514           self#_loadObj obj
515       | _ -> self#blank ()
516
517       (** loads a cic uri from the environment
518       * @param uri UriManager.uri *)
519     method private _loadUriManagerUri uri =
520       let uri = UriManager.strip_xpointer uri in
521       let (obj, _) = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
522       self#_loadObj obj
523       
524     method private _loadDir dir = 
525       let content = Http_getter.ls dir in
526       let l =
527         List.fast_sort
528           Pervasives.compare
529           (List.map
530             (function 
531               | Http_getter_types.Ls_section s -> "dir", s
532               | Http_getter_types.Ls_object o -> "obj", o.Http_getter_types.uri)
533             content)
534       in
535       lastDir <- dir;
536       self#_loadList l
537
538     method private setEntry entry =
539       win#browserUri#entry#set_text (string_of_entry entry);
540       current_entry <- entry
541
542     method private _loadObj obj =
543       self#_showMath; 
544       (* this must be _before_ loading the document, since 
545        * if the widget is not mapped (hidden by the notebook)
546        * the document is not rendered *)
547       let use_diff = false in (* ZACK TODO use XmlDiff when re-rendering? *)
548       let (mathml, (_,(ids_to_terms, ids_to_father_ids, ids_to_conjectures,
549            ids_to_hypotheses,_,_))) =
550         ApplyTransformation.mml_of_cic_object obj
551       in
552       current_infos <- Some (ids_to_terms, ids_to_father_ids,
553         ids_to_conjectures, ids_to_hypotheses);
554       (match current_mathml with
555       | Some current_mathml when use_diff ->
556           mathView#freeze;
557           XmlDiff.update_dom ~from:current_mathml mathml;
558           mathView#thaw
559       |  _ ->
560           let name = "cic_browser.xml" in
561           prerr_endline ("cic_browser: dumping MathML to ./" ^ name);
562           ignore (DomMisc.domImpl#saveDocumentToFile ~name ~doc:mathml ());
563           mathView#load_root ~root:mathml#get_documentElement;
564           current_mathml <- Some mathml);
565
566     method private _loadTermCic term metasenv =
567       let context = self#script#proofContext in
568       let dummyno = CicMkImplicit.new_meta metasenv [] in
569       let sequent = (dummyno, context, term) in
570       mathView#load_sequent (sequent :: metasenv) dummyno;
571       self#_showMath
572
573     method private _loadList l =
574       model#list_store#clear ();
575       List.iter (fun (tag, s) -> model#easy_append ~tag s) l;
576       self#_showList
577     
578     (** { public methods, all must call _load!! } *)
579       
580     method load entry =
581       handle_error (fun () -> self#_load entry; self#_historyAdd entry)
582
583     (**  this is what the browser does when you enter a string an hit enter *)
584     method loadInput txt =
585       let txt = strip_blanks txt in
586       let fix_uri txt =
587         UriManager.string_of_uri
588           (UriManager.strip_xpointer (UriManager.uri_of_string txt))
589       in
590       if is_whelp txt then begin
591         set_whelp_query txt;  
592         (MatitaScript.instance ())#advance ~statement:(txt ^ ".") ()
593       end else begin
594         let entry =
595           match txt with
596           | txt when is_uri txt -> `Uri (UriManager.uri_of_string (fix_uri txt))
597           | txt when is_dir txt -> `Dir (add_trailing_slash txt)
598           | txt ->
599               (try
600                 entry_of_string txt
601               with Invalid_argument _ ->
602                 command_error (sprintf "unsupported uri: %s" txt))
603         in
604         self#_load entry;
605         self#_historyAdd entry
606       end
607
608       (** {2 methods accessing underlying GtkMathView} *)
609
610     method updateFontSize = mathView#set_font_size !current_font_size
611
612       (** {2 methods used by constructor only} *)
613
614     method win = win
615     method history = history
616     method currentEntry = current_entry
617     method refresh () =
618       if reloadable current_entry then self#_load current_entry
619
620   end
621   
622 let sequentsViewer ~(notebook:GPack.notebook)
623   ~(sequentViewer:sequentViewer) ()
624 =
625   new sequentsViewer ~notebook ~sequentViewer ()
626
627 let cicBrowser () =
628   let size = BuildTimeConf.browser_history_size in
629   let rec aux history =
630     let browser = new cicBrowser_impl ~history () in
631     let win = browser#win in
632     ignore (win#browserNewButton#connect#clicked (fun () ->
633       let history =
634         new MatitaMisc.browser_history ~memento:history#save size
635           (`About `Blank)
636       in
637       let newBrowser = aux history in
638       newBrowser#load browser#currentEntry));
639 (*
640       (* attempt (failed) to close windows on CTRL-W ... *)
641     MatitaGtkMisc.connect_key win#browserWinEventBox#event ~modifiers:[`CONTROL]
642       GdkKeysyms._W (fun () -> win#toplevel#destroy ());
643 *)
644     cicBrowsers := browser :: !cicBrowsers;
645     (browser :> cicBrowser)
646   in
647   let history = new MatitaMisc.browser_history size (`About `Blank) in
648   aux history
649
650 let default_sequentViewer () = sequentViewer ~show:true ()
651 let sequentViewer_instance = MatitaMisc.singleton default_sequentViewer
652
653 let default_sequentsViewer () =
654   let gui = MatitaGui.instance () in
655   let sequentViewer = sequentViewer_instance () in
656   sequentsViewer ~notebook:gui#main#sequentsNotebook ~sequentViewer ()
657 let sequentsViewer_instance = MatitaMisc.singleton default_sequentsViewer
658
659 let mathViewer () = 
660   object(self)
661     method private get_browser reuse = 
662       if reuse then
663         (match !cicBrowsers with
664         | [] -> cicBrowser ()
665         | b :: _ -> (b :> cicBrowser))
666       else
667         (cicBrowser ())
668           
669     method show_entry ?(reuse=false) t = (self#get_browser reuse)#load t
670       
671     method show_uri_list ?(reuse=false) ~entry l =
672       (self#get_browser reuse)#load entry
673   end
674
675 let refresh_all_browsers () = List.iter (fun b -> b#refresh ()) !cicBrowsers
676
677 let update_font_sizes () =
678   List.iter (fun b -> b#updateFontSize) !cicBrowsers;
679   (sequentViewer_instance ())#update_font_size
680