- (if near (button_press_x, button_press_y)
- (button_release_x, button_release_y)
- then
- let x = int_of_float button_press_x in
- let y = int_of_float button_press_y in
- (match self#get_element_at x y with
- | None -> ()
- | Some elt ->
- let namespaceURI = DomMisc.xlink_ns in
- let localName = href in
- if elt#hasAttributeNS ~namespaceURI ~localName then
- self#invoke_href_callback
- (elt#getAttributeNS ~namespaceURI ~localName)#to_string
- gdk_button
- else
- ignore (self#action_toggle elt)));
- false
-
- method private invoke_href_callback href_value gdk_button =
- let button = GdkEvent.Button.button gdk_button in
- if button = left_button then
- let time = GdkEvent.Button.time gdk_button in
- match href_callback with
- | None -> ()
- | Some f ->
- (match MatitaMisc.split href_value with
- | [ uri ] -> f uri
- | uris ->
- let menu = GMenu.menu () in
- List.iter
- (fun uri ->
- let menu_item =
- GMenu.menu_item ~label:uri ~packing:menu#append ()
- in
- ignore (menu_item#connect#activate (fun () -> f uri)))
- uris;
- menu#popup ~button ~time)
-
- method private choose_selection gdome_elt =
- let rec aux elt =
- if elt#hasAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref then
- self#set_selection (Some elt)
- else
- try
- (match elt#get_parentNode with
- | None -> assert false
- | Some p -> aux (new Gdome.element_of_node p))
- with GdomeInit.DOMCastException _ -> ()
-(* debug_print "trying to select above the document root" *)
+ if selection_changed then
+ ()
+ else (* selection _not_ changed *)
+ if near (button_press_x, button_press_y)
+ (button_release_x, button_release_y)
+ then
+ let x = int_of_float button_press_x in
+ let y = int_of_float button_press_y in
+ (match self#get_element_at x y with
+ | None -> ()
+ | Some elt ->
+ let namespaceURI = DomMisc.xlink_ns in
+ let localName = href_ds in
+ if elt#hasAttributeNS ~namespaceURI ~localName then
+ self#invoke_href_callback
+ (elt#getAttributeNS ~namespaceURI ~localName)#to_string
+ gdk_button
+ else
+ ignore (self#action_toggle elt));
+ end;
+ false
+
+ method private invoke_href_callback href_value gdk_button =
+ let button = GdkEvent.Button.button gdk_button in
+ if button = left_button then
+ let time = GdkEvent.Button.time gdk_button in
+ match href_callback with
+ | None -> ()
+ | Some f ->
+ (match MatitaMisc.split href_value with
+ | [ uri ] -> f uri
+ | uris ->
+ let menu = GMenu.menu () in
+ List.iter
+ (fun uri ->
+ let menu_item =
+ GMenu.menu_item ~label:uri ~packing:menu#append ()
+ in
+ connect_menu_item menu_item (fun () -> f uri))
+ uris;
+ menu#popup ~button ~time)
+
+ method private choose_selection_cb gdome_elt =
+ let (gui: MatitaGuiTypes.gui) = get_gui () in
+ let clipboard = GData.clipboard Gdk.Atom.primary in
+ let rec aux elt =
+ if (elt#getAttributeNS ~namespaceURI:DomMisc.helm_ns
+ ~localName:xref_ds)#to_string <> ""
+(* if elt#hasAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref_ds
+ && (elt#getAttributeNS ~namespaceURI:DomMisc.helm_ns
+ ~localName:xref_ds)#to_string <> "" *)
+ then begin
+ self#set_selection (Some elt);
+ ignore (self#coerce#misc#grab_selection Gdk.Atom.primary)
+ end else
+ try
+ (match elt#get_parentNode with
+ | None -> assert false
+ | Some p -> aux (new Gdome.element_of_node p))
+ with GdomeInit.DOMCastException _ -> ()
+ in
+ (match gdome_elt with
+ | Some elt -> aux elt
+ | None -> self#set_selection None);
+ selection_changed <- true
+
+ method update_font_size = self#set_font_size !current_font_size
+
+ method private get_term_by_id context id =
+ let ids_to_terms, ids_to_hypotheses = self#cic_info in
+ try
+ `Term (Hashtbl.find ids_to_terms id)
+ with Not_found ->
+ try
+ let hyp = Hashtbl.find ids_to_hypotheses id in
+ let context' = MatitaMisc.list_tl_at hyp context in
+ `Hyp context'
+ with Not_found -> assert false
+
+ method private string_of_node node =
+ let get_id (node: Gdome.element) =
+ let xref_attr =
+ node#getAttributeNS ~namespaceURI:DomMisc.helm_ns ~localName:xref_ds
+ in
+ xref_attr#to_string
+ in
+ let script = MatitaScript.instance () in
+ let metasenv = script#proofMetasenv in
+ let context = script#proofContext in
+ let conclusion = script#proofConclusion in
+(* TODO: code for patterns
+ let conclusion = (MatitaScript.instance ())#proofConclusion in
+ let conclusion_pattern =
+ ProofEngineHelpers.pattern_of ~term:conclusion cic_terms
+ in
+*)
+ let dummy_goal = ~-1 in
+ let string_of_cic_sequent cic_sequent =
+ let acic_sequent, _, _, ids_to_inner_sorts, _ =
+ Cic2acic.asequent_of_sequent metasenv cic_sequent