X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2FmatitaMathView.ml;h=5de25e45b13b784bca64eb50c5fafbe7d7341f99;hb=6e4e1c55cb1d3d5f8ef6d607263647bf4e789458;hp=aa1b16a2871da2dd07959af03b24da61fe19716e;hpb=890221127070350c2e33aa4685398b03258aa847;p=helm.git diff --git a/matita/matitaMathView.ml b/matita/matitaMathView.ml index aa1b16a28..5de25e45b 100644 --- a/matita/matitaMathView.ml +++ b/matita/matitaMathView.ml @@ -246,21 +246,24 @@ object (self) | _ -> leave_href ()) | None -> leave_href () + + method private tactic_text_pattern_of_node node = + let id = id_of_node node in + let cic_info, unsh_sequent = self#get_cic_info id in + match self#get_term_by_id cic_info id with + | SelTerm (t, father_hyp) -> + let sequent = self#sequent_of_id ~paste_kind:`Pattern id in + let text = self#string_of_cic_sequent sequent in + (match father_hyp with + | None -> None, [], Some text + | Some hyp_name -> None, [ hyp_name, text ], None) + | SelHyp (hyp_name, _ctxt) -> None, [ hyp_name, "%" ], None + (** @return a pattern structure which contains pretty printed terms *) method private tactic_text_pattern_of_selection = match self#get_selections with | [] -> assert false (* this method is invoked only if there's a sel. *) - | node :: _ -> - let id = id_of_node node in - let cic_info, unsh_sequent = self#get_cic_info id in - match self#get_term_by_id cic_info id with - | SelTerm (t, father_hyp) -> - let sequent = self#sequent_of_id ~paste_kind:`Pattern id in - let text = self#string_of_cic_sequent sequent in - (match father_hyp with - | None -> None, [], Some text - | Some hyp_name -> None, [ hyp_name, text ], None) - | SelHyp (hyp_name, _ctxt) -> None, [ hyp_name, "%" ], None + | node :: _ -> self#tactic_text_pattern_of_node node method private popup_contextual_menu time = let menu = GMenu.menu () in @@ -417,8 +420,10 @@ object (self) method private string_of_node ~(paste_kind:paste_kind) node = if node#hasAttributeNS ~namespaceURI:helm_ns ~localName:xref_ds then - let id = id_of_node node in - self#string_of_cic_sequent (self#sequent_of_id ~paste_kind id) + let tactic_text_pattern = self#tactic_text_pattern_of_node node in + GrafiteAstPp.pp_tactic_pattern + ~term_pp:(fun s -> s) ~lazy_term_pp:(fun _ -> assert false) + tactic_text_pattern else string_of_dom_node node method private string_of_cic_sequent cic_sequent = @@ -769,8 +774,9 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) "^cic:/([^/]+/)*[^/]+\\.(con|ind|var)(#xpointer\\(\\d+(/\\d+)+\\))?$" in let dir_RE = Pcre.regexp "^cic:((/([^/]+/)*[^/]+(/)?)|/|)$" in - let whelp_query_RE = Pcre.regexp "^\\s*whelp\\s+([^\\s]+)\\s+(.*)$" in - let do_not_execute_whelp_query = ref false in + let whelp_query_RE = Pcre.regexp + "^\\s*whelp\\s+([^\\s]+)\\s+(\"|\\()(.*)(\\)|\")$" + in let is_whelp txt = Pcre.pmatch ~rex:whelp_RE txt in let is_uri txt = Pcre.pmatch ~rex:uri_RE txt in let is_dir txt = Pcre.pmatch ~rex:dir_RE txt in @@ -786,14 +792,13 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) | _::tl -> aux (i+1) tl in win#queryInputText#set_text input; - do_not_execute_whelp_query:=true; combo#set_active (aux 0 queries); in let set_whelp_query txt = let query, arg = try let q = Pcre.extract ~rex:whelp_query_RE txt in - q.(1), q.(2) + q.(1), q.(3) with Not_found -> failwith "Malformed Whelp query" in activate_combo_query arg query; @@ -808,11 +813,12 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) [ "dir", GdkPixbuf.from_file (MatitaMisc.image_path "matita-folder.png"); "obj", GdkPixbuf.from_file (MatitaMisc.image_path "matita-object.png") ] in + let b = (not (Helm_registry.get_bool "matita.debug")) in let handle_error f = try f () with exn -> - if not (Helm_registry.get_bool "matita.debug") then + if b then fail (snd (MatitaExcPp.to_string exn)) else raise exn in @@ -829,19 +835,18 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) activate_combo_query "" "locate"; win#whelpBarComboVbox#add combo#coerce; let start_query () = - if !do_not_execute_whelp_query then - do_not_execute_whelp_query := false - else - begin - let query = - try - String.lowercase (List.nth queries combo#active) - with Not_found -> assert false - in - let input = win#queryInputText#text in - let statement = "whelp " ^ query ^ " (" ^ input ^ ")." in - (MatitaScript.current ())#advance ~statement () - end + let query = + try + String.lowercase (List.nth queries combo#active) + with Not_found -> assert false in + let input = win#queryInputText#text in + let statement = + if query = "locate" then + "whelp " ^ query ^ " \"" ^ input ^ "\"." + else + "whelp " ^ query ^ " (" ^ input ^ ")." + in + (MatitaScript.current ())#advance ~statement () in ignore(win#queryInputText#connect#activate ~callback:start_query); ignore(combo#connect#changed ~callback:start_query);