X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FgTopLevel%2FtexTermEditor.ml;h=18c2215b5f1be654f7ddf0cc36b734be2a3375ac;hb=2afbca45037c56264d1889ced69b5f4844b9ecb9;hp=b8375b3eab0a9a861d8841c35a8cef17f4c714ed;hpb=1bfef566743ddd81db375cf66ed3868c5d7df542;p=helm.git diff --git a/helm/gTopLevel/texTermEditor.ml b/helm/gTopLevel/texTermEditor.ml index b8375b3ea..18c2215b5 100644 --- a/helm/gTopLevel/texTermEditor.ml +++ b/helm/gTopLevel/texTermEditor.ml @@ -38,11 +38,13 @@ class type term_editor = object method coerce : GObj.widget + (* get_as_string returns the unquoted string *) method get_as_string : string method get_metasenv_and_term : context:Cic.context -> metasenv:Cic.metasenv -> Cic.metasenv * Cic.term method reset : unit + (* The input of set_term is unquoted *) method set_term : string -> unit method id_to_uris : Disambiguate.domain_and_interpretation ref end @@ -165,18 +167,22 @@ module Make(C:Disambiguate.Callbacks) = ignore (Mathml_editor.thaw tex_editor) ; mmlwidget#thaw + (* The input of set_term is unquoted *) method set_term txt = mmlwidget#freeze ; ignore (Mathml_editor.freeze tex_editor) ; self#reset ; - (* we need to remove the initial and final '$' *) - let txt' = String.sub txt 1 (String.length txt - 2) in + let txt' = Str.global_replace (Str.regexp "_") "\\_" txt in String.iter (fun ch -> Mathml_editor.push tex_editor ch) txt' ; ignore (Mathml_editor.thaw tex_editor) ; mmlwidget#thaw + (* get_as_string returns the unquoted string *) method get_as_string = - Mathml_editor.get_tex tex_editor + let term = Mathml_editor.get_tex tex_editor in + Str.global_replace (Str.regexp "^\\$\\$?") "" + (Str.global_replace (Str.regexp "\\$\\$?$") "" + (Str.global_replace (Str.regexp "\\\\_") "_" term)) method get_metasenv_and_term ~context ~metasenv = let name_context = @@ -186,7 +192,7 @@ module Make(C:Disambiguate.Callbacks) = | None -> None ) context in - let lexbuf = Lexing.from_string self#get_as_string in + let lexbuf = Lexing.from_string (Mathml_editor.get_tex tex_editor) in let dom,mk_metasenv_and_expr = TexCicTextualParserContext.main ~context:name_context ~metasenv TexCicTextualLexer.token lexbuf