]> git.lyx.org Git - features.git/commitdiff
move around debugging stuff
authorAndré Pönitz <poenitz@gmx.net>
Fri, 15 Feb 2002 14:07:09 +0000 (14:07 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 15 Feb 2002 14:07:09 +0000 (14:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3544 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_extern.C
src/mathed/math_parser.C

index a1077977c392b476b6ddd421ce1feb0fa9f9c98a..f1c6113b5733e7c07c5cc44a24e6b08532489aa6 100644 (file)
@@ -571,10 +571,14 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                break;
 
        case LFUN_MATH_MODE:
-               //handleFont(bv, arg, LM_TC_TEXTRM);
+#if 0
+               handleFont(bv, arg, LM_TC_TEXTRM);
+#endif
 
-               //mathcursor->niceInsert(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
-               //updateLocal(bv, true);
+#if 0
+               mathcursor->niceInsert(MathAtom(new MathHullInset(LM_OT_SIMPLE)));
+               updateLocal(bv, true);
+#endif
 
                //bv->owner()->message(_("math text mode toggled"));
                break;
@@ -729,10 +733,45 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
        else
                bv->unlockInset(this);
 
+       revealCodes(bv);
+
        return result;  // original version
 }
 
 
+void InsetFormulaBase::revealCodes(BufferView * bv) const
+{
+       if (!mathcursor)
+               return;
+#if 0
+       // write something to the minibuffer
+       // translate to latex
+       mathcursor->markInsert();
+       ostringstream os;
+       write(NULL, os);
+       string str = os.str();
+       mathcursor->markErase();
+       string::size_type pos = 0;
+       string res;
+       for (string::iterator it = str.begin(); it != str.end(); ++it) {
+               if (*it == '\n')
+                       res += ' ';
+               else if (*it == '\0') {
+                       res += "  -X-  ";
+                       pos = it - str.begin();
+               }
+               else
+                       res += *it;
+       }
+       if (pos > 30)
+               res = res.substr(pos - 30);
+       if (res.size() > 60)
+               res = res.substr(0, 60);
+       bv->owner()->message(res);
+#endif
+}
+
+
 Inset::Code InsetFormulaBase::lyxCode() const
 {
        return Inset::MATH_CODE;
index 7e5b8f1813d43860a87b1ef24149019e1ccbd3f2..25048df783059caa7eb7abaa2ba81b7f46c3e86a 100644 (file)
@@ -112,6 +112,8 @@ public:
        virtual bool isTextInset() const { return true; }
        ///
        virtual void mutateToText();
+       ///
+       virtual void revealCodes(BufferView *) const;
 
 
 private:
index 7de50259313ef67fcc97d9e8117cbae4fff8894d..c52c467529eaed79b3b78ee9589b3df60d8ad549 100644 (file)
@@ -428,6 +428,20 @@ void MathCursor::plainErase()
 }
 
 
+void MathCursor::markInsert()
+{
+       //lyxerr << "inserting mark\n";
+       array().insert(pos(), MathAtom(new MathCharInset(0, lastcode_)));
+}
+
+
+void MathCursor::markErase()
+{
+       //lyxerr << "deleting mark\n";
+       array().erase(pos());
+}
+
+
 void MathCursor::plainInsert(MathAtom const & t)
 {
        array().insert(pos(), t);
index c518bc44194add29326c2e9ce2428e3667b7dc7a..3561d2089eccb53984ac5cdfd2aaaa1424c98869 100644 (file)
@@ -244,6 +244,10 @@ public:
        ///
        void insert(char);
 
+       /// hack for reveal codes
+       void markInsert();
+       void markErase();
+       
        ///
        friend class Selection;
 
index 6751dd405ad13aeaaf37ed8732dc9f88e34d0fce..c317f3fe57ab7b354b73d1a2ced07974b828cf99 100644 (file)
@@ -157,7 +157,7 @@ MathInset * singleItem(MathArray & ar)
 
 void extractMatrices(MathArray & ar)
 {
-       lyxerr << "\nMatrices from: " << ar << "\n";
+       //lyxerr << "\nMatrices from: " << ar << "\n";
        for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) {
                MathDelimInset * del = (*it)->asDelimInset();
                if (!del)
@@ -167,7 +167,7 @@ void extractMatrices(MathArray & ar)
                        continue;
                *it = MathAtom(new MathMatrixInset(*(arr->asArrayInset())));
        }
-       lyxerr << "\nMatrices to: " << ar << "\n";
+       //lyxerr << "\nMatrices to: " << ar << "\n";
 }
 
 
@@ -266,7 +266,7 @@ void replaceNested(
 
 void splitScripts(MathArray & ar)
 {
-       lyxerr << "\nScripts from: " << ar << "\n";
+       //lyxerr << "\nScripts from: " << ar << "\n";
        for (MathArray::size_type i = 0; i < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
@@ -289,7 +289,7 @@ void splitScripts(MathArray & ar)
                ++i;
                ar.insert(i, MathAtom(q)); 
        }
-       lyxerr << "\nScripts to: " << ar << "\n";
+       //lyxerr << "\nScripts to: " << ar << "\n";
 }
 
 
@@ -299,7 +299,7 @@ void splitScripts(MathArray & ar)
 
 void extractExps(MathArray & ar)
 {
-       lyxerr << "\nExps from: " << ar << "\n";
+       //lyxerr << "\nExps from: " << ar << "\n";
 
        for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
@@ -322,7 +322,7 @@ void extractExps(MathArray & ar)
                (*it).reset(func);
                ar.erase(it + 1);
        }
-       lyxerr << "\nExps to: " << ar << "\n";
+       //lyxerr << "\nExps to: " << ar << "\n";
 }
 
 
@@ -353,9 +353,9 @@ MathInset * replaceDelims(const MathArray & ar)
 // replace '('...')' sequences by a real MathDelimInset
 void extractDelims(MathArray & ar)
 {
-       lyxerr << "\nDelims from: " << ar << "\n";
+       //lyxerr << "\nDelims from: " << ar << "\n";
        replaceNested(ar, testOpenParan, testCloseParan, replaceDelims);
-       lyxerr << "\nDelims to: " << ar << "\n";
+       //lyxerr << "\nDelims to: " << ar << "\n";
 }
 
 
@@ -373,7 +373,7 @@ void extractFunctions(MathArray & ar)
        if (ar.size() <= 1)
                return;
 
-       lyxerr << "\nFunctions from: " << ar << "\n";
+       //lyxerr << "\nFunctions from: " << ar << "\n";
        for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
                MathArray::iterator jt = it + 1;
@@ -418,7 +418,7 @@ void extractFunctions(MathArray & ar)
 
                // re-insert exponent
                ar.insert(i + 1, exp);
-               lyxerr << "\nFunctions to: " << ar << "\n";
+               //lyxerr << "\nFunctions to: " << ar << "\n";
        }
 } 
 
@@ -453,7 +453,7 @@ void extractIntegrals(MathArray & ar)
        if (ar.size() <= 2)
                return;
 
-       lyxerr << "\nIntegrals from: " << ar << "\n";
+       //lyxerr << "\nIntegrals from: " << ar << "\n";
        for (MathArray::size_type i = 0; i + 1 < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
@@ -499,7 +499,7 @@ void extractIntegrals(MathArray & ar)
                ar.erase(it + 1, tt);
                (*it).reset(p);
        }
-       lyxerr << "\nIntegrals to: " << ar << "\n";
+       //lyxerr << "\nIntegrals to: " << ar << "\n";
 }
 
 
@@ -528,7 +528,7 @@ void extractSums(MathArray & ar)
        if (ar.size() <= 1)
                return;
 
-       lyxerr << "\nSums from: " << ar << "\n";
+       //lyxerr << "\nSums from: " << ar << "\n";
        for (MathArray::size_type i = 0; i + 1< ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
@@ -575,7 +575,7 @@ void extractSums(MathArray & ar)
                ar.erase(it + 1, tt);
                (*it).reset(p);
        }
-       lyxerr << "\nSums to: " << ar << "\n";
+       //lyxerr << "\nSums to: " << ar << "\n";
 }
 
 
@@ -620,7 +620,7 @@ bool extractDiffExponent(MathArray::iterator it, int & i)
 
 void extractDiff(MathArray & ar)
 {
-       lyxerr << "\nDiffs from: " << ar << "\n";
+       //lyxerr << "\nDiffs from: " << ar << "\n";
        for (MathArray::size_type i = 0; i < ar.size(); ++i) {
                MathArray::iterator it = ar.begin() + i;
 
@@ -670,7 +670,7 @@ void extractDiff(MathArray & ar)
                                // things like   d.../dx^n
                                int mult = 1;
                                if (extractNumber(script->up().data_, mult)) {
-                                       lyxerr << "mult: " << mult << std::endl;
+                                       //lyxerr << "mult: " << mult << std::endl;
                                        for (int i = 0; i < mult; ++i)
                                                diff->addDer(MathArray(dt + 1, st));
                                }
@@ -685,7 +685,7 @@ void extractDiff(MathArray & ar)
                ar.erase(it + 1, jt);
                (*it).reset(diff);
        }
-       lyxerr << "\nDiffs to: " << ar << "\n";
+       //lyxerr << "\nDiffs to: " << ar << "\n";
 }
 
 
index 41de8015331d3913b18fecd83488a1e1b4b61a04..79229b2d959aa54472313a96688209bd43b03f0e 100644 (file)
@@ -53,6 +53,7 @@ point to write some macros:
 #include "math_inset.h"
 #include "math_arrayinset.h"
 #include "math_braceinset.h"
+#include "math_boxinset.h"
 #include "math_charinset.h"
 #include "math_deliminset.h"
 #include "math_factory.h"
@@ -73,7 +74,7 @@ point to write some macros:
 
 #include "lyxlex.h"
 #include "debug.h"
-
+#include "support/LAssert.h"
 #include "support/lstrings.h"
 
 #include <cctype>
@@ -87,6 +88,8 @@ using std::endl;
 using std::stack;
 using std::fill;
 
+//#define FILEDEBUG
+
 
 namespace {
 
@@ -539,7 +542,9 @@ void Parser::tokenize(string const & buffer)
                }
        }
 
-       //dump();
+#ifdef FILEDEBUG
+       dump();
+#endif
 }
 
 
@@ -895,9 +900,11 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
        while (good()) {
                Token const & t = getToken();
        
-               //lyxerr << "t: " << t << " flags: " << flags << "\n";
-               //array.dump(lyxerr);
-               //lyxerr << "\n";
+#ifdef FILEDEBUG
+               lyxerr << "t: " << t << " flags: " << flags << "\n";
+               //array.dump();
+               lyxerr << "\n";
+#endif
 
                if (flags & FLAG_ITEM) {
                        flags &= ~FLAG_ITEM;
@@ -976,6 +983,7 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                                return;
                        lyxerr << "found '}' unexpectedly, array: '" << array << "'\n";
                        //lyxerr << "found '}' unexpectedly\n";
+                       lyx::Assert(0);
                        add(array, '}', LM_TC_TEX);
                }
                
@@ -1157,9 +1165,12 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                        array.push_back(MathAtom(p));
                        //lyxerr << "read array: " << array << "\n";
                }
+#endif
 
-               else if (t.cs() == "mbox") {
-                       array.push_back(createMathInset(t.cs()));
+#if 0
+               else if (t.cs() == "mbox" || t.cs() == "text") {
+                       //array.push_back(createMathInset(t.cs()));
+                       array.push_back(MathAtom(new MathBoxInset(t.cs())));
                        // slurp in the argument of mbox
        
                        MathBoxInset * p = array.back()->asBoxInset();