]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/test/editor.cc
Added the completion of the macro's name.
[helm.git] / helm / DEVEL / mathml_editor / test / editor.cc
index cdf6d51a5877a1c103e5ae3dc437c1ae14fad6bc..00aa28eb98c04654e6c3c3738c4015331b4f5506 100644 (file)
 
 #include "dom.hh"
 #include "TPushParser.hh"
-#include "TPushLexer.hh"
+
 #include "LPushLexer.hh"
+
+#include "TPushLexer.hh"
+#include "ILPushLexer.hh"
 #include "TDictionary.hh"
 #include "CLoggerConsole.hh"
 #include "CMathMLFactoryXSLT.hh"
 
 #include "guiGTK.h"
 
+typedef ILPushLexer MyPushLexer;
+
 extern void *parseMathMLFile(char *);
 
 struct Context
 {
-  Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) 
+  /*
+  Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { };
+  */
+  Context(const std::string& s, MyPushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) 
     : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { };
 
   void send(void)
@@ -49,7 +57,8 @@ struct Context
 
   std::string buffer;
   unsigned i;
-  APushLexer& lexer;
+  //TPushLexer& lexer;
+  MyPushLexer& lexer;
   TPushParser& parser;
   DOMX::XSLTStylesheet& texStyle;
 };
@@ -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,6 +141,15 @@ edit_reset_tex(Context* context)
   GUI_thaw();
 }
 
+extern "C" void
+edit_complete(Context* context)
+{
+  assert(context != NULL);
+  GUI_freeze();
+  if (!context->lexer.complete()) context->lexer.push('\t');
+  GUI_thaw();
+}
+
 void
 main(int argc, char* argv[])
 {
@@ -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("./dictionary-test.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);
+  MyPushLexer lexer(logger, parser, dictionary);
 
 #if 0
   lexer.push('$');