From: Enrico Tassi Date: Mon, 8 Dec 2008 17:07:45 +0000 (+0000) Subject: non active but almost working implementation of \TeX macro substitution while colouring X-Git-Tag: make_still_working~4433 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=54ddd51bfebe9afc46db2eaa1a20ae971a467fd7;p=helm.git non active but almost working implementation of \TeX macro substitution while colouring --- diff --git a/helm/software/matita/.depend b/helm/software/matita/.depend index 8c4e69265..12790dd0e 100644 --- a/helm/software/matita/.depend +++ b/helm/software/matita/.depend @@ -52,10 +52,10 @@ matita.cmo: predefined_virtuals.cmi matitaTypes.cmi matitaScript.cmi \ matita.cmx: predefined_virtuals.cmx matitaTypes.cmx matitaScript.cmx \ matitaMathView.cmx matitaInit.cmx matitaGui.cmx matitaGtkMisc.cmx \ matitaAutoGui.cmx buildTimeConf.cmx applyTransformation.cmx -matitaScript.cmo: matitacLib.cmi matitaTypes.cmi matitaMisc.cmi \ +matitaScript.cmo: virtuals.cmi matitacLib.cmi matitaTypes.cmi matitaMisc.cmi \ matitaGtkMisc.cmi matitaEngine.cmi buildTimeConf.cmo \ applyTransformation.cmi matitaScript.cmi -matitaScript.cmx: matitacLib.cmx matitaTypes.cmx matitaMisc.cmx \ +matitaScript.cmx: virtuals.cmx matitacLib.cmx matitaTypes.cmx matitaMisc.cmx \ matitaGtkMisc.cmx matitaEngine.cmx buildTimeConf.cmx \ applyTransformation.cmx matitaScript.cmi matitaTypes.cmo: matitaTypes.cmi diff --git a/helm/software/matita/.depend.opt b/helm/software/matita/.depend.opt index b91cc9fb2..64b214769 100644 --- a/helm/software/matita/.depend.opt +++ b/helm/software/matita/.depend.opt @@ -52,10 +52,10 @@ matita.cmo: predefined_virtuals.cmi matitaTypes.cmi matitaScript.cmi \ matita.cmx: predefined_virtuals.cmx matitaTypes.cmx matitaScript.cmx \ matitaMathView.cmx matitaInit.cmx matitaGui.cmx matitaGtkMisc.cmx \ matitaAutoGui.cmx buildTimeConf.cmx applyTransformation.cmx -matitaScript.cmo: matitacLib.cmi matitaTypes.cmi matitaMisc.cmi \ +matitaScript.cmo: virtuals.cmi matitacLib.cmi matitaTypes.cmi matitaMisc.cmi \ matitaGtkMisc.cmi matitaEngine.cmi buildTimeConf.cmx \ applyTransformation.cmi matitaScript.cmi -matitaScript.cmx: matitacLib.cmx matitaTypes.cmx matitaMisc.cmx \ +matitaScript.cmx: virtuals.cmx matitacLib.cmx matitaTypes.cmx matitaMisc.cmx \ matitaGtkMisc.cmx matitaEngine.cmx buildTimeConf.cmx \ applyTransformation.cmx matitaScript.cmi matitaTypes.cmo: matitaTypes.cmi diff --git a/helm/software/matita/Makefile b/helm/software/matita/Makefile index d09395eab..6bdba1baf 100644 --- a/helm/software/matita/Makefile +++ b/helm/software/matita/Makefile @@ -38,8 +38,8 @@ MLI = \ matitaInit.mli \ matitaGtkMisc.mli \ matitaAutoGui.mli \ - matitaScript.mli \ virtuals.mli \ + matitaScript.mli \ predefined_virtuals.mli \ matitaMathView.mli \ matitaGui.mli \ diff --git a/helm/software/matita/matitaScript.ml b/helm/software/matita/matitaScript.ml index a5e24d315..7bcbea294 100644 --- a/helm/software/matita/matitaScript.ml +++ b/helm/software/matita/matitaScript.ml @@ -848,8 +848,38 @@ object (self) | exc -> self#notify; raise exc method private getFuture = - buffer#get_text ~start:(buffer#get_iter_at_mark (`MARK locked_mark)) - ~stop:buffer#end_iter () + let lock = buffer#get_iter_at_mark (`MARK locked_mark) in + let text = buffer#get_text ~start:lock ~stop:buffer#end_iter () in + text +(* THIS SNIPPET AUTOMATICALLY EXPANDS EVERY \TeX MACRO + if Pcre.pmatch ~pat:"\\\\[a-zA-Z]+" text then + begin + buffer#delete ~start:lock ~stop:buffer#end_iter; + let text = + Pcre.substitute_substrings + ~subst:(fun str -> + let pristine = Pcre.get_substring str 0 in + let input = + if pristine.[0] = ' ' then + String.sub pristine 1 (String.length pristine -1) + else pristine + in + let input = + if input.[String.length input-1] = ' ' then + String.sub input 0 (String.length input -1) + else input + in + try + Glib.Utf8.from_unichar (snd (Virtuals.symbol_of_virtual input)) + with Virtuals.Not_a_virtual -> pristine) + ~pat:" ?\\\\[a-zA-Z]+ ?" text + in + buffer#insert ~iter:lock text; + text + end + else + text +*) (** @param rel_offset relative offset from current position of locked_mark *)