X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Flablgtkmathview%2Ftest%2Ftest.ml;h=936f962b596016dbbb8941c459e5b11a2c0395f4;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=ca9abd84bbab42645173c0b57e0a0347c5874fdf;hpb=1957a1f151c547f04625c4379e51ab66bddb69c7;p=helm.git diff --git a/helm/DEVEL/lablgtkmathview/test/test.ml b/helm/DEVEL/lablgtkmathview/test/test.ml index ca9abd84b..936f962b5 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.ml @@ -29,15 +29,62 @@ (* MathView widget *) (******************************************************************************) +let helmns = Gdome.domString "http://www.cs.unibo.it/helm";; + +(* +let choose_selection mmlwidget (element : Gdome.element option) = + let module G = Gdome in + let rec aux element = + if element#hasAttributeNS + ~namespaceURI:Misc.helmns + ~localName:(G.domString "xref") + then + mmlwidget#set_selection (Some element) + else + try + match element#get_parentNode with + None -> assert false + (*CSC: OCAML DIVERGES! + | Some p -> aux (new G.element_of_node p) + *) + | Some p -> aux (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + prerr_endline + "******* trying to select above the document root ********" + in + match element with + Some x -> aux x + | None -> mmlwidget#set_selection None +;; +*) + (* Callbacks *) let selection_changed mathview (element : Gdome.element option) = + let rec aux element = + if element#hasAttributeNS + ~namespaceURI:helmns + ~localName:(Gdome.domString "xref") + then + mathview#set_selection (Some element) + else + try + match element#get_parentNode with + None -> mathview#set_selection None + | Some p -> aux (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + prerr_endline "******* trying to select above the document root ********" + in print_endline ("selection_changed: " ^ (match element with None -> "selection_changed on nothing" | Some element -> element#get_tagName#to_string ) ) ; - mathview#set_selection element; + match element with + None -> () + | Some el -> aux el; flush stdout ;;