X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Ftest%2Feditor.cc;h=38c8bbbd0d5ebaee248d133d3c1df6ec5c9aef96;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=cdf6d51a5877a1c103e5ae3dc437c1ae14fad6bc;hpb=c112706f347e08e7f345131fbc4c3aa0e9ecc7b5;p=helm.git diff --git a/helm/DEVEL/mathml_editor/test/editor.cc b/helm/DEVEL/mathml_editor/test/editor.cc index cdf6d51a5..38c8bbbd0 100644 --- a/helm/DEVEL/mathml_editor/test/editor.cc +++ b/helm/DEVEL/mathml_editor/test/editor.cc @@ -23,10 +23,12 @@ * or send an email to */ +#include + #include "dom.hh" #include "TPushParser.hh" -#include "TPushLexer.hh" -#include "LPushLexer.hh" + +#include "ILPushLexer.hh" #include "TDictionary.hh" #include "CLoggerConsole.hh" #include "CMathMLFactoryXSLT.hh" @@ -39,6 +41,9 @@ extern void *parseMathMLFile(char *); struct Context { + /* + Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { }; + */ Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { }; @@ -62,7 +67,7 @@ edit_output_tex(Context* data) #if 0 res.normalize(); DOM::Node c = res.get_firstChild(); - if (c) cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << endl; + if (c) std::cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << std::endl; #endif data->texStyle.save(res, stdout); } @@ -82,7 +87,7 @@ edit_push_char(Context* context, gchar ch) { assert(context != NULL); GUI_freeze(); - cout << "*** SENDING " << ch << endl; + std::cout << "*** SENDING " << ch << std::endl; context->lexer.push(ch); GUI_thaw(); } @@ -112,8 +117,10 @@ edit_push_string(Context* context, const gchar* s) } extern "C" void -edit_drop(Context* context, gboolean alt) +edit_drop(Context* context, gboolean alt, gboolean control) { + // At the moment, the last parameter is not used, but it will + // be useful when we will handle the "fast" deletion assert(context != NULL); GUI_freeze(); context->lexer.drop(alt); @@ -130,7 +137,16 @@ edit_reset_tex(Context* context) GUI_thaw(); } -void +extern "C" void +edit_complete(Context* context) +{ + assert(context != NULL); + GUI_freeze(); + if (!context->lexer.complete()) context->lexer.push('\t'); + GUI_thaw(); +} + +int main(int argc, char* argv[]) { CLoggerConsole logger; @@ -138,19 +154,19 @@ main(int argc, char* argv[]) TDictionary dictionary(logger); logger.info("loading the dictionary..."); - dictionary.load("/home/luca/projects/helm/DEVEL/mathml_editor/dictionary-test.xml"); + dictionary.load("/usr/share/editex/dictionary-tex.xml"); logger.info("loading the stylesheet..."); DOM::DOMImplementation di; DOM::Document mmlStyleDoc = di.createDocumentFromURI("./xsl/tml-mmlp.xsl"); DOMX::XSLTStylesheet mmlStyle(mmlStyleDoc); - DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-tex.xsl"); + DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-texid.xsl"); DOMX::XSLTStylesheet texStyle(texStyleDoc); - CMathMLFactoryXSLT factory(logger, mmlStyle); + CMathMLFactoryXSLTDiff factory(logger, mmlStyle); TPushParser parser(logger, factory, dictionary); - LPushLexer lexer(logger, parser); + ILPushLexer lexer(logger, parser, dictionary); #if 0 lexer.push('$'); @@ -172,4 +188,5 @@ main(int argc, char* argv[]) GUI_run(); GUI_uninit(); GUI_unload_document(); + }