move around debugging stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3544 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-02-15 14:07:09 +00:00
parent a5322b93c6
commit d7f701b8d6
6 changed files with 97 additions and 27 deletions

View 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;

View File

@ -112,6 +112,8 @@ public:
virtual bool isTextInset() const { return true; }
///
virtual void mutateToText();
///
virtual void revealCodes(BufferView *) const;
private:

View 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);

View File

@ -244,6 +244,10 @@ public:
///
void insert(char);
/// hack for reveal codes
void markInsert();
void markErase();
///
friend class Selection;

View 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";
}

View 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();