X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2FcicMathView.ml;h=ec42ee8df543f0fd7db44d8372a96874cbc244e0;hb=68b4f2490c12139c03760b39895619e63b0f38c9;hp=2fe7db06b6f0c7d134a8a0985390ab94d61efee2;hpb=f3d0ba1e75bc3383d766f3a33a19352db19854df;p=helm.git diff --git a/matita/matita/cicMathView.ml b/matita/matita/cicMathView.ml index 2fe7db06b..ec42ee8df 100644 --- a/matita/matita/cicMathView.ml +++ b/matita/matita/cicMathView.ml @@ -25,16 +25,14 @@ open Printf -open GrafiteTypes -open MatitaGtkMisc open MatitaGuiTypes -open GtkSourceView2 +open GtkSourceView3 -let matita_script_current = ref (fun _ -> (assert false : < advance: ?statement:string -> unit -> unit; grafite_status: GrafiteTypes.status; setGoal: int option -> unit >));; +let matita_script_current = ref (fun _ -> (assert false : < advance: ?statement:string -> unit -> unit; status: GrafiteTypes.status >));; let register_matita_script_current f = matita_script_current := f;; let get_matita_script_current () = !matita_script_current ();; -type document_element = string +type document_element = (int * int * string) list * string (* hyperlinks,text *) class type cicMathView = object @@ -67,10 +65,10 @@ let xref_ds = Gdome.domString "xref" (** Gdome.element of a MathML document whose rendering should be blank. Used * by cicBrowser to render "about:blank" document *) -let empty_mathml = lazy "" +let empty_mathml = lazy ([],"") (** shown for goals closed by side effects *) -let closed_goal_mathml = lazy "chiuso per side effect..." +let closed_goal_mathml = lazy ([],"chiuso per side effect...") (* let rec has_maction (elt :Gdome.element) = @@ -174,20 +172,74 @@ let string_of_dom_node node = *) class clickableMathView obj = -let text_width = 80 in +(*let text_width = 80 in*) object (self) - inherit GSourceView2.source_view obj + inherit GSourceView3.source_view obj method strings_of_selection = (assert false : (paste_kind * string) list) - method set_href_callback = (function _ -> () : (string -> unit) option -> unit) + + val mutable href_callback: (string -> unit) option = None + method set_href_callback f = href_callback <- f + + val mutable href_statusbar_msg: + (GMisc.statusbar_context * Gtk.statusbar_message) option = None + (* *) + method private set_cic_info = (function _ -> () : unit (*(Cic.conjecture option * (Cic.id, Cic.term) Hashtbl.t * (Cic.id, Cic.hypothesis) Hashtbl.t * (Cic.id, Cic.id option) Hashtbl.t * ('a, 'b) Hashtbl.t * 'c option)*) option -> unit) (* dal widget di Luca *) - method load_root ~root = - self#buffer#delete ~start:(self#buffer#get_iter `START) - ~stop:(self#buffer#get_iter `END); - self#buffer#insert root + method load_root ~root:(hyperlinks,text) = + self#buffer#set_text text; + let all_tag = self#buffer#create_tag [] in + self#buffer#apply_tag all_tag ~start:(self#buffer#get_iter `START) + ~stop:(self#buffer#get_iter `END); + ignore(all_tag#connect#event + ~callback:(fun ~origin:_ event _pos -> + match GdkEvent.get_type event with + | `MOTION_NOTIFY -> + Gdk.Window.set_cursor + (match self#get_window `TEXT with None -> assert false | Some x -> x) + (Gdk.Cursor.create `ARROW); + HExtlib.iter_option (fun (ctxt, msg) -> ctxt#remove msg) + href_statusbar_msg; + false + | _ -> false)); + let hyperlink_tag = self#buffer#create_tag [] in + ignore(hyperlink_tag#connect#event + ~callback:(fun ~origin:_ event pos -> + let offset = (new GText.iter pos)#offset in + let _,_,href = + try + List.find + (fun (start,stop,_href) -> start <= offset && offset <= stop + ) hyperlinks + with + Not_found -> assert false + in + match GdkEvent.get_type event with + `BUTTON_PRESS -> + (match href_callback with + None -> () + | Some f -> f href); + true + | `MOTION_NOTIFY -> + Gdk.Window.set_cursor + (match self#get_window `TEXT with None -> assert false | Some x -> x) + (Gdk.Cursor.create `HAND1); + let ctxt = (MatitaMisc.get_gui ())#main#statusBar#new_context ~name:"href" in + let msg = ctxt#push href in + href_statusbar_msg <- Some (ctxt, msg); + false + | _ -> false)); + List.iter + ( fun (start,stop,(_href : string)) -> + self#buffer#apply_tag hyperlink_tag + ~start:(self#buffer#get_iter_at_char start) + ~stop:(self#buffer#get_iter_at_char (stop+1)); + ) hyperlinks + + method action_toggle = (fun _ -> assert false : document_element -> bool) method remove_selections = (() : unit) method set_selection = (fun _ -> () : document_element option -> unit) @@ -202,7 +254,7 @@ object (self) self#misc#modify_font_by_name (sprintf "%s %d" BuildTimeConf.script_font size)) -(* MATITA1.0 +(* MATITA 1.0 inherit GMathViewAux.multi_selection_math_view obj val mutable href_callback: (string -> unit) option = None @@ -591,7 +643,7 @@ object (self) let sequent = List.assoc metano metasenv in let txt = ApplyTransformation.ntxt_of_cic_sequent - ~map_unicode_to_tex:false 80 status metasenv subst (metano,sequent) + ~map_unicode_to_tex:false 80 status ~metasenv ~subst (metano,sequent) in (* MATITA 1.0 if BuildTimeConf.debug then begin let name = @@ -616,7 +668,7 @@ object (self) self#thaw | _ -> *) - (* MATITA1.0 if BuildTimeConf.debug then begin + (* MATITA 1.0 if BuildTimeConf.debug then begin let name = "/tmp/cic_browser_" ^ string_of_int (Unix.getuid ()) ^ ".xml" in HLog.debug ("cic_browser: dumping MathML to ./" ^ name); @@ -636,7 +688,7 @@ let cicMathView (*?auto_indent ?highlight_current_line ?indent_on_tab ?indent_wi Gobject.set_params (Gobject.try_cast obj "GtkSourceView") pl; new _cicMathView obj)(*)) ?auto_indent ?highlight_current_line ?indent_on_tab ?indent_width ?insert_spaces_instead_of_tabs ?right_margin_position ?show_line_marks ?show_line_numbers ?show_right_margin ?smart_home_end ?tab_width ?editable ?cursor_visible ?justification ?wrap_mode ?accepts_tab ?border_width*) [] ?width ?height ?packing ?show () :> cicMathView) -let screenshot status sequents metasenv subst (filename as ofn) = +let screenshot _status _sequents _metasenv _subst (_filename (*as ofn*)) = () (*MATITA 1.0 let w = GWindow.window ~title:"screenshot" () in let width = 500 in