- 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" *)
+ set_selection elt
+ 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 when (elt#getAttributeNS ~namespaceURI:DomMisc.xlink_ns
+ ~localName:href_ds)#to_string <> "" ->
+ set_selection elt
+ | 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 cic_info id =
+ let ids_to_terms, ids_to_hypotheses, _, _, _ = 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 find_obj_conclusion id =
+ match self#cic_info with
+ | None
+ | Some (_, _, _, _, None) -> assert false
+ | Some (ids_to_terms, _, ids_to_father_ids, ids_to_inner_types, Some annobj) ->
+ let id =
+ find_root_id annobj id ids_to_father_ids ids_to_terms ids_to_inner_types
+ in
+ (try Hashtbl.find ids_to_terms id with Not_found -> assert false)
+
+ method private string_of_node node =
+ if node#hasAttributeNS ~namespaceURI:DomMisc.xlink_ns ~localName:href_ds
+ then string_of_dom_node node
+ else self#string_of_id_node node
+
+ method private string_of_id_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 id = get_id node in
+ let script = MatitaScript.instance () in
+ let metasenv = script#proofMetasenv in
+ let context = script#proofContext in
+ let metasenv, context, conclusion =
+ if script#onGoingProof () then
+ script#proofMetasenv, script#proofContext, script#proofConclusion
+ else
+ [], [],
+ let t = self#find_obj_conclusion id in
+ MatitaLog.debug (CicPp.ppterm t);
+ t
+ in
+(* TODO: code for patterns
+ let conclusion = (MatitaScript.instance ())#proofConclusion in
+ let conclusion_pattern =
+ ProofEngineHelpers.pattern_of ~term:conclusion cic_terms
+ in
+*)
+ let string_of_cic_sequent cic_sequent =
+ let acic_sequent, _, _, ids_to_inner_sorts, _ =
+ Cic2acic.asequent_of_sequent metasenv cic_sequent
+ in
+ let _, _, _, annterm = acic_sequent in
+ let ast, ids_to_uris =
+ CicNotationRew.ast_of_acic ids_to_inner_sorts annterm