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