]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/src/TPushParser.cc
* added show/hide cursro methods
[helm.git] / helm / DEVEL / mathml_editor / src / TPushParser.cc
index 836be35a894eeacd5c11727e5aad6d01d794a6ae..a3fb9772996a11becbd03e578b62b6badac40ca2 100644 (file)
@@ -5,27 +5,36 @@
 
 TPushParser::TPushParser(ALogger& l, const TDictionary& d) : APushParser(l), dictionary(d)
 {
-  reset();
+  init();
 }
 
 TPushParser::TPushParser(ALogger& l, AMathMLFactory& f, const TDictionary& d) : APushParser(l, f), dictionary(d)
 {
-  reset();
+  init();
 }
 
 TPushParser::~TPushParser()
 {
 }
 
+void
+TPushParser::init()
+{
+  cursor = doc.create("cursor");
+  cursor["visible"] = "1";
+  hiddenCursor = 0;
+  reset();
+}
+
 void
 TPushParser::reset()
 {
-  APushParser::reset();
+  cout << "passo di qui dentro pushparser " << factory << endl;
   nextId = 1;
-  cursor = doc.create("cursor");
-  cursor["id"] = "I0";
-  doc.clearDirty();
+  if (cursor.parent()) cursor.remove();
+  doc.reset();
   doc.root().append(cursor);
+  if (factory) factory->documentModified(doc);
 }
 
 std::string
@@ -1688,6 +1697,32 @@ TPushParser::setCursorHint(const std::string& c)
     }
 }
 
+bool
+TPushParser::hideCursor()
+{
+  if (hiddenCursor++ == 0)
+    {
+      cursor["visible"] = "0";
+      if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc);
+      return true;
+    }
+  else
+    return false;
+}
+
+bool
+TPushParser::showCursor()
+{
+  if (hiddenCursor > 0 && --hiddenCursor == 0)
+    {
+      cursor["visible"] = "1";
+      if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc);
+      return true;
+    }
+  else
+    return false;
+}
+
 bool
 TPushParser::thaw()
 {