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