X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Ftest%2Feditor.cc;h=3efc17cee2168b72acb5429a1f73c3c9bdb12c78;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;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..3efc17cee 100644 --- a/helm/DEVEL/mathml_editor/test/editor.cc +++ b/helm/DEVEL/mathml_editor/test/editor.cc @@ -23,10 +23,13 @@ * or send an email to */ +#include + #include "dom.hh" #include "TPushParser.hh" -#include "TPushLexer.hh" -#include "LPushLexer.hh" +#include "timer.hh" + +#include "ILPushLexer.hh" #include "TDictionary.hh" #include "CLoggerConsole.hh" #include "CMathMLFactoryXSLT.hh" @@ -39,6 +42,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,9 +68,9 @@ 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); + //data->texStyle.save(res, stdout); } extern "C" int @@ -81,10 +87,13 @@ extern "C" void edit_push_char(Context* context, gchar ch) { assert(context != NULL); + long t0 = getTimer(); GUI_freeze(); - cout << "*** SENDING " << ch << endl; + std::cout << "*** SENDING " << ch << std::endl; context->lexer.push(ch); GUI_thaw(); + long t1 = getTimer(); + std::cout << "=== OVERALL TIME = " << (t1 - t0) / 1000 << std::endl; } #include @@ -112,8 +121,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 +141,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 +158,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("./dict/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); TPushParser parser(logger, factory, dictionary); - LPushLexer lexer(logger, parser); + ILPushLexer lexer(logger, parser, dictionary); #if 0 lexer.push('$'); @@ -172,4 +192,5 @@ main(int argc, char* argv[]) GUI_run(); GUI_uninit(); GUI_unload_document(); + }