#include "font.h"
#include "Lsstream.h"
#include "math_arrayinset.h"
+#include "math_charinset.h"
#include "math_cursor.h"
#include "math_factory.h"
#include "math_hullinset.h"
#include "math_pos.h"
#include "math_spaceinset.h"
#include "undo_funcs.h"
+#include "textpainter.h"
#include "frontends/Dialogs.h"
#include "intl.h"
int hack_button;
-void handleFont(BufferView * bv, string const & arg, MathTextCodes t)
+void handleFont(BufferView * bv, string const & arg, MathTextCodes t)
{
if (mathcursor->selection())
bv->lockedInsetStoreUndo(Undo::EDIT);
// This is needed as long the math parser is not re-entrant
MathMacroTable::builtinMacros();
//lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
+ //lyxerr << "sizeof(MathMetricsInfo): " << sizeof(MathMetricsInfo) << "\n";
+ //lyxerr << "sizeof(MathCharInset): " << sizeof(MathCharInset) << "\n";
}
{}
-void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
+void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
{
font_ = f;
metrics(bv);
}
-void InsetFormulaBase::metrics(BufferView * bv) const
+void InsetFormulaBase::metrics(BufferView * bv) const
{
if (bv)
view_ = bv;
y -= yo_;
int asc = 0;
int des = 0;
- MathMetricsInfo mi(bv, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
- math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
+ math_font_max_dim(font_, asc, des);
bv->showLockedInsetCursor(x, y, asc, des);
//lyxerr << "toggleInsetCursor: " << x << " " << y << "\n";
}
y -= yo_;
int asc = 0;
int des = 0;
- MathMetricsInfo mi(bv, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
- math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
+ math_font_max_dim(font_, asc, des);
bv->fitLockedInsetCursor(x, y, asc, des);
//lyxerr << "showInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << "\n";
}
vector<string> const InsetFormulaBase::getLabelList() const
{
- return std::vector<string>();
+ return vector<string>();
}
bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
- int /*x*/, int /*y*/, int /*button*/)
+ int /*x*/, int /*y*/, int /*button*/)
{
if (!mathcursor)
return false;
bv->getLyXText()->selectionAsString(bv->buffer(), false);
mathed_parse_cell(ar, sel);
mathcursor->insert(ar);
- }
+ }
break;
*/
case 3:
first_x = x;
first_y = y;
- if (!mathcursor->selection())
+ if (!mathcursor->selection())
mathcursor->selStart();
-
+
//lyxerr << "insetMotionNotify: " << x + xo_ << ' ' << y + yo_
// << ' ' << button << "\n";
hideInsetCursor(bv);
//lyxerr << "InsetFormulaBase::localDispatch: act: " << action
// << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
- if (!mathcursor)
+ if (!mathcursor)
return UNDISPATCHED;
if (mathcursor->asHyperActiveInset()) {
hideInsetCursor(bv);
mathcursor->normalize();
+ mathcursor->touch();
+
switch (action) {
// --- Cursor Movements ---------------------------------------------
case LFUN_DEFAULT: handleFont(bv, arg, LM_TC_VAR); break;
case LFUN_FREE: handleFont(bv, arg, LM_TC_TEXTRM); break;
- case LFUN_GREEK:
+ case LFUN_GREEK:
handleFont(bv, arg, LM_TC_GREEK1);
if (arg.size())
mathcursor->interpret(arg);
break;
case LFUN_MATH_MODE:
-#if 0
+#if 1
handleFont(bv, arg, LM_TC_TEXTRM);
#endif
updateLocal(bv, true);
break;
}
-
+
case LFUN_SUPERSCRIPT:
case LFUN_SUBSCRIPT:
{
updateLocal(bv, true);
break;
}
-
+
case LFUN_MATH_DELIM:
{
lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
MathInset::idx_type idx = 0;
MathGridInset * p = mathcursor ? mathcursor->enclosingGrid(idx) : 0;
if (p) {
+ mathcursor->popToEnclosingGrid();
bv->lockedInsetStoreUndo(Undo::EDIT);
- char al = arg.size() ? arg[0] : 'c';
+ char align = arg.size() ? arg[0] : 'c';
switch (action) {
- case LFUN_MATH_HALIGN: p->halign(al, p->col(idx)); break;
- case LFUN_MATH_VALIGN: p->valign(al); break;
+ case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break;
+ case LFUN_MATH_VALIGN: p->valign(align); break;
case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break;
case LFUN_MATH_ROW_DELETE: p->delRow(p->row(idx)); break;
case LFUN_MATH_COLUMN_INSERT: p->addCol(p->col(idx)); break;
}
mathcursor->normalize();
+ mathcursor->touch();
lyx::Assert(mathcursor);
}
-void InsetFormulaBase::revealCodes(BufferView * bv) const
+void InsetFormulaBase::revealCodes(BufferView * /*bv*/) const
{
if (!mathcursor)
return;
//lyxerr << "reset lastformula to " << this << "\n";
lastformula = this;
laststr = str;
- current = ibegin(par().nucleus());
+ current = ibegin(par().nucleus());
ar.clear();
mathed_parse_cell(ar, str);
} else {
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
// formula otherwise
- if (sel.find("\\newcommand") == string::npos)
+ if (sel.find("\\newcommand") == string::npos &&
+ sel.find("\\def") == string::npos)
f = new InsetFormula(sel);
else {
string name;
mathDispatchCreation(bv, arg, true);
}
-
+
void mathDispatchMathMode(BufferView * bv, string const & arg)
{
mathDispatchCreation(bv, arg, false);
if (arg.empty())
bv->owner()->getLyXFunc()->setErrorMessage(N_("Missing argument"));
else {
- string s(arg);
+ string s = arg;
string const s1 = token(s, ' ', 1);
int const na = s1.empty() ? 0 : lyx::atoi(s1);
openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na));
void mathDispatchMathDelim(BufferView * bv, string const & arg)
{
- if (bv->available()) {
+ if (bv->available()) {
if (openNewInset(bv, new InsetFormula))
bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
}
-}
+}
void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
-{
- if (bv->available()) {
+{
+ if (bv->available()) {
if (openNewInset(bv, new InsetFormula))
bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
}
-}
+}
void mathDispatchInsertMath(BufferView * bv, string const & arg)
void mathDispatchGreek(BufferView * bv, string const & arg)
-{
- if (bv->available()) {
+{
+ if (bv->available()) {
InsetFormula * f = new InsetFormula;
if (openNewInset(bv, f)) {
bv->theLockingInset()->localDispatch(bv, LFUN_GREEK, arg);
bv->unlockInset(f);
}
}
-}
+}
void mathDispatch(BufferView *, kb_action, string const &)
-{}
+{}