X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2FcicMathView.ml;h=e06e0055d6da93d8ea9531fceca880048f5d3609;hb=9080be011a214d5ee98639c2c7c6356a7be3d2d1;hp=d619482de46779081001caffab56a328dcd8c8ff;hpb=bfd488729e5f21cedaba0cccfa10fdb63da8a68f;p=helm.git diff --git a/matita/matita/cicMathView.ml b/matita/matita/cicMathView.ml index d619482de..e06e0055d 100644 --- a/matita/matita/cicMathView.ml +++ b/matita/matita/cicMathView.ml @@ -192,9 +192,7 @@ object (self) (Cic.id, Cic.id option) Hashtbl.t * ('a, 'b) Hashtbl.t * 'c option)*) option -> unit) (* dal widget di Luca *) method load_root ~root:(hyperlinks,text) = - self#buffer#delete ~start:(self#buffer#get_iter `START) - ~stop:(self#buffer#get_iter `END); - self#buffer#insert 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); @@ -209,31 +207,41 @@ object (self) 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)) -> - let hyperlink_tag = self#buffer#create_tag [] in self#buffer#apply_tag hyperlink_tag ~start:(self#buffer#get_iter_at_char start) ~stop:(self#buffer#get_iter_at_char (stop+1)); - ignore(hyperlink_tag#connect#event - ~callback:(fun ~origin event pos -> - 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)); ) hyperlinks + method action_toggle = (fun _ -> assert false : document_element -> bool) method remove_selections = (() : unit) method set_selection = (fun _ -> () : document_element option -> unit)