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;
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;
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)
continue;
*it = MathAtom(new MathMatrixInset(*(arr->asArrayInset())));
}
- lyxerr << "\nMatrices to: " << ar << "\n";
+ //lyxerr << "\nMatrices to: " << ar << "\n";
}
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;
++i;
ar.insert(i, MathAtom(q));
}
- lyxerr << "\nScripts to: " << ar << "\n";
+ //lyxerr << "\nScripts to: " << ar << "\n";
}
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;
(*it).reset(func);
ar.erase(it + 1);
}
- lyxerr << "\nExps to: " << ar << "\n";
+ //lyxerr << "\nExps to: " << ar << "\n";
}
// 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";
}
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;
// re-insert exponent
ar.insert(i + 1, exp);
- lyxerr << "\nFunctions to: " << ar << "\n";
+ //lyxerr << "\nFunctions to: " << ar << "\n";
}
}
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;
ar.erase(it + 1, tt);
(*it).reset(p);
}
- lyxerr << "\nIntegrals to: " << ar << "\n";
+ //lyxerr << "\nIntegrals to: " << ar << "\n";
}
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;
ar.erase(it + 1, tt);
(*it).reset(p);
}
- lyxerr << "\nSums to: " << ar << "\n";
+ //lyxerr << "\nSums to: " << ar << "\n";
}
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;
// 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));
}
ar.erase(it + 1, jt);
(*it).reset(diff);
}
- lyxerr << "\nDiffs to: " << ar << "\n";
+ //lyxerr << "\nDiffs to: " << ar << "\n";
}
#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"
#include "lyxlex.h"
#include "debug.h"
-
+#include "support/LAssert.h"
#include "support/lstrings.h"
#include <cctype>
using std::stack;
using std::fill;
+//#define FILEDEBUG
+
namespace {
}
}
- //dump();
+#ifdef FILEDEBUG
+ dump();
+#endif
}
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;
return;
lyxerr << "found '}' unexpectedly, array: '" << array << "'\n";
//lyxerr << "found '}' unexpectedly\n";
+ lyx::Assert(0);
add(array, '}', LM_TC_TEX);
}
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();