/*
-* File: formula.C
-* Purpose: Implementation of formula inset
+* File: formulabase.C
+* Purpose: Implementation of common parts of the LyX math insets
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
-* Description: Allows the edition of math paragraphs inside Lyx.
*
* Copyright: 1996-1998 Alejandro Aguilar Sierra
*
int sel_y;
bool sel_flag;
-void mathed_init_fonts();
-
-string nicelabel(string const & label)
-{
- return "(" + (label.empty() ? "#" : label) + ")";
-}
-
void handleFont(BufferView * bv, MathTextCodes t)
{
if (mathcursor->selection())
// returns the nearest enclosing grid
-MathArrayInset * matrixpar(int & idx)
+MathArrayInset * matrixpar(unsigned int & idx)
{
idx = 0;
return (mathcursor ? mathcursor->enclosingArray(idx) : 0);
InsetFormulaBase::InsetFormulaBase()
{
-#ifdef WITH_WARNINGS
-#warning This is needed as long the math parser is not re-entrant
-#endif
+ // This is needed as long the math parser is not re-entrant
MathMacroTable::builtinMacros();
//lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
}
-void InsetFormulaBase::read(Buffer const *, LyXLex & lex)
-{
- read(lex);
-}
-
-
-void InsetFormulaBase::write(Buffer const *, ostream & os) const
-{
- write(os);
-}
-
-
-int InsetFormulaBase::latex(Buffer const *, ostream & os,
- bool fragile, bool spacing) const
-{
- return latex(os, fragile, spacing);
-}
-
-
-int InsetFormulaBase::ascii(Buffer const *, ostream & os, int spacing) const
-{
- return ascii(os, spacing);
-}
-
-
-int InsetFormulaBase::linuxdoc(Buffer const *, ostream & os) const
-{
- return linuxdoc(os);
-}
-
-
-int InsetFormulaBase::docBook(Buffer const *, ostream & os) const
-{
- return docBook(os);
-}
-
-
-
// Check if uses AMS macros
void InsetFormulaBase::validate(LaTeXFeatures &) const
{}
string rs;
istringstream is(arg.c_str());
is >> ls >> rs;
- latexkeys const * l = in_word_set(ls);
- latexkeys const * r = in_word_set(rs);
- if (!is || !l || !r) {
+ if (!is) {
lyxerr << "can't parse delimeters from '" << arg << "'\n";
break;
}
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->handleDelim(l, r);
+ mathcursor->handleDelim(ls, rs);
updateLocal(bv, true);
break;
}
{
bv->lockedInsetStoreUndo(Undo::INSERT);
lyxerr << "handling halign '" << arg << "'\n";
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
{
bv->lockedInsetStoreUndo(Undo::INSERT);
lyxerr << "handling valign '" << arg << "'\n";
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
case LFUN_MATH_ROW_INSERT:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl;
if (!p)
case LFUN_MATH_ROW_DELETE:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl;
if (!p)
case LFUN_MATH_COLUMN_INSERT:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
case LFUN_MATH_COLUMN_DELETE:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
- int idx;
+ unsigned int idx;
MathArrayInset * p = matrixpar(idx);
if (!p)
break;
break;
default:
- lyxerr << "Closed by action " << action << endl;
- result = FINISHED_RIGHT;
+ result = UNDISPATCHED;
}
- mathcursor->normalize();
+ //mathcursor->normalize();
if (was_macro != mathcursor->inMacroMode()
&& action >= 0 && action != LFUN_BACKSPACE)
// sel = "";
//else
- string sel = bv->getLyXText()->selectionAsString(bv->buffer());
+ string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
+ false);
InsetFormulaBase * f;
if (sel.empty()) {
- f = new InsetFormula;
- if (openNewInset(bv, f)) {
- // don't do that also for LFUN_MATH_MODE unless you want end up with
- // always changing to mathrm when opening an inlined inset
- // -- I really hate "LyXfunc overloading"...
- if (display)
- f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
- f->localDispatch(bv, LFUN_INSERT_MATH, arg);
- }
+ f = new InsetFormula;
+ if (openNewInset(bv, f)) {
+ // don't do that also for LFUN_MATH_MODE unless you want end up with
+ // always changing to mathrm when opening an inlined inset
+ // -- I really hate "LyXfunc overloading"...
+ if (display)
+ f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
+ f->localDispatch(bv, LFUN_INSERT_MATH, arg);
+ }
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
// formula otherwise