connect_menu_item main#newMenuItem self#newScript;
connect_menu_item main#closeMenuItem self#closeCurrentScript;
connect_menu_item main#showCoercionsGraphMenuItem
- (fun _ ->
- let c = MatitaMathView.cicBrowser () in
- c#load (`About `Coercions));
+ (fun _ -> MatitaMathView.cicBrowser (Some (`About `Coercions)));
connect_menu_item main#showHintsDbMenuItem
- (fun _ ->
- let c = MatitaMathView.cicBrowser () in
- c#load (`About `Hints));
+ (fun _ -> MatitaMathView.cicBrowser (Some (`About `Hints)));
connect_menu_item main#showTermGrammarMenuItem
- (fun _ ->
- let c = MatitaMathView.cicBrowser () in
- c#load (`About `Grammar));
+ (fun _ -> MatitaMathView.cicBrowser (Some (`About `Grammar)));
connect_menu_item main#showUnicodeTable
- (fun _ ->
- let c = MatitaMathView.cicBrowser () in
- c#load (`About `TeX));
+ (fun _ -> MatitaMathView.cicBrowser (Some (`About `TeX)));
(* debug menu *)
main#debugMenu#misc#hide ();
(* HBUGS *)
main#hpaneScriptSequent#set_position script_w;
(* math view handling *)
connect_menu_item main#newCicBrowserMenuItem (fun () ->
- ignore(MatitaMathView.cicBrowser ()));
+ ignore(MatitaMathView.cicBrowser None));
connect_menu_item main#increaseFontSizeMenuItem
MatitaMisc.increase_font_size;
connect_menu_item main#decreaseFontSizeMenuItem
method goto_sequent:
#ApplyTransformation.status -> int -> unit (* to be called _after_ load_sequents *)
end
-
-class type cicBrowser =
-object
- method load: MatitaTypes.mathViewer_entry -> unit
-end
=
(new sequentsViewer ~notebook ~cicMathView ():> MatitaGuiTypes.sequentsViewer)
-let cicBrowser () =
+let new_cicBrowser () =
let size = BuildTimeConf.browser_history_size in
let rec aux history =
let browser = new cicBrowser_impl ~history () in
GdkKeysyms._W (fun () -> win#toplevel#destroy ());
*)
cicBrowsers := browser :: !cicBrowsers;
- (browser :> MatitaGuiTypes.cicBrowser)
+ browser
in
let history = new MatitaMisc.browser_history size (`About `Blank) in
aux history
+(** @param reuse if set reused last opened cic browser otherwise
+* opens a new one. default is false *)
+let cicBrowser ?(reuse=false) t =
+ let browser =
+ if reuse then
+ (match !cicBrowsers with [] -> new_cicBrowser () | b :: _ -> b)
+ else
+ new_cicBrowser ()
+ in
+ match t with
+ None -> ()
+ | Some t -> browser#load t
+;;
+
let default_cicMathView () =
let res = cicMathView ~show:true () in
res#set_href_callback
(Some (fun uri ->
let uri = `NRef (NReference.reference_of_string uri) in
- (cicBrowser ())#load uri));
+ cicBrowser (Some uri)));
res
let cicMathView_instance =
let default_sequentsViewer notebook =
let cicMathView = cicMathView_instance () in
sequentsViewer ~notebook ~cicMathView ()
+
let sequentsViewer_instance =
let already_used = ref false in
fun notebook ->
(already_used := true;
default_sequentsViewer notebook)
-(** @param reuse if set reused last opened cic browser otherwise
-* opens a new one. default is false *)
-let show_entry ?(reuse=false) t =
- let browser =
- if reuse then
- (match !cicBrowsers with
- [] -> cicBrowser ()
- | b :: _ -> (b :> MatitaGuiTypes.cicBrowser))
- else
- cicBrowser ()
- in
- browser#load t
-;;
-
let refresh_all_browsers () =
List.iter (fun b -> b#refresh ~force:false ()) !cicBrowsers
* http://helm.cs.unibo.it/
*)
-(** {2 Instances} *)
-val cicBrowser: unit -> MatitaGuiTypes.cicBrowser
-
(** {2 To be called just once} *)
-val sequentsViewer_instance: GPack.notebook -> MatitaGuiTypes.sequentsViewer
+val sequentsViewer_instance: GPack.notebook -> MatitaGuiTypes.sequentsViewer
(** {2 Global changes} *)
-
val refresh_all_browsers: unit -> unit (** act on all cicBrowsers *)
(** {2 Rendering in a browser} *)
-
(** @param reuse if set reused last opened cic browser otherwise
* opens a new one. default is false *)
-val show_entry: ?reuse:bool -> MatitaTypes.mathViewer_entry -> unit
+val cicBrowser: ?reuse:bool -> MatitaTypes.mathViewer_entry option -> unit
(** {2 Clipboard & Selection handling} *)
NotationPt.Cast (t,NotationPt.Implicit `JustOne))
(* XXX use the metasenv, if possible *)
in
- MatitaMathView.show_entry (`NCic (t,ctx,m,s));
+ MatitaMathView.cicBrowser (Some (`NCic (t,ctx,m,s)));
[status, parsed_text], "", parsed_text_length
| TA.NIntroGuess _loc ->
let names_ref = ref [] in