1 (* Copyright (C) 2004-2005, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
31 let add_trailing_slash =
32 let rex = Pcre.regexp "/$" in
34 if Pcre.pmatch ~rex s then s
38 let rex = Pcre.regexp "^\\s*([^\\s]*)\\s*$" in
40 (Pcre.extract ~rex s).(1)
42 (** inherit from this class if you want to access current script *)
43 class scriptAccessor =
45 method private script = MatitaScript.instance ()
48 let cicBrowsers = ref []
49 let gui_instance = ref None
50 let set_gui gui = gui_instance := Some gui
52 match !gui_instance with
53 | None -> assert false
56 let default_font_size () =
57 Helm_registry.get_opt_default Helm_registry.int
58 ~default:BuildTimeConf.default_font_size "matita.font_size"
59 let current_font_size = ref ~-1
60 let increase_font_size () = incr current_font_size
61 let decrease_font_size () = decr current_font_size
62 let reset_font_size () = current_font_size := default_font_size ()
64 (* is there any lablgtk2 constant corresponding to the various mouse
70 let near (x1, y1) (x2, y2) =
71 let distance = sqrt (((x2 -. x1) ** 2.) +. ((y2 -. y1) ** 2.)) in
74 let href_ds = Gdome.domString "href"
75 let xref_ds = Gdome.domString "xref"
77 class clickableMathView obj =
78 let text_width = 80 in
80 inherit GMathViewAux.multi_selection_math_view obj
82 val mutable href_callback: (string -> unit) option = None
83 method set_href_callback f = href_callback <- f
85 val mutable _cic_info = None
86 method private set_cic_info info = _cic_info <- info
87 method private cic_info =
90 | None -> assert false
93 self#set_font_size !current_font_size;
94 ignore (self#connect#selection_changed self#choose_selection_cb);
95 ignore (self#event#connect#button_press self#button_press_cb);
96 ignore (self#event#connect#button_release self#button_release_cb);
97 ignore (self#event#connect#selection_clear self#selection_clear_cb);
98 ignore (self#coerce#misc#connect#selection_get self#selection_get_cb)
100 val mutable button_press_x = -1.
101 val mutable button_press_y = -1.
102 val mutable selection_changed = false
104 method private selection_get_cb ctxt ~info ~time =
105 (match self#get_selections with
107 | node :: _ -> ctxt#return (self#string_of_node node))
109 method private selection_clear_cb sel_event =
110 self#remove_selections;
113 method private button_press_cb gdk_button =
114 let button = GdkEvent.Button.button gdk_button in
115 if button = left_button then begin
116 button_press_x <- GdkEvent.Button.x gdk_button;
117 button_press_y <- GdkEvent.Button.y gdk_button;
118 selection_changed <- false
119 end else if button = right_button then
120 self#popup_contextual_menu (GdkEvent.Button.time gdk_button);
123 method private popup_contextual_menu time =
124 match self#string_of_selection with
127 let clipboard = GData.clipboard Gdk.Atom.clipboard in
128 let menu = GMenu.menu () in
130 GMenu.image_menu_item
131 ~label:"_Copy" ~stock:`COPY ~packing:menu#append ()
133 connect_menu_item copy_menu_item (fun () -> clipboard#set_text s);
134 menu#popup ~button:right_button ~time
136 method private button_release_cb gdk_button =
137 let clipboard = GData.clipboard Gdk.Atom.primary in
138 if GdkEvent.Button.button gdk_button = left_button then begin
139 let button_release_x = GdkEvent.Button.x gdk_button in
140 let button_release_y = GdkEvent.Button.y gdk_button in
141 if selection_changed then
143 else (* selection _not_ changed *)
144 if near (button_press_x, button_press_y)
145 (button_release_x, button_release_y)
147 let x = int_of_float button_press_x in
148 let y = int_of_float button_press_y in
149 (match self#get_element_at x y with
152 let namespaceURI = DomMisc.xlink_ns in
153 let localName = href_ds in
154 if elt#hasAttributeNS ~namespaceURI ~localName then
155 self#invoke_href_callback
156 (elt#getAttributeNS ~namespaceURI ~localName)#to_string
159 ignore (self#action_toggle elt));
163 method private invoke_href_callback href_value gdk_button =
164 let button = GdkEvent.Button.button gdk_button in
165 if button = left_button then
166 let time = GdkEvent.Button.time gdk_button in
167 match href_callback with
170 (match MatitaMisc.split href_value with
173 let menu = GMenu.menu () in
177 GMenu.menu_item ~label:uri ~packing:menu#append ()
179 connect_menu_item menu_item (fun () -> f uri))
181 menu#popup ~button ~time)
183 method private choose_selection_cb gdome_elt =
184 let (gui: MatitaGuiTypes.gui) = get_gui () in
185 let clipboard = GData.clipboard Gdk.Atom.primary in
187 if (elt#getAttributeNS ~namespaceURI:DomMisc.helm_ns
188 ~localName:xref_ds)#to_string <> ""
189 (* if elt#hasAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref_ds
190 && (elt#getAttributeNS ~namespaceURI:DomMisc.helm_ns
191 ~localName:xref_ds)#to_string <> "" *)
193 self#set_selection (Some elt);
194 self#coerce#misc#add_selection_target
195 ~target:(Gdk.Atom.name Gdk.Atom.string) Gdk.Atom.primary;
196 ignore (self#coerce#misc#grab_selection Gdk.Atom.primary)
199 (match elt#get_parentNode with
200 | None -> assert false
201 | Some p -> aux (new Gdome.element_of_node p))
202 with GdomeInit.DOMCastException _ -> ()
204 (match gdome_elt with
205 | Some elt -> aux elt
206 | None -> self#set_selection None);
207 selection_changed <- true
209 method update_font_size = self#set_font_size !current_font_size
211 method private get_term_by_id context id =
212 let ids_to_terms, ids_to_hypotheses = self#cic_info in
214 `Term (Hashtbl.find ids_to_terms id)
217 let hyp = Hashtbl.find ids_to_hypotheses id in
218 let context' = MatitaMisc.list_tl_at hyp context in
220 with Not_found -> assert false
222 method private string_of_node node =
223 let get_id (node: Gdome.element) =
225 node#getAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref_ds
229 let script = MatitaScript.instance () in
230 let metasenv = script#proofMetasenv in
231 let context = script#proofContext in
232 let conclusion = script#proofConclusion in
233 (* TODO: code for patterns
234 let conclusion = (MatitaScript.instance ())#proofConclusion in
235 let conclusion_pattern =
236 ProofEngineHelpers.pattern_of ~term:conclusion cic_terms
239 let dummy_goal = ~-1 in
240 let string_of_cic_sequent cic_sequent =
241 let acic_sequent, _, _, ids_to_inner_sorts, _ =
242 Cic2acic.asequent_of_sequent metasenv cic_sequent
244 let _, _, _, annterm = acic_sequent in
245 let ast, ids_to_uris =
246 CicNotationRew.ast_of_acic ids_to_inner_sorts annterm
248 let pped_ast = CicNotationRew.pp_ast ast in
249 let markup = CicNotationPres.render ids_to_uris pped_ast in
250 BoxPp.render_to_string text_width markup
252 let term = self#get_term_by_id context (get_id node) in
258 ProofEngineHelpers.locate_in_conjecture t
259 (dummy_goal, context, conclusion)
261 [context,_] -> context
262 | _ -> assert false (* since it uses physical equality *)
264 dummy_goal, context', t
265 | `Hyp context -> dummy_goal, context, Cic.Rel 1
267 string_of_cic_sequent cic_sequent
269 method string_of_selections =
270 List.map self#string_of_node (List.rev self#get_selections)
272 method string_of_selection =
273 match self#get_selections with
275 | node :: _ -> Some (self#string_of_node node)
279 let clickableMathView ?hadjustment ?vadjustment ?font_size ?log_verbosity =
280 GtkBase.Widget.size_params
281 ~cont:(OgtkMathViewProps.pack_return (fun p ->
282 OgtkMathViewProps.set_params
283 (new clickableMathView (GtkMathViewProps.MathView_GMetaDOM.create p))
284 ~font_size:None ~log_verbosity:None))
287 class sequentViewer obj =
289 inherit clickableMathView obj
291 method load_sequent metasenv metano =
292 let sequent = CicUtil.lookup_meta metano metasenv in
293 let (mathml, (_, (ids_to_terms, _, ids_to_hypotheses,_ ))) =
294 ApplyTransformation.mml_of_cic_sequent metasenv sequent
296 self#set_cic_info (Some (ids_to_terms, ids_to_hypotheses));
297 let name = "sequent_viewer.xml" in
298 MatitaLog.debug ("load_sequent: dumping MathML to ./" ^ name);
299 ignore (DomMisc.domImpl#saveDocumentToFile ~name ~doc:mathml ());
300 self#load_root ~root:mathml#get_documentElement
303 class sequentsViewer ~(notebook:GPack.notebook)
304 ~(sequentViewer:sequentViewer) ()
307 inherit scriptAccessor
309 val mutable pages = 0
310 val mutable switch_page_callback = None
311 val mutable page2goal = [] (* associative list: page no -> goal no *)
312 val mutable goal2page = [] (* the other way round *)
313 val mutable goal2win = [] (* associative list: goal no -> scrolled win *)
314 val mutable _metasenv = []
315 val mutable scrolledWin: GBin.scrolled_window option = None
316 (* scrolled window to which the sequentViewer is currently attached *)
318 method private tab_label metano =
319 (GMisc.label ~text:(sprintf "?%d" metano) ~show:true ())#coerce
322 (match scrolledWin with
324 (* removing page from the notebook will destroy all contained widget,
325 * we do not want the sequentViewer to be destroyed as well *)
326 w#remove sequentViewer#coerce;
329 for i = 1 to pages do notebook#remove_page 0 done;
335 self#script#setGoal ~-1;
336 (match switch_page_callback with
338 GtkSignal.disconnect notebook#as_widget id;
339 switch_page_callback <- None
342 method load_sequents (status: ProofEngineTypes.status) =
343 let ((_, metasenv, _, _), goal) = status in
344 let sequents_no = List.length metasenv in
345 _metasenv <- metasenv;
346 pages <- sequents_no;
347 self#script#setGoal goal;
350 GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
351 ~shadow_type:`IN ~show:true ()
354 scrolledWin <- Some w;
355 match sequentViewer#misc#parent with
356 | None -> w#add sequentViewer#coerce
359 match sequentViewer#misc#parent with
361 | Some p -> GContainer.cast_container p
363 parent#remove sequentViewer#coerce;
364 w#add sequentViewer#coerce
366 goal2win <- (metano, reparent) :: goal2win;
371 (fun (metano, _, _) ->
372 page2goal <- (!page, metano) :: page2goal;
373 goal2page <- (metano, !page) :: goal2page;
375 notebook#append_page ~tab_label:(self#tab_label metano) (win metano))
377 switch_page_callback <-
378 Some (notebook#connect#switch_page ~callback:(fun page ->
381 List.assoc page page2goal
382 with Not_found -> assert false
384 self#script#setGoal goal;
385 self#render_page ~page ~goal))
387 method private render_page ~page ~goal =
388 sequentViewer#load_sequent _metasenv goal;
390 List.assoc goal goal2win ();
391 sequentViewer#set_selection None
392 with Not_found -> assert false
394 method goto_sequent goal =
397 List.assoc goal goal2page
398 with Not_found -> assert false
400 notebook#goto_page page;
401 self#render_page page goal
407 type 'widget constructor =
408 ?hadjustment:GData.adjustment ->
409 ?vadjustment:GData.adjustment ->
411 ?log_verbosity:int ->
414 ?packing:(GObj.widget -> unit) ->
419 let sequentViewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
420 GtkBase.Widget.size_params
421 ~cont:(OgtkMathViewProps.pack_return (fun p ->
422 OgtkMathViewProps.set_params
423 (new sequentViewer (GtkMathViewProps.MathView_GMetaDOM.create p))
424 ~font_size ~log_verbosity))
427 let blank_uri = BuildTimeConf.blank_uri
428 let current_proof_uri = BuildTimeConf.current_proof_uri
431 [ `Ast of DisambiguateTypes.term
432 | `Cic of Cic.term * Cic.metasenv
436 let reloadable = function
437 | `About `Current_proof
442 class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
445 let term_RE = Pcre.regexp "^term:(.*)" in
446 let whelp_RE = Pcre.regexp "^\\s*whelp" in
449 "^cic:/([^/]+/)*[^/]+\\.(con|ind|var)(#xpointer\\(\\d+(/\\d+)+\\))?$"
451 let dir_RE = Pcre.regexp "^cic:((/([^/]+/)*[^/]+(/)?)|/|)$" in
452 let whelp_query_RE = Pcre.regexp "^\\s*whelp\\s+([^\\s]+)\\s+(.*)$" in
453 let trailing_slash_RE = Pcre.regexp "/$" in
454 let has_xpointer_RE = Pcre.regexp "#xpointer\\(\\d+/\\d+(/\\d+)?\\)$" in
455 let is_whelp txt = Pcre.pmatch ~rex:whelp_RE txt in
456 let is_uri txt = Pcre.pmatch ~rex:uri_RE txt in
457 let is_dir txt = Pcre.pmatch ~rex:dir_RE txt in
458 let gui = get_gui () in
459 let (win: MatitaGuiTypes.browserWin) = gui#newBrowserWin () in
460 let queries = ["Locate";"Hint";"Match";"Elim";"Instance"] in
461 let combo,_ = GEdit.combo_box_text ~strings:queries () in
462 let activate_combo_query input q =
463 let q' = String.lowercase q in
464 let rec aux i = function
465 | [] -> failwith ("Whelp query '" ^ q ^ "' not found")
466 | h::_ when String.lowercase h = q' -> i
467 | _::tl -> aux (i+1) tl
469 combo#set_active (aux 0 queries);
470 win#queryInputText#set_text input
472 let set_whelp_query txt =
475 let q = Pcre.extract ~rex:whelp_query_RE txt in
477 with Invalid_argument _ -> failwith "Malformed Whelp query"
479 activate_combo_query arg query
481 let toplevel = win#toplevel in
482 let mathView = sequentViewer ~packing:win#scrolledBrowser#add () in
484 MatitaGtkMisc.report_error ~title:"Cic browser" ~message
488 [ "dir", GdkPixbuf.from_file (MatitaMisc.image_path "matita-folder.png");
489 "obj", GdkPixbuf.from_file (MatitaMisc.image_path "matita-object.png") ]
494 with exn -> fail (MatitaExcPp.to_string exn)
496 let handle_error' f = (fun () -> handle_error (fun () -> f ())) in
498 inherit scriptAccessor
500 (* Whelp bar queries *)
503 activate_combo_query "" "locate";
504 win#whelpBarComboVbox#add combo#coerce;
506 let query = String.lowercase (List.nth queries combo#active) in
507 let input = win#queryInputText#text in
508 let statement = "whelp " ^ query ^ " " ^ input ^ "." in
509 (MatitaScript.instance ())#advance ~statement ()
511 ignore(win#queryInputText#connect#activate ~callback:start_query);
512 ignore(combo#connect#changed ~callback:start_query);
513 win#whelpBarImage#set_file (MatitaMisc.image_path "whelp.png");
514 win#mathOrListNotebook#set_show_tabs false;
516 win#browserForwardButton#misc#set_sensitive false;
517 win#browserBackButton#misc#set_sensitive false;
518 ignore (win#browserUri#entry#connect#activate (handle_error' (fun () ->
519 self#loadInput win#browserUri#entry#text)));
520 ignore (win#browserHomeButton#connect#clicked (handle_error' (fun () ->
521 self#load (`About `Current_proof))));
522 ignore (win#browserRefreshButton#connect#clicked
523 (handle_error' self#refresh));
524 ignore (win#browserBackButton#connect#clicked (handle_error' self#back));
525 ignore (win#browserForwardButton#connect#clicked
526 (handle_error' self#forward));
527 ignore (win#toplevel#event#connect#delete (fun _ ->
528 let my_id = Oo.id self in
529 cicBrowsers := List.filter (fun b -> Oo.id b <> my_id) !cicBrowsers;
530 if !cicBrowsers = [] &&
531 Helm_registry.get "matita.mode" = "cicbrowser"
535 ignore(win#whelpResultTreeview#connect#row_activated
536 ~callback:(fun _ _ ->
537 handle_error (fun () -> self#loadInput (self#_getSelectedUri ()))));
538 mathView#set_href_callback (Some (fun uri ->
539 handle_error (fun () ->
540 self#load (`Uri (UriManager.uri_of_string uri)))));
541 self#_load (`About `Blank);
544 val mutable current_entry = `About `Blank
545 val mutable current_infos = None
546 val mutable current_mathml = None
549 new MatitaGtkMisc.taggedStringListModel tags win#whelpResultTreeview
551 val mutable lastDir = "" (* last loaded "directory" *)
553 method mathView = (mathView :> MatitaGuiTypes.clickableMathView)
555 method private _getSelectedUri () =
556 match model#easy_selection () with
557 | [sel] when is_uri sel -> sel (* absolute URI selected *)
558 (* | [sel] -> win#browserUri#entry#text ^ sel |+ relative URI selected +| *)
559 | [sel] -> lastDir ^ sel
562 (** history RATIONALE
564 * All operations about history are done using _historyFoo.
565 * Only toplevel functions (ATM load and loadInput) call _historyAdd.
568 method private _historyAdd item =
570 win#browserBackButton#misc#set_sensitive true;
571 win#browserForwardButton#misc#set_sensitive false
573 method private _historyPrev () =
574 let item = history#previous in
575 if history#is_begin then win#browserBackButton#misc#set_sensitive false;
576 win#browserForwardButton#misc#set_sensitive true;
579 method private _historyNext () =
580 let item = history#next in
581 if history#is_end then win#browserForwardButton#misc#set_sensitive false;
582 win#browserBackButton#misc#set_sensitive true;
585 (** notebook RATIONALE
587 * Use only these functions to switch between the tabs
589 method private _showList = win#mathOrListNotebook#goto_page 1
590 method private _showMath = win#mathOrListNotebook#goto_page 0
592 method private back () =
594 self#_load (self#_historyPrev ())
595 with MatitaMisc.History_failure -> ()
597 method private forward () =
599 self#_load (self#_historyNext ())
600 with MatitaMisc.History_failure -> ()
602 (* loads a uri which can be a cic uri or an about:* uri
603 * @param uri string *)
604 method private _load entry =
606 if entry <> current_entry || reloadable entry then begin
608 | `About `Current_proof -> self#home ()
609 | `About `Blank -> self#blank ()
610 | `About `Us -> () (* TODO implement easter egg here :-] *)
611 | `Check term -> self#_loadCheck term
612 | `Cic (term, metasenv) -> self#_loadTermCic term metasenv
613 | `Dir dir -> self#_loadDir dir
614 | `Uri uri -> self#_loadUriManagerUri uri
615 | `Whelp (query, results) ->
616 set_whelp_query query;
617 self#_loadList (List.map (fun r -> "obj",
618 UriManager.string_of_uri r) results));
621 with exn -> fail (MatitaExcPp.to_string exn)
623 method private blank () =
625 mathView#load_root (MatitaMisc.empty_mathml ())#get_documentElement
627 method private _loadCheck term =
628 failwith "not implemented _loadCheck";
631 method private home () =
633 match self#script#status.proof_status with
634 | Proof (uri, metasenv, bo, ty) ->
635 let name = UriManager.name_of_uri (MatitaMisc.unopt uri) in
636 let obj = Cic.CurrentProof (name, metasenv, bo, ty, [], []) in
638 | Incomplete_proof ((uri, metasenv, bo, ty), _) ->
639 let name = UriManager.name_of_uri (MatitaMisc.unopt uri) in
640 let obj = Cic.CurrentProof (name, metasenv, bo, ty, [], []) in
644 (** loads a cic uri from the environment
645 * @param uri UriManager.uri *)
646 method private _loadUriManagerUri uri =
647 let uri = UriManager.strip_xpointer uri in
648 let (obj, _) = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
651 method private _loadDir dir =
652 let content = Http_getter.ls dir in
658 | Http_getter_types.Ls_section s -> "dir", s
659 | Http_getter_types.Ls_object o -> "obj", o.Http_getter_types.uri)
665 method private setEntry entry =
666 win#browserUri#entry#set_text (string_of_entry entry);
667 current_entry <- entry
669 method private _loadObj obj =
671 (* this must be _before_ loading the document, since
672 * if the widget is not mapped (hidden by the notebook)
673 * the document is not rendered *)
674 let use_diff = false in (* ZACK TODO use XmlDiff when re-rendering? *)
675 let (mathml, (_,((ids_to_terms, ids_to_father_ids, ids_to_conjectures,
676 ids_to_hypotheses, ids_to_inner_sorts, ids_to_inner_types) as info)))
678 ApplyTransformation.mml_of_cic_object obj
680 current_infos <- Some info;
681 (match current_mathml with
682 | Some current_mathml when use_diff ->
684 XmlDiff.update_dom ~from:current_mathml mathml;
687 let name = "cic_browser.xml" in
688 MatitaLog.debug ("cic_browser: dumping MathML to ./" ^ name);
689 ignore (DomMisc.domImpl#saveDocumentToFile ~name ~doc:mathml ());
690 mathView#load_root ~root:mathml#get_documentElement;
691 current_mathml <- Some mathml);
693 method private _loadTermCic term metasenv =
694 let context = self#script#proofContext in
695 let dummyno = CicMkImplicit.new_meta metasenv [] in
696 let sequent = (dummyno, context, term) in
697 mathView#load_sequent (sequent :: metasenv) dummyno;
700 method private _loadList l =
701 model#list_store#clear ();
702 List.iter (fun (tag, s) -> model#easy_append ~tag s) l;
705 (** { public methods, all must call _load!! } *)
708 handle_error (fun () -> self#_load entry; self#_historyAdd entry)
710 (** this is what the browser does when you enter a string an hit enter *)
711 method loadInput txt =
712 let txt = strip_blanks txt in
714 UriManager.string_of_uri
715 (UriManager.strip_xpointer (UriManager.uri_of_string txt))
717 if is_whelp txt then begin
719 (MatitaScript.instance ())#advance ~statement:(txt ^ ".") ()
723 | txt when is_uri txt -> `Uri (UriManager.uri_of_string (fix_uri txt))
724 | txt when is_dir txt -> `Dir (add_trailing_slash txt)
728 with Invalid_argument _ ->
729 command_error (sprintf "unsupported uri: %s" txt))
732 self#_historyAdd entry
735 (** {2 methods accessing underlying GtkMathView} *)
737 method updateFontSize = mathView#set_font_size !current_font_size
739 (** {2 methods used by constructor only} *)
742 method history = history
743 method currentEntry = current_entry
745 if reloadable current_entry then self#_load current_entry
749 let sequentsViewer ~(notebook:GPack.notebook)
750 ~(sequentViewer:sequentViewer) ()
752 new sequentsViewer ~notebook ~sequentViewer ()
755 let size = BuildTimeConf.browser_history_size in
756 let rec aux history =
757 let browser = new cicBrowser_impl ~history () in
758 let win = browser#win in
759 ignore (win#browserNewButton#connect#clicked (fun () ->
761 new MatitaMisc.browser_history ~memento:history#save size
764 let newBrowser = aux history in
765 newBrowser#load browser#currentEntry));
767 (* attempt (failed) to close windows on CTRL-W ... *)
768 MatitaGtkMisc.connect_key win#browserWinEventBox#event ~modifiers:[`CONTROL]
769 GdkKeysyms._W (fun () -> win#toplevel#destroy ());
771 cicBrowsers := browser :: !cicBrowsers;
772 (browser :> MatitaGuiTypes.cicBrowser)
774 let history = new MatitaMisc.browser_history size (`About `Blank) in
777 let default_sequentViewer () = sequentViewer ~show:true ()
778 let sequentViewer_instance = MatitaMisc.singleton default_sequentViewer
780 let default_sequentsViewer () =
781 let gui = get_gui () in
782 let sequentViewer = sequentViewer_instance () in
783 sequentsViewer ~notebook:gui#main#sequentsNotebook ~sequentViewer ()
784 let sequentsViewer_instance = MatitaMisc.singleton default_sequentsViewer
788 method private get_browser reuse =
790 (match !cicBrowsers with
791 | [] -> cicBrowser ()
792 | b :: _ -> (b :> MatitaGuiTypes.cicBrowser))
796 method show_entry ?(reuse=false) t = (self#get_browser reuse)#load t
798 method show_uri_list ?(reuse=false) ~entry l =
799 (self#get_browser reuse)#load entry
802 let refresh_all_browsers () = List.iter (fun b -> b#refresh ()) !cicBrowsers
804 let update_font_sizes () =
805 List.iter (fun b -> b#updateFontSize) !cicBrowsers;
806 (sequentViewer_instance ())#update_font_size
808 let get_math_views () =
809 ((sequentViewer_instance ()) :> MatitaGuiTypes.clickableMathView)
810 :: (List.map (fun b -> b#mathView) !cicBrowsers)
812 let get_selections () =
813 if (MatitaScript.instance ())#onGoingProof () then
818 (match mv#string_of_selections with
822 aux (get_math_views ())
826 let reset_selections () =
827 List.iter (fun mv -> mv#remove_selections) (get_math_views ())